Skip to content

Commit 66ce71f

Browse files
committed
Refactor xPDO->sanitizePKCriteria to use prepared statments
1 parent 6271aa9 commit 66ce71f

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

src/xPDO/xPDO.php

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2750,20 +2750,19 @@ protected function sanitizePKCriteria($className, &$criteria) {
27502750
if (is_scalar($criteria)) {
27512751
$pkType = $this->getPKType($className);
27522752
if (is_string($pkType)) {
2753-
if (is_string($criteria) && !xPDOQuery::isValidClause($criteria)) {
2754-
$criteria = null;
2755-
} else {
2756-
switch ($pkType) {
2757-
case 'int':
2758-
case 'integer':
2759-
$criteria = (int)$criteria;
2760-
break;
2761-
case 'string':
2762-
if (is_int($criteria)) {
2763-
$criteria = (string)$criteria;
2764-
}
2753+
$pk = $this->getPK($className);
2754+
switch ($pkType) {
2755+
case 'int':
2756+
case 'integer':
2757+
if (!is_numeric($criteria)) {
2758+
$criteria = null;
27652759
break;
2766-
}
2760+
}
2761+
$criteria = [$pk => (int)$criteria];
2762+
break;
2763+
case 'string':
2764+
$criteria = [$pk => (string)$criteria];
2765+
break;
27672766
}
27682767
} elseif (is_array($pkType)) {
27692768
$criteria = null;

0 commit comments

Comments
 (0)