Skip to content

Commit

Permalink
[location-cards] Shortcode / @with/@Of bugfix -- use = for singleton …
Browse files Browse the repository at this point in the history
…arrays, allowing for ROWID queries. Google's sub-SQL dialect apparently can't handle sending ROWID through an IN operator?
  • Loading branch information
radgeek committed Nov 19, 2012
1 parent cb9bfb8 commit 52da302
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions extensions/fusion/occupysandyfrontend.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -86,16 +86,22 @@ function the_occupy_sandy_cards ($params = array()) {
if (is_array($params['matches'])) : if (is_array($params['matches'])) :
$whereClauses = array(); $whereClauses = array();
foreach ($params['matches'] as $col => $value) : foreach ($params['matches'] as $col => $value) :
if (is_array($value)) : if (!is_array($value)) :
$value = array($value);
endif;

if (count($value) > 1) :
$operator = 'IN'; $operator = 'IN';
$operand = "("; $operand = "(";
if (count($value) > 0) : if (count($value) > 0) :
$operand .= "'" . implode("', '", array_map(array($wpdb, 'escape'), $value)) . "'"; $operand .= "'" . implode("', '", array_map(function ($v) {
return $GLOBALS['wpdb']->escape(trim($v));
}, $value)) . "'";
endif; endif;
$operand .= ")"; $operand .= ")";
else : else :
$operator = '='; $operator = '=';
$operand = "'".$wpdb->escape($value)."'"; $operand = "'".$wpdb->escape(reset($value))."'";
endif; endif;


$whereClauses[] = "$col $operator $operand"; $whereClauses[] = "$col $operator $operand";
Expand Down

0 comments on commit 52da302

Please sign in to comment.