@@ -227,6 +227,9 @@ |
||
227 | 227 | } |
228 | 228 | } |
229 | 229 | |
230 | + /** |
|
231 | + * @param string $event |
|
232 | + */ |
|
230 | 233 | private function runBehaviours($event, $args) { |
231 | 234 | foreach ($this->wrapper->getBehaviours() as $behaviour) { |
232 | 235 | $args[0] = call_user_func_array([$behaviour, $event], $args); |
@@ -118,6 +118,9 @@ |
||
118 | 118 | return $this->queryEngine; |
119 | 119 | } |
120 | 120 | |
121 | + /** |
|
122 | + * @param RecordWrapper $model |
|
123 | + */ |
|
121 | 124 | public function setModel($model) { |
122 | 125 | $this->modelInstance = $model; |
123 | 126 | } |
@@ -190,6 +190,10 @@ |
||
190 | 190 | return $return; |
191 | 191 | } |
192 | 192 | |
193 | + /** |
|
194 | + * @param integer $level |
|
195 | + * @param string $opr |
|
196 | + */ |
|
193 | 197 | private function parseRightExpression($level, $opr) { |
194 | 198 | switch ($opr) { |
195 | 199 | case 'between': return $this->parseBetween(); |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | $this->getToken(); |
58 | 58 | $expression = $this->parseExpression(); |
59 | 59 | if ($this->token !== false) { |
60 | - throw new FilterCompilerException("Unexpected '" . $this->token . "' in filter [$filter]"); |
|
60 | + throw new FilterCompilerException("Unexpected '".$this->token."' in filter [$filter]"); |
|
61 | 61 | } |
62 | 62 | $parsed = $this->renderExpression($expression); |
63 | 63 | return $parsed; |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | |
66 | 66 | private function renderExpression($expression) { |
67 | 67 | if (is_array($expression)) { |
68 | - $expression = $this->renderExpression($expression['left']) . " {$expression['opr']} " . $this->renderExpression($expression['right']); |
|
68 | + $expression = $this->renderExpression($expression['left'])." {$expression['opr']} ".$this->renderExpression($expression['right']); |
|
69 | 69 | } |
70 | 70 | return $expression; |
71 | 71 | } |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | $tokens = [$tokens]; |
76 | 76 | } |
77 | 77 | if (array_search($this->lookahead, $tokens) === false) { |
78 | - throw new FilterCompilerException("Expected " . implode(' or ', $tokens) . " but found " . $this->lookahead); |
|
78 | + throw new FilterCompilerException("Expected ".implode(' or ', $tokens)." but found ".$this->lookahead); |
|
79 | 79 | } |
80 | 80 | } |
81 | 81 | |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | } |
161 | 161 | |
162 | 162 | private function returnPositionTag() { |
163 | - return ":filter_bind_" . ( ++$this->numPositions); |
|
163 | + return ":filter_bind_".( ++$this->numPositions); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | private function parseObracket() { |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | } |
238 | 238 | |
239 | 239 | if ($this->token === false && strlen($this->filter) > 0) { |
240 | - throw new FilterCompilerException("Unexpected character [" . $this->filter[0] . "] begining " . $this->filter . "."); |
|
240 | + throw new FilterCompilerException("Unexpected character [".$this->filter[0]."] begining ".$this->filter."."); |
|
241 | 241 | } |
242 | 242 | } |
243 | 243 | |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | $rewritten = []; |
252 | 252 | foreach ($data as $key => $value) { |
253 | 253 | if (is_numeric($key)) { |
254 | - $rewritten["filter_bind_" . ($key + 1)] = $value; |
|
254 | + $rewritten["filter_bind_".($key + 1)] = $value; |
|
255 | 255 | } else { |
256 | 256 | $rewritten[$key] = $value; |
257 | 257 | } |
@@ -90,6 +90,9 @@ |
||
90 | 90 | return $relationshipDetails; |
91 | 91 | } |
92 | 92 | |
93 | + /** |
|
94 | + * @param string $type |
|
95 | + */ |
|
93 | 96 | private function createRelationships($type, $relationships) { |
94 | 97 | foreach ($relationships as $relationship) { |
95 | 98 | $relationship = $this->getRelationshipDetails($relationship); |
@@ -22,6 +22,11 @@ |
||
22 | 22 | 'save' |
23 | 23 | ]; |
24 | 24 | |
25 | + /** |
|
26 | + * @param RecordWrapper $wrapper |
|
27 | + * @param DriverAdapter $adapter |
|
28 | + * @param string $table |
|
29 | + */ |
|
25 | 30 | public function __construct($wrapper, $adapter, $table) { |
26 | 31 | $this->wrapper = $wrapper; |
27 | 32 | $this->adapter = $adapter; |
@@ -6,10 +6,16 @@ discard block |
||
6 | 6 | |
7 | 7 | private $db; |
8 | 8 | |
9 | + /** |
|
10 | + * @param \ntentan\atiaa\Driver $driver |
|
11 | + */ |
|
9 | 12 | public function setDriver($driver) { |
10 | 13 | $this->db = $driver; |
11 | 14 | } |
12 | 15 | |
16 | + /** |
|
17 | + * @param string $query |
|
18 | + */ |
|
13 | 19 | private function filter($query) { |
14 | 20 | return $query; |
15 | 21 | } |
@@ -39,6 +45,9 @@ discard block |
||
39 | 45 | ); |
40 | 46 | } |
41 | 47 | |
48 | + /** |
|
49 | + * @return string |
|
50 | + */ |
|
42 | 51 | public function getBulkUpdateQuery($data, $parameters) { |
43 | 52 | $updateData = []; |
44 | 53 | foreach ($data as $field => $value) { |
@@ -84,6 +93,9 @@ discard block |
||
84 | 93 | ); |
85 | 94 | } |
86 | 95 | |
96 | + /** |
|
97 | + * @return string |
|
98 | + */ |
|
87 | 99 | public function getSelectQuery($parameters) { |
88 | 100 | return $this->filter(sprintf( |
89 | 101 | "SELECT %s FROM %s%s%s%s%s", |
@@ -97,6 +109,9 @@ discard block |
||
97 | 109 | ); |
98 | 110 | } |
99 | 111 | |
112 | + /** |
|
113 | + * @return string |
|
114 | + */ |
|
100 | 115 | public function getCountQuery($parameters) { |
101 | 116 | return $this->filter(sprintf( |
102 | 117 | "SELECT count(*) as count FROM %s%s", |
@@ -106,6 +121,9 @@ discard block |
||
106 | 121 | ); |
107 | 122 | } |
108 | 123 | |
124 | + /** |
|
125 | + * @return string |
|
126 | + */ |
|
109 | 127 | public function getDeleteQuery($parameters) { |
110 | 128 | return $this->filter(sprintf( |
111 | 129 | "DELETE FROM %s%s", |
@@ -34,8 +34,8 @@ discard block |
||
34 | 34 | } |
35 | 35 | |
36 | 36 | return $this->filter( |
37 | - "INSERT INTO " . $table . |
|
38 | - " (" . implode(", ", $quotedFields) . ") VALUES (" . implode(', ', $valueFields) . ")" |
|
37 | + "INSERT INTO ".$table. |
|
38 | + " (".implode(", ", $quotedFields).") VALUES (".implode(', ', $valueFields).")" |
|
39 | 39 | ); |
40 | 40 | } |
41 | 41 | |
@@ -77,10 +77,10 @@ discard block |
||
77 | 77 | } |
78 | 78 | } |
79 | 79 | |
80 | - return $this->filter("UPDATE " . |
|
81 | - $model->getDBStoreInformation()['quoted_table'] . |
|
82 | - " SET " . implode(', ', $valueFields) . |
|
83 | - " WHERE " . implode(' AND ', $conditions) |
|
80 | + return $this->filter("UPDATE ". |
|
81 | + $model->getDBStoreInformation()['quoted_table']. |
|
82 | + " SET ".implode(', ', $valueFields). |
|
83 | + " WHERE ".implode(' AND ', $conditions) |
|
84 | 84 | ); |
85 | 85 | } |
86 | 86 |
@@ -26,8 +26,8 @@ |
||
26 | 26 | |
27 | 27 | namespace ntentan\nibii; |
28 | 28 | |
29 | -use ntentan\utils\Text; |
|
30 | 29 | use ntentan\atiaa\Db; |
30 | +use ntentan\utils\Text; |
|
31 | 31 | |
32 | 32 | class QueryOperations { |
33 | 33 |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | |
24 | 24 | /** |
25 | 25 | * |
26 | - * @param \ $model |
|
26 | + * @param string $table |
|
27 | 27 | */ |
28 | 28 | public function __construct($table) { |
29 | 29 | $this->db = DriverAdapter::getDefaultInstance(); |
@@ -106,6 +106,9 @@ discard block |
||
106 | 106 | $this->boundData += $values; |
107 | 107 | } |
108 | 108 | |
109 | + /** |
|
110 | + * @param boolean $firstOnly |
|
111 | + */ |
|
109 | 112 | public function setFirstOnly($firstOnly) { |
110 | 113 | $this->firstOnly = $firstOnly; |
111 | 114 | return $this; |
@@ -123,6 +126,9 @@ discard block |
||
123 | 126 | $this->offset = $offset; |
124 | 127 | } |
125 | 128 | |
129 | + /** |
|
130 | + * @param string $field |
|
131 | + */ |
|
126 | 132 | public function addSort($field, $direction = 'ASC') { |
127 | 133 | $this->sorts[] = "$field $direction"; |
128 | 134 | } |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | } |
71 | 71 | |
72 | 72 | public function getSorts() { |
73 | - return count($this->sorts) ? " ORDER BY " . implode(", ", $this->sorts) : null; |
|
73 | + return count($this->sorts) ? " ORDER BY ".implode(", ", $this->sorts) : null; |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | public function addFilter($field, $values = []) { |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | $this->whereClause .= "{$field} IN ("; |
91 | 91 | $comma = ''; |
92 | 92 | for ($i = 0; $i < $numValues; $i++) { |
93 | - $key = "filter_" . ($startIndex + $i); |
|
93 | + $key = "filter_".($startIndex + $i); |
|
94 | 94 | $this->whereClause .= "$comma:$key"; |
95 | 95 | $this->boundData[$key] = $values[$i]; |
96 | 96 | $comma = ' ,'; |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | |
123 | 123 | /** |
124 | 124 | * @method |
125 | - * @param type $name |
|
125 | + * @param string $name |
|
126 | 126 | * @param type $arguments |
127 | 127 | * @return type |
128 | 128 | */ |
@@ -148,6 +148,10 @@ discard block |
||
148 | 148 | return $this->retrieveItem($name); |
149 | 149 | } |
150 | 150 | |
151 | + /** |
|
152 | + * @param Relationship[] $relationships |
|
153 | + * @param integer $depth |
|
154 | + */ |
|
151 | 155 | private function expandArrayValue($array, $relationships, $depth, $index = null) { |
152 | 156 | foreach ($relationships as $name => $relationship) { |
153 | 157 | $array[$name] = $this->fetchRelatedFields($relationship, $index)->toArray($depth); |
@@ -26,11 +26,10 @@ |
||
26 | 26 | |
27 | 27 | namespace ntentan\nibii; |
28 | 28 | |
29 | -use ntentan\utils\Utils; |
|
29 | +use ntentan\atiaa\Db; |
|
30 | 30 | use ntentan\kaikai\Cache; |
31 | 31 | use ntentan\panie\InjectionContainer; |
32 | 32 | use ntentan\utils\Text; |
33 | -use ntentan\atiaa\Db; |
|
34 | 33 | |
35 | 34 | /** |
36 | 35 | * |
@@ -57,12 +57,12 @@ discard block |
||
57 | 57 | public function __construct(DriverAdapter $adapter) { |
58 | 58 | $table = Nibii::getModelTable($this); |
59 | 59 | $driver = Db::getDriver(); |
60 | - if(is_string($table)) { |
|
60 | + if (is_string($table)) { |
|
61 | 61 | $this->quotedTable = $driver->quoteIdentifier($table); |
62 | 62 | $this->table = $this->unquotedTable = $table; |
63 | 63 | } else { |
64 | - $this->quotedTable = (isset($table['schema']) ? "{$driver->quoteIdentifier($table["schema"])}." : ""). $driver->quoteIdentifier($table["table"]); |
|
65 | - $this->unquotedTable = (isset($table['schema']) ? "{$table['schema']}." : "") . $table['table']; |
|
64 | + $this->quotedTable = (isset($table['schema']) ? "{$driver->quoteIdentifier($table["schema"])}." : "").$driver->quoteIdentifier($table["table"]); |
|
65 | + $this->unquotedTable = (isset($table['schema']) ? "{$table['schema']}." : "").$table['table']; |
|
66 | 66 | $this->table = $table['table']; |
67 | 67 | $this->schema = $table['schema']; |
68 | 68 | } |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | */ |
81 | 81 | public function getDescription() { |
82 | 82 | return Cache::read( |
83 | - (new \ReflectionClass($this))->getName() . '::desc', function() { |
|
83 | + (new \ReflectionClass($this))->getName().'::desc', function() { |
|
84 | 84 | return new ModelDescription($this); |
85 | 85 | } |
86 | 86 | ); |