-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwrapper.php
42 lines (32 loc) · 855 Bytes
/
wrapper.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php namespace phpsql\utils;
include("vendor/autoload.php");
class wrapper
{
private $obj;
public function __construct($obj)
{
$this->obj = $obj;
}
public function __call($method, $args)
{
return call_user_func_array([$this->obj, $method], $args);
}
public function Query($query, $params = [], $one_row = false, $reindex_by = null)
{
$res = $this->obj->Query($query, $params, $one_row, $reindex_by);
if (is_string($res))
return $res;
$row_array_to_obj = function($row)
{
return new \phpa2o\phpa2o($row);
};
return $row_array_to_obj($res);
}
public function SafeQuery($query, $params = [], $one_row = false, $reindex_by = null)
{
$res = $this->Query($query, $params, $one_row, $reindex_by);
if (is_string($res))
throw new \Exception($res);
return $res;
}
}