37 require_once realpath(dirname(__FILE__).
"/query.inc");
58 if (!$json)
return null;
60 $json = json_decode($json);
62 if (is_object($json)) $json = array($json);
64 foreach($json as $jsonItem)
68 $item->fromJSON($jsonItem);
79 trace(print_r($json,
true), 1);
80 if (!$json)
return null;
84 throw new FakoliException(
"Ambiguous Singleton Query - JSON");
89 $item->fromJSON($json);
91 trace(print_r($item,
true), 1);
101 if (!
startsWith($query,
"SELECT ")) $query =
"SELECT $query";
107 $result = $db->prepare($query);
108 $result->execute($this->
params);
112 $line = $result->fetch();
113 trace(print_r($line,
true), 1);
122 catch(PDOException $e)
124 $err =
"JSONQuery failed - " . $e->getMessage();
params($params)
Sets the bound parameters array.
static getConnection()
Retrieves a reference to the global database connection.
__construct($class, $constraints="")
static create($class, $constraints="")
trace($msg, $lvl=3, $callStack=null)
Send output to the trace log.
startsWith($text, $start)
Tests whether a string starts with a given sub-string.