CoreFiles by mySites.guru
sql.php58 lines, 1,017 bytes, from Joomla_3.9.2-rc-Release_Candidate-Full_Package.zip
Raw History Compare with 3.9.1-rc
md5
3c8eb1b1e4e84e6e2e8ae002e89f15f5
sha1
c53b43d67bc2c5150c38105c67a8ef7296934593
sha256
f51129a2ea1951a1b17dd6619842adb9afbeb8ecc46e56c9811f18ca2000b058
<?php
/**
 * @package     Joomla.Plugin
 * @subpackage  Fields.Sql
 *
 * @copyright   Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */
defined('_JEXEC') or die;

$value = $field->value;

if ($value == '')
{
	return;
}

$db        = JFactory::getDbo();
$value     = (array) $value;
$condition = '';

foreach ($value as $v)
{
	if (!$v)
	{
		continue;
	}

	$condition .= ', ' . $db->q($v);
}

$query = $fieldParams->get('query', '');

// Run the query with a having condition because it supports aliases
$db->setQuery($query . ' having value in (' . trim($condition, ',') . ')');

try
{
	$items = $db->loadObjectlist();
}
catch (Exception $e)
{
	// If the query failed, we fetch all elements
	$db->setQuery($query);
	$items = $db->loadObjectlist();
}

$texts = array();

foreach ($items as $item)
{
	if (in_array($item->value, $value))
	{
		$texts[] = $item->text;
	}
}

echo htmlentities(implode(', ', $texts));

The same content is in 26 releases, Joomla 3.9.2-rc to 3.9.14. See them all, or every version of this file.