Fixed DB class not finding $manager + Refactor methods to be similar to Node
This commit is contained in:
parent
3a3cf576e5
commit
f9540b9aab
|
@ -13,9 +13,18 @@ class DB {
|
|||
$this->db_name = $db_name;
|
||||
}
|
||||
|
||||
function query($table, $q) {
|
||||
function findOne($table, $q) {
|
||||
$result = $this->find($table, $q);
|
||||
if ($result === null)
|
||||
return null;
|
||||
if (count($result) === 0)
|
||||
return null;
|
||||
return $result[0];
|
||||
}
|
||||
|
||||
function find($table, $q) {
|
||||
$query = new MongoDB\Driver\Query($q);
|
||||
$cursor = $manager->executeQuery($this->db_name.'.'.$table, $query);
|
||||
$cursor = $this->manager->executeQuery($this->db_name.'.'.$table, $query);
|
||||
return $cursor->toArray();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue