@@ -50,16 +50,16 @@ |
||
50 | 50 | return $destination; |
51 | 51 | } |
52 | 52 | |
53 | - /** |
|
54 | - * Turn the stadClass object to the type of calling Model |
|
55 | - * |
|
56 | - * @param String $destination |
|
57 | - * @param Object $sourceObject |
|
58 | - * @return Object $destination |
|
59 | - * |
|
60 | - * @author RN Kushwaha <[email protected]> |
|
61 | - * @since v0.0.5 |
|
62 | - */ |
|
53 | + /** |
|
54 | + * Turn the stadClass object to the type of calling Model |
|
55 | + * |
|
56 | + * @param String $destination |
|
57 | + * @param Object $sourceObject |
|
58 | + * @return Object $destination |
|
59 | + * |
|
60 | + * @author RN Kushwaha <[email protected]> |
|
61 | + * @since v0.0.5 |
|
62 | + */ |
|
63 | 63 | public function turnObjects($destination, $data) |
64 | 64 | { |
65 | 65 | $destination = new $destination(); |
@@ -23,16 +23,16 @@ |
||
23 | 23 | } |
24 | 24 | |
25 | 25 | public function buildQueryStrSingleFromArr($row = array()){ |
26 | - $ar = []; |
|
27 | - $query = "UPDATE ".$this->table." SET "; |
|
28 | - foreach($row as $key => $val){ |
|
29 | - $ar[':'.$key] = $val; |
|
30 | - if($key == 'id') continue; |
|
31 | - $query.= $this->qb->quote($key)." =:".$key.","; |
|
32 | - } |
|
33 | - $query = rtrim($query, ","); |
|
26 | + $ar = []; |
|
27 | + $query = "UPDATE ".$this->table." SET "; |
|
28 | + foreach($row as $key => $val){ |
|
29 | + $ar[':'.$key] = $val; |
|
30 | + if($key == 'id') continue; |
|
31 | + $query.= $this->qb->quote($key)." =:".$key.","; |
|
32 | + } |
|
33 | + $query = rtrim($query, ","); |
|
34 | 34 | |
35 | - return ['ar' => $ar, 'query' => $query]; |
|
35 | + return ['ar' => $ar, 'query' => $query]; |
|
36 | 36 | } |
37 | 37 | public function createQuery($row){ |
38 | 38 | $ar = []; |
@@ -66,7 +66,7 @@ |
||
66 | 66 | } |
67 | 67 | |
68 | 68 | private function checkMultipleInsert($rows = array()){ |
69 | - return is_array($rows) && isset($rows[0]) && is_array($rows[0]); |
|
69 | + return is_array($rows) && isset($rows[0]) && is_array($rows[0]); |
|
70 | 70 | } |
71 | 71 | /** |
72 | 72 | * It inserts the new rows |
@@ -26,14 +26,14 @@ |
||
26 | 26 | * @since v0.0.5 |
27 | 27 | */ |
28 | 28 | public function update( |
29 | - $row, |
|
30 | - $table, |
|
31 | - $where, |
|
32 | - $whereRaw, |
|
33 | - $whereIn, |
|
34 | - $whereNotIn, |
|
35 | - $whereNull, |
|
36 | - $whereNotNull |
|
29 | + $row, |
|
30 | + $table, |
|
31 | + $where, |
|
32 | + $whereRaw, |
|
33 | + $whereIn, |
|
34 | + $whereNotIn, |
|
35 | + $whereNull, |
|
36 | + $whereNotNull |
|
37 | 37 | ) |
38 | 38 | { |
39 | 39 | $wqb = new WhereQueryBuilder(); |
@@ -299,8 +299,8 @@ discard block |
||
299 | 299 | } |
300 | 300 | |
301 | 301 | if(count($this->results) ){ |
302 | - // now turn this stdClass object to the object type of calling model |
|
303 | - $rows = $util->turnObjects($this->className, $this->results); |
|
302 | + // now turn this stdClass object to the object type of calling model |
|
303 | + $rows = $util->turnObjects($this->className, $this->results); |
|
304 | 304 | } |
305 | 305 | // Reset class variables |
306 | 306 | $this->reset(); |
@@ -424,14 +424,14 @@ discard block |
||
424 | 424 | public function update($row) |
425 | 425 | { |
426 | 426 | $result = (new UpdateQueryBuilder())->update( |
427 | - $row, |
|
428 | - $this->table, |
|
429 | - $this->where, |
|
430 | - $this->whereRaw, |
|
431 | - $this->whereIn, |
|
432 | - $this->whereNotIn, |
|
433 | - $this->whereNull, |
|
434 | - $this->whereNotNull |
|
427 | + $row, |
|
428 | + $this->table, |
|
429 | + $this->where, |
|
430 | + $this->whereRaw, |
|
431 | + $this->whereIn, |
|
432 | + $this->whereNotIn, |
|
433 | + $this->whereNull, |
|
434 | + $this->whereNotNull |
|
435 | 435 | ); |
436 | 436 | |
437 | 437 | $this->reset(); |
@@ -470,13 +470,13 @@ discard block |
||
470 | 470 | public function delete() |
471 | 471 | { |
472 | 472 | $result = (new DeleteQueryBuilder())->delete( |
473 | - $this->table, |
|
474 | - $this->where, |
|
475 | - $this->whereRaw, |
|
476 | - $this->whereIn, |
|
477 | - $this->whereNotIn, |
|
478 | - $this->whereNull, |
|
479 | - $this->whereNotNull |
|
473 | + $this->table, |
|
474 | + $this->where, |
|
475 | + $this->whereRaw, |
|
476 | + $this->whereIn, |
|
477 | + $this->whereNotIn, |
|
478 | + $this->whereNull, |
|
479 | + $this->whereNotNull |
|
480 | 480 | ); |
481 | 481 | |
482 | 482 | $this->reset(); |
@@ -78,37 +78,37 @@ |
||
78 | 78 | } |
79 | 79 | |
80 | 80 | private function buildLimitQuery($limit, $offset, $query = array()){ |
81 | - $limitQuery = []; |
|
82 | - if (!empty($limit)) { |
|
83 | - $query[] = 'LIMIT'; |
|
81 | + $limitQuery = []; |
|
82 | + if (!empty($limit)) { |
|
83 | + $query[] = 'LIMIT'; |
|
84 | 84 | |
85 | - if (!empty($offset)) { |
|
86 | - $query[] = $offset.','; |
|
87 | - } |
|
85 | + if (!empty($offset)) { |
|
86 | + $query[] = $offset.','; |
|
87 | + } |
|
88 | 88 | |
89 | - $query[] = $limit; |
|
90 | - } |
|
89 | + $query[] = $limit; |
|
90 | + } |
|
91 | 91 | |
92 | - if (count($limitQuery)) { |
|
93 | - $query = array_merge($query, $limitQuery); |
|
94 | - } |
|
95 | - return $query; |
|
92 | + if (count($limitQuery)) { |
|
93 | + $query = array_merge($query, $limitQuery); |
|
94 | + } |
|
95 | + return $query; |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | public function query($query, $fetchRows){ |
99 | - try { |
|
100 | - $obj = Connection::get()->query($this->queryPrefix($query), \PDO::FETCH_OBJ); |
|
101 | - |
|
102 | - if ($fetchRows == 'count') { |
|
103 | - $obj = $obj->fetchColumn(); |
|
104 | - } |
|
105 | - |
|
106 | - return $obj; |
|
107 | - } catch (\PDOException $ex) { |
|
108 | - throw new \PDOException($ex->getMessage(), 1); |
|
109 | - } catch (Exception $e) { |
|
110 | - throw new Exception($e->getMessage(), 1); |
|
111 | - } |
|
99 | + try { |
|
100 | + $obj = Connection::get()->query($this->queryPrefix($query), \PDO::FETCH_OBJ); |
|
101 | + |
|
102 | + if ($fetchRows == 'count') { |
|
103 | + $obj = $obj->fetchColumn(); |
|
104 | + } |
|
105 | + |
|
106 | + return $obj; |
|
107 | + } catch (\PDOException $ex) { |
|
108 | + throw new \PDOException($ex->getMessage(), 1); |
|
109 | + } catch (Exception $e) { |
|
110 | + throw new Exception($e->getMessage(), 1); |
|
111 | + } |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | public function buildQuery(array $params) |
@@ -26,13 +26,13 @@ |
||
26 | 26 | * @since v0.0.5 |
27 | 27 | */ |
28 | 28 | public function delete( |
29 | - $table, |
|
30 | - $where, |
|
31 | - $whereRaw, |
|
32 | - $whereIn, |
|
33 | - $whereNotIn, |
|
34 | - $whereNull, |
|
35 | - $whereNotNull |
|
29 | + $table, |
|
30 | + $where, |
|
31 | + $whereRaw, |
|
32 | + $whereIn, |
|
33 | + $whereNotIn, |
|
34 | + $whereNull, |
|
35 | + $whereNotNull |
|
36 | 36 | ) |
37 | 37 | { |
38 | 38 | $wqb = new WhereQueryBuilder(); |