Skip to content
Browse files

- Automatically pick up on primary key name

- Support GUID PKs and escape for ID input (thanks Gbob)
  • Loading branch information...
1 parent 971fc02 commit 7dc9ac69bf8615329a5a5466a0f8ee9213a1f4e6 Steven Bredenberg committed May 10, 2011
Showing with 6 additions and 2 deletions.
  1. +6 −2 axonrest.php
View
8 axonrest.php
@@ -81,8 +81,12 @@ static protected function getObject($name, $where=null) {
// Now load this mess.
$x = new AxonHelper($name);
if ($where !== null) {
+ list($pk) = each($x->keys);
if (is_numeric($where)) {
- $where = sprintf("id=%d", $where);
+ $where = sprintf("%s=%d", $pk, intval($where));
+ } else {
+ $where = sprintf("%s='%s'", $pk,
+ addslashes(preg_replace('/[^[:print:]]/', '', $where)));
}
$x->load($where);
}
@@ -163,7 +167,7 @@ static public function get() {
}
if (!empty($object_id)) {
- $object = self::getObject($object_name, intval($object_id));
+ $object = self::getObject($object_name, $object_id);
if ($object->dry()) {
f3::http404();
} else {

0 comments on commit 7dc9ac6

Please sign in to comment.
Something went wrong with that request. Please try again.