Skip to content

Commit

Permalink
Fixing issue with join getQuery(), which was producing a WHERE clause
Browse files Browse the repository at this point in the history
with IN () under some circumstances, which isn't valid MySQL.  So detect
that, and replace it with 1=-1
  • Loading branch information
cheesegrits committed Aug 15, 2013
1 parent 5ff754e commit d8f9ac8
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion plugins/fabrik_element/databasejoin/databasejoin.php
Expand Up @@ -2613,8 +2613,22 @@ public function getLabelForValue($v, $defaultLabel = null, $forceCheck = false)
$query->clear('where');
if (is_array($v))
{
/**
* $$$ hugh - tweaked this a little, as IN () pitches an error in
* MySQL, so we need to make sure we don't end up with that. So as
* IN (), if it worked, would produce no rows, just replace with 1=-1
* Can't just count($v), as sometimes it's an array with a single null entry.
*/
array_map(array($db, 'quote'), $v);
$query->where($key . ' IN (' . implode(',', $v) . ')');
$ins = implode(',', $v);
if (trim($ins) === '')
{
$query->where('1=-1');
}
else
{
$query->where($key . ' IN (' . $ins . ')');
}
}
else
{
Expand Down

0 comments on commit d8f9ac8

Please sign in to comment.