Skip to content

Commit e813df0

Browse files
author
peejeh
committed
Added quotes around all primary values put into SQL WHERE statements so as to allow non-numeric primary keys.
1 parent fa087b9 commit e813df0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

phprestsql.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
* PHP REST SQL class
2525
* The base class for the Rest SQL system that opens up a REST interface to a MySQL database.
2626
*/
27-
class PHPRestSQL {
27+
class PHPRestSQfL {
2828

2929
/**
3030
* Parsed configuration file
@@ -292,7 +292,7 @@ function post() {
292292
$values = substr($values, 0, -2);
293293
$where = '';
294294
foreach($primary as $key => $pri) {
295-
$where .= $pri.' = '.$this->uid[$key].' AND ';
295+
$where .= $pri.' = \''.$this->uid[$key].'\' AND ';
296296
}
297297
$where = substr($where, 0, -5);
298298
$resource = $this->db->updateRow($this->table, $values, $where);
@@ -431,7 +431,7 @@ function delete() {
431431
if ($primary && count($primary) == count($this->uid)) { // delete a row
432432
$where = '';
433433
foreach($primary as $key => $pri) {
434-
$where .= $pri.' = '.$this->uid[$key].' AND ';
434+
$where .= $pri.' = \''.$this->uid[$key].'\' AND ';
435435
}
436436
$where = substr($where, 0, -5);
437437
$resource = $this->db->deleteRow($this->table, $where);

0 commit comments

Comments
 (0)