Open radar3301 opened 3 years ago
function fetch($db, $translator, $wheres) { $query = new \ClanCats\Hydrahon\Query\Sql\Select; /* other stuff to setup query */ $query->where($wheres); list($queryString, $queryParams) = $translator->translate($query); return getQueryResult($db, $queryString, $queryParams); } fetch($mysqli, $translator, [ 'otherThing' => 'otherValue', 'status' => [ 'Active', 'Inactive' ] ]);
The above code generates a MySQL error: "Operand should contain 1 column(s)"
Examining the generated query string:
select fields from table where ( `otherThing` = ?, `status` = (?, ?) )
The Fix:
Replace \ClanCats\Hydrahon\Query\Sql\SelectBase.php:153-156:
\ClanCats\Hydrahon\Query\Sql\SelectBase.php:153-156
if (is_array($param2)) { $param2 = array_unique($param2); }
With:
if (is_array($param2)) { $param2 = array_unique($param2); if ($param1 === '=') $param1 = 'IN'; }
The above code generates a MySQL error: "Operand should contain 1 column(s)"
Examining the generated query string:
The Fix:
Replace
\ClanCats\Hydrahon\Query\Sql\SelectBase.php:153-156
:With: