mirror of
https://github.com/e107inc/e107.git
synced 2025-07-25 17:01:43 +02:00
#4564: Un-break validatorClass::dbValidateArray()
counter
I forgot an `AND` in the `WHERE` clause for the `e_db_pdo` implementation of `validatorClass::dbValidateArray()`. Fixes: https://github.com/e107inc/e107/issues/4564
This commit is contained in:
@@ -1387,17 +1387,24 @@ class validatorClass
|
|||||||
}
|
}
|
||||||
$field = varset($options['dbFieldName'], $f);
|
$field = varset($options['dbFieldName'], $f);
|
||||||
// XXX: Different implementations due to missing API for preventing SQL injections
|
// XXX: Different implementations due to missing API for preventing SQL injections
|
||||||
$count = 0;
|
|
||||||
if ($u_sql instanceof e_db_mysql)
|
if ($u_sql instanceof e_db_mysql)
|
||||||
{
|
{
|
||||||
$v = $u_sql->escape($v);
|
$v = $u_sql->escape($v);
|
||||||
$count = $u_sql->count($targetTable, "(*)", "WHERE `{$f}`='$v' AND `user_id` != " . $userID);
|
$count = (int) $u_sql->count($targetTable, "(*)", "WHERE `{$f}`='$v' AND `user_id` != " . $userID);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$u_sql->select($targetTable, "COUNT(*)", "`{$f}`=:value", ['value' => $v]);
|
$u_sql->select(
|
||||||
|
$targetTable,
|
||||||
|
"COUNT(*)",
|
||||||
|
"`{$f}`=:value AND `user_id` != :userID",
|
||||||
|
[
|
||||||
|
'value' => $v,
|
||||||
|
'userID' => $userID,
|
||||||
|
]
|
||||||
|
);
|
||||||
$row = $u_sql->fetch('num');
|
$row = $u_sql->fetch('num');
|
||||||
$count = $row[0];
|
$count = (int) $row[0];
|
||||||
}
|
}
|
||||||
if ($count)
|
if ($count)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user