@@ -3,22 +3,22 @@ |
||
3 | 3 | /** |
4 | 4 | * Data Model implementation for this class |
5 | 5 | * |
6 | - * <?=$this->config->last_modify."\n"?> |
|
6 | + * <?=$this->config->last_modify . "\n"?> |
|
7 | 7 | * |
8 | - * @see <?=$objTables->getNamespace()?>\<?=$this->getClassName ( $objTables->getName () ). "\n"?> |
|
8 | + * @see <?=$objTables->getNamespace()?>\<?=$this->getClassName($objTables->getName()) . "\n"?> |
|
9 | 9 | * |
10 | - * @author <?=$this->config->author."\n"?> |
|
10 | + * @author <?=$this->config->author . "\n"?> |
|
11 | 11 | * |
12 | - * @copyright <?=$this->config->copyright."\n"?> |
|
13 | - * @license <?=$this->config->license."\n"?> |
|
14 | - * @link <?=$this->config->link."\n"?> |
|
15 | - * @version <?=$this->config->version."\n"?> |
|
12 | + * @copyright <?=$this->config->copyright . "\n"?> |
|
13 | + * @license <?=$this->config->license . "\n"?> |
|
14 | + * @link <?=$this->config->link . "\n"?> |
|
15 | + * @version <?=$this->config->version . "\n"?> |
|
16 | 16 | */ |
17 | 17 | |
18 | 18 | |
19 | 19 | namespace <?=$objTables->getNamespace()?>; |
20 | 20 | |
21 | -class <?=$this->getClassName ( $objTables->getName () )?> extends \<?=$objTables->getNamespace()?>\Entity\<?=$this->getClassName ( $objTables->getName () ). "\n"?> |
|
21 | +class <?=$this->getClassName($objTables->getName())?> extends \<?=$objTables->getNamespace()?>\Entity\<?=$this->getClassName($objTables->getName()) . "\n"?> |
|
22 | 22 | { |
23 | 23 | /* @TODO Codifique aqui */ |
24 | 24 | } |
@@ -3,18 +3,18 @@ discard block |
||
3 | 3 | /** |
4 | 4 | * Application Model DbTables |
5 | 5 | * |
6 | - * <?=$this->config->last_modify."\n"?> |
|
6 | + * <?=$this->config->last_modify . "\n"?> |
|
7 | 7 | * |
8 | 8 | * Classe Abstract pai de todas as tabelas |
9 | 9 | * |
10 | 10 | * @package <?=$this->config->namespace?>Model |
11 | 11 | * @subpackage DbTable |
12 | - * @author <?=$this->config->author."\n"?> |
|
12 | + * @author <?=$this->config->author . "\n"?> |
|
13 | 13 | * |
14 | - * @copyright <?=$this->config->copyright."\n"?> |
|
15 | - * @license <?=$this->config->license."\n"?> |
|
16 | - * @link <?=$this->config->link."\n"?> |
|
17 | - * @version <?=$this->config->version."\n"?> |
|
14 | + * @copyright <?=$this->config->copyright . "\n"?> |
|
15 | + * @license <?=$this->config->license . "\n"?> |
|
16 | + * @link <?=$this->config->link . "\n"?> |
|
17 | + * @version <?=$this->config->version . "\n"?> |
|
18 | 18 | * |
19 | 19 | * @abstract |
20 | 20 | */ |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * Zend DB Table Abstract class |
24 | 24 | */ |
25 | 25 | |
26 | -abstract class <?=$this->config->namespace?$this->config->namespace."_":""?>Model_TableAbstract extends Zend_Db_Table_Abstract |
|
26 | +abstract class <?=$this->config->namespace ? $this->config->namespace . "_" : ""?>Model_TableAbstract extends Zend_Db_Table_Abstract |
|
27 | 27 | { |
28 | 28 | /** |
29 | 29 | * Nome da tabela do banco de dados |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | /** |
151 | 151 | * @param AbstractAdapter $type |
152 | 152 | * |
153 | - * @return mixed |
|
153 | + * @return string |
|
154 | 154 | */ |
155 | 155 | public function getTypeByConfig ( AbstractAdapter $type ) |
156 | 156 | { |
@@ -199,6 +199,7 @@ discard block |
||
199 | 199 | * @param $constraint_name |
200 | 200 | * @param $table_name |
201 | 201 | * @param $column_name |
202 | + * @param string $database |
|
202 | 203 | * |
203 | 204 | * @return $this |
204 | 205 | */ |
@@ -205,15 +205,15 @@ |
||
205 | 205 | public function createDependece ( $constraint_name, $table_name, $column_name, $database, $schema = null ) |
206 | 206 | { |
207 | 207 | $objConstrantDependence = Constrant::getInstance () |
208 | - ->populate ( |
|
209 | - array ( |
|
210 | - 'constrant' => $constraint_name, |
|
211 | - 'schema' => $schema, |
|
212 | - 'table' => $table_name, |
|
213 | - 'column' => $column_name, |
|
214 | - 'database' => $database |
|
215 | - ) |
|
216 | - ); |
|
208 | + ->populate ( |
|
209 | + array ( |
|
210 | + 'constrant' => $constraint_name, |
|
211 | + 'schema' => $schema, |
|
212 | + 'table' => $table_name, |
|
213 | + 'column' => $column_name, |
|
214 | + 'database' => $database |
|
215 | + ) |
|
216 | + ); |
|
217 | 217 | |
218 | 218 | $this->addDependece ( $objConstrantDependence ); |
219 | 219 |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * |
23 | 23 | * @author Pedro Alarcao <[email protected]> |
24 | 24 | */ |
25 | - final private function __construct () |
|
25 | + final private function __construct() |
|
26 | 26 | { |
27 | 27 | } |
28 | 28 | |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * |
32 | 32 | * @return \Classes\Db\Column |
33 | 33 | */ |
34 | - public static function getInstance () |
|
34 | + public static function getInstance() |
|
35 | 35 | { |
36 | 36 | return new Column(); |
37 | 37 | } |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | /** |
90 | 90 | * @return string |
91 | 91 | */ |
92 | - public function getName () |
|
92 | + public function getName() |
|
93 | 93 | { |
94 | 94 | return $this->name; |
95 | 95 | } |
@@ -99,13 +99,13 @@ discard block |
||
99 | 99 | * |
100 | 100 | * @param $array |
101 | 101 | */ |
102 | - public function populate ( $array ) |
|
102 | + public function populate($array) |
|
103 | 103 | { |
104 | - $this->name = $array[ 'name' ]; |
|
105 | - $this->type = $array[ 'type' ]; |
|
106 | - $this->nullable = $array[ 'nullable' ]; |
|
107 | - $this->max_length = $array[ 'max_length' ]; |
|
108 | - $this->column_default = $array[ 'column_default' ]; |
|
104 | + $this->name = $array['name']; |
|
105 | + $this->type = $array['type']; |
|
106 | + $this->nullable = $array['nullable']; |
|
107 | + $this->max_length = $array['max_length']; |
|
108 | + $this->column_default = $array['column_default']; |
|
109 | 109 | |
110 | 110 | return $this; |
111 | 111 | } |
@@ -113,54 +113,54 @@ discard block |
||
113 | 113 | /** |
114 | 114 | * @return boolean |
115 | 115 | */ |
116 | - public function isPrimaryKey () |
|
116 | + public function isPrimaryKey() |
|
117 | 117 | { |
118 | - return !empty( $this->primarykey ); |
|
118 | + return ! empty($this->primarykey); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | /** |
122 | 122 | * @return boolean |
123 | 123 | */ |
124 | - public function isForeingkey () |
|
124 | + public function isForeingkey() |
|
125 | 125 | { |
126 | - return !empty( $this->refForeingkey ); |
|
126 | + return ! empty($this->refForeingkey); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | /** |
130 | 130 | * @return boolean |
131 | 131 | */ |
132 | - public function hasDependence () |
|
132 | + public function hasDependence() |
|
133 | 133 | { |
134 | - return !empty( $this->dependences ); |
|
134 | + return ! empty($this->dependences); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
138 | 138 | * @return boolean |
139 | 139 | */ |
140 | - public function hasColumnDefault () |
|
140 | + public function hasColumnDefault() |
|
141 | 141 | { |
142 | - return !empty( $this->column_default ); |
|
142 | + return ! empty($this->column_default); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | /** |
146 | 146 | * @return string |
147 | 147 | */ |
148 | - public function getColumnDefault () |
|
148 | + public function getColumnDefault() |
|
149 | 149 | { |
150 | - return $this->column_default ; |
|
150 | + return $this->column_default; |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | /** |
154 | 154 | * @return string |
155 | 155 | */ |
156 | - public function getType ( $type = self::TypeDefault ) |
|
156 | + public function getType($type = self::TypeDefault) |
|
157 | 157 | { |
158 | - switch ( $type ) |
|
158 | + switch ($type) |
|
159 | 159 | { |
160 | 160 | case self::TypePHP: |
161 | - return AbstractAdapter::convertTypeToPHP ( $this->type ); |
|
161 | + return AbstractAdapter::convertTypeToPHP($this->type); |
|
162 | 162 | case self::TypeDefault: |
163 | - return AbstractAdapter::convertTypeToDefault ( $this->type ); |
|
163 | + return AbstractAdapter::convertTypeToDefault($this->type); |
|
164 | 164 | case self::TypeNone: |
165 | 165 | return $this->type; |
166 | 166 | } |
@@ -172,9 +172,9 @@ discard block |
||
172 | 172 | * |
173 | 173 | * @return bool |
174 | 174 | */ |
175 | - public function equalType ( $type, $inPHP = true ) |
|
175 | + public function equalType($type, $inPHP = true) |
|
176 | 176 | { |
177 | - return $this->getType ( $inPHP ) === $type; |
|
177 | + return $this->getType($inPHP) === $type; |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | /** |
@@ -182,15 +182,15 @@ discard block |
||
182 | 182 | * |
183 | 183 | * @return mixed |
184 | 184 | */ |
185 | - public function getTypeByConfig ( AbstractAdapter $type ) |
|
185 | + public function getTypeByConfig(AbstractAdapter $type) |
|
186 | 186 | { |
187 | - return $type->convertTypeToTypeFramework ( $this->getType ( false ) ); |
|
187 | + return $type->convertTypeToTypeFramework($this->getType(false)); |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | /** |
191 | 191 | * @return string |
192 | 192 | */ |
193 | - public function getComment () |
|
193 | + public function getComment() |
|
194 | 194 | { |
195 | 195 | return $this->comment; |
196 | 196 | } |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | /** |
199 | 199 | * @param string $comment |
200 | 200 | */ |
201 | - public function setComment ( $comment ) |
|
201 | + public function setComment($comment) |
|
202 | 202 | { |
203 | 203 | $this->comment = $comment; |
204 | 204 | |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | /** |
209 | 209 | * @param \Classes\Db\Constrant $primarykey |
210 | 210 | */ |
211 | - public function setPrimaryKey ( Constrant $primarykey ) |
|
211 | + public function setPrimaryKey(Constrant $primarykey) |
|
212 | 212 | { |
213 | 213 | $this->primarykey = $primarykey; |
214 | 214 | |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | /** |
219 | 219 | * @param \Classes\Db\Constrant $dependece |
220 | 220 | */ |
221 | - public function addDependece ( Constrant $dependece ) |
|
221 | + public function addDependece(Constrant $dependece) |
|
222 | 222 | { |
223 | 223 | $this->dependences[] = $dependece; |
224 | 224 | |
@@ -232,11 +232,11 @@ discard block |
||
232 | 232 | * |
233 | 233 | * @return $this |
234 | 234 | */ |
235 | - public function createDependece ( $constraint_name, $table_name, $column_name, $database, $schema = null ) |
|
235 | + public function createDependece($constraint_name, $table_name, $column_name, $database, $schema = null) |
|
236 | 236 | { |
237 | - $objConstrantDependence = Constrant::getInstance () |
|
238 | - ->populate ( |
|
239 | - array ( |
|
237 | + $objConstrantDependence = Constrant::getInstance() |
|
238 | + ->populate( |
|
239 | + array( |
|
240 | 240 | 'constrant' => $constraint_name, |
241 | 241 | 'schema' => $schema, |
242 | 242 | 'table' => $table_name, |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | ) |
246 | 246 | ); |
247 | 247 | |
248 | - $this->addDependece ( $objConstrantDependence ); |
|
248 | + $this->addDependece($objConstrantDependence); |
|
249 | 249 | |
250 | 250 | return $this; |
251 | 251 | } |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | /** |
254 | 254 | * @param \Classes\Db\Constrant $reference |
255 | 255 | */ |
256 | - public function addRefFk ( Constrant $reference ) |
|
256 | + public function addRefFk(Constrant $reference) |
|
257 | 257 | { |
258 | 258 | $this->refForeingkey = $reference; |
259 | 259 | |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | * |
266 | 266 | * @return \Classes\Db\Constrant |
267 | 267 | */ |
268 | - public function getFks () |
|
268 | + public function getFks() |
|
269 | 269 | { |
270 | 270 | return $this->refForeingkey; |
271 | 271 | } |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | * |
276 | 276 | * @return \Classes\Db\Constrant[] |
277 | 277 | */ |
278 | - public function getDependences () |
|
278 | + public function getDependences() |
|
279 | 279 | { |
280 | 280 | return $this->dependences; |
281 | 281 | } |
@@ -283,9 +283,9 @@ discard block |
||
283 | 283 | /** |
284 | 284 | * @return bool |
285 | 285 | */ |
286 | - public function hasDependences () |
|
286 | + public function hasDependences() |
|
287 | 287 | { |
288 | - return (bool) count ( $this->dependences ); |
|
288 | + return (bool) count($this->dependences); |
|
289 | 289 | } |
290 | 290 | |
291 | 291 | /** |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | * |
294 | 294 | * @return \Classes\Db\Constrant[] |
295 | 295 | */ |
296 | - public function getPrimaryKey () |
|
296 | + public function getPrimaryKey() |
|
297 | 297 | { |
298 | 298 | return $this->primarykey; |
299 | 299 | } |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | /** |
302 | 302 | * |
303 | 303 | */ |
304 | - public function getMaxLength () |
|
304 | + public function getMaxLength() |
|
305 | 305 | { |
306 | 306 | return $this->max_length; |
307 | 307 | } |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | /** |
310 | 310 | * @return bool |
311 | 311 | */ |
312 | - public function hasSequence () |
|
312 | + public function hasSequence() |
|
313 | 313 | { |
314 | 314 | return (bool) $this->sequence; |
315 | 315 | } |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | /** |
318 | 318 | * @return string |
319 | 319 | */ |
320 | - public function getSequence () |
|
320 | + public function getSequence() |
|
321 | 321 | { |
322 | 322 | return $this->sequence; |
323 | 323 | } |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | /** |
326 | 326 | * @param string $sequence |
327 | 327 | */ |
328 | - public function setSequence ( $sequence ) |
|
328 | + public function setSequence($sequence) |
|
329 | 329 | { |
330 | 330 | $this->sequence = $sequence; |
331 | 331 | } |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | /** |
334 | 334 | * @return boolean |
335 | 335 | */ |
336 | - public function isNullable () |
|
336 | + public function isNullable() |
|
337 | 337 | { |
338 | 338 | return $this->nullable; |
339 | 339 | } |
@@ -35,26 +35,19 @@ |
||
35 | 35 | $res = ''; |
36 | 36 | if ( preg_match ( '/(tinyint\(1\)|bit)/', $str ) ) { |
37 | 37 | $res = 'boolean'; |
38 | - } |
|
39 | - elseif ( preg_match ( '/(timestamp|blob|char|enum)/', $str ) ) { |
|
38 | + } elseif ( preg_match ( '/(timestamp|blob|char|enum)/', $str ) ) { |
|
40 | 39 | $res = 'string'; |
41 | - } |
|
42 | - elseif ( preg_match ( '/(text)/', $str ) ) { |
|
40 | + } elseif ( preg_match ( '/(text)/', $str ) ) { |
|
43 | 41 | $res = 'text'; |
44 | - } |
|
45 | - elseif ( preg_match ( '/(decimal|numeric|float|double)/', $str ) ) { |
|
42 | + } elseif ( preg_match ( '/(decimal|numeric|float|double)/', $str ) ) { |
|
46 | 43 | $res = 'float'; |
47 | - } |
|
48 | - elseif ( preg_match ( '#^(?:tiny|small|medium|long|big|var)?(\w+)(?:\(\d+\))?(?:\s\w+)*$#', $str, $matches ) ) { |
|
44 | + } elseif ( preg_match ( '#^(?:tiny|small|medium|long|big|var)?(\w+)(?:\(\d+\))?(?:\s\w+)*$#', $str, $matches ) ) { |
|
49 | 45 | $res = $matches[ 1 ]; |
50 | - } |
|
51 | - elseif ( preg_match ( '/(date)/', $str ) ) { |
|
46 | + } elseif ( preg_match ( '/(date)/', $str ) ) { |
|
52 | 47 | $res = 'date'; |
53 | - } |
|
54 | - elseif ( preg_match ( '/(datetime)/', $str ) ) { |
|
48 | + } elseif ( preg_match ( '/(datetime)/', $str ) ) { |
|
55 | 49 | $res = 'datetime'; |
56 | - } |
|
57 | - else { |
|
50 | + } else { |
|
58 | 51 | print "Can't convert column type to Simple - Unrecognized type: $str"; |
59 | 52 | } |
60 | 53 |
@@ -174,10 +174,10 @@ discard block |
||
174 | 174 | $sqlTables = !empty($this->tablesName)?"AND table_name IN ( $this->tablesName )":''; |
175 | 175 | |
176 | 176 | $this->totalTables = $this->getPDO () |
177 | - ->query ( |
|
178 | - "SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = '{$this->database}' $sqlTables" |
|
179 | - ) |
|
180 | - ->fetchColumn (); |
|
177 | + ->query ( |
|
178 | + "SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = '{$this->database}' $sqlTables" |
|
179 | + ) |
|
180 | + ->fetchColumn (); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | return (int) $this->totalTables; |
@@ -194,10 +194,10 @@ discard block |
||
194 | 194 | public function getSequence ( $table, $column, $schema = 0 ) |
195 | 195 | { |
196 | 196 | $return = $this->getPDO () |
197 | - ->query ( |
|
198 | - "select * from information_schema.columns where extra like '%auto_increment%' and TABLE_SCHEMA='{$this->database}' AND TABLE_NAME='{$table}' AND COLUMN_NAME='{$column}';" |
|
199 | - ) |
|
200 | - ->fetch ( \PDO::FETCH_ASSOC ); |
|
197 | + ->query ( |
|
198 | + "select * from information_schema.columns where extra like '%auto_increment%' and TABLE_SCHEMA='{$this->database}' AND TABLE_NAME='{$table}' AND COLUMN_NAME='{$column}';" |
|
199 | + ) |
|
200 | + ->fetch ( \PDO::FETCH_ASSOC ); |
|
201 | 201 | |
202 | 202 | if ( !$return ) { |
203 | 203 | return; |
@@ -30,28 +30,28 @@ discard block |
||
30 | 30 | * |
31 | 31 | * @return string |
32 | 32 | */ |
33 | - protected function convertTypeToSimple ( $str ) |
|
33 | + protected function convertTypeToSimple($str) |
|
34 | 34 | { |
35 | 35 | $res = ''; |
36 | - if ( preg_match ( '/(tinyint\(1\)|bit)/', $str ) ) { |
|
36 | + if (preg_match('/(tinyint\(1\)|bit)/', $str)) { |
|
37 | 37 | $res = 'boolean'; |
38 | 38 | } |
39 | - elseif ( preg_match ( '/(timestamp|blob|char|enum)/', $str ) ) { |
|
39 | + elseif (preg_match('/(timestamp|blob|char|enum)/', $str)) { |
|
40 | 40 | $res = 'string'; |
41 | 41 | } |
42 | - elseif ( preg_match ( '/(text)/', $str ) ) { |
|
42 | + elseif (preg_match('/(text)/', $str)) { |
|
43 | 43 | $res = 'text'; |
44 | 44 | } |
45 | - elseif ( preg_match ( '/(decimal|numeric|float|double)/', $str ) ) { |
|
45 | + elseif (preg_match('/(decimal|numeric|float|double)/', $str)) { |
|
46 | 46 | $res = 'float'; |
47 | 47 | } |
48 | - elseif ( preg_match ( '#^(?:tiny|small|medium|long|big|var)?(\w+)(?:\(\d+\))?(?:\s\w+)*$#', $str, $matches ) ) { |
|
49 | - $res = $matches[ 1 ]; |
|
48 | + elseif (preg_match('#^(?:tiny|small|medium|long|big|var)?(\w+)(?:\(\d+\))?(?:\s\w+)*$#', $str, $matches)) { |
|
49 | + $res = $matches[1]; |
|
50 | 50 | } |
51 | - elseif ( preg_match ( '/(date)/', $str ) ) { |
|
51 | + elseif (preg_match('/(date)/', $str)) { |
|
52 | 52 | $res = 'date'; |
53 | 53 | } |
54 | - elseif ( preg_match ( '/(datetime)/', $str ) ) { |
|
54 | + elseif (preg_match('/(datetime)/', $str)) { |
|
55 | 55 | $res = 'datetime'; |
56 | 56 | } |
57 | 57 | else { |
@@ -65,9 +65,9 @@ discard block |
||
65 | 65 | * @inheritDoc |
66 | 66 | * @return string |
67 | 67 | */ |
68 | - public function getPDOString () |
|
68 | + public function getPDOString() |
|
69 | 69 | { |
70 | - return sprintf ( |
|
70 | + return sprintf( |
|
71 | 71 | "mysql:host=%s;port=%s;dbname=%s", |
72 | 72 | $this->host, |
73 | 73 | $this->port, |
@@ -80,9 +80,9 @@ discard block |
||
80 | 80 | * @inheritDoc |
81 | 81 | * @return string |
82 | 82 | */ |
83 | - public function getPDOSocketString () |
|
83 | + public function getPDOSocketString() |
|
84 | 84 | { |
85 | - return sprintf ( |
|
85 | + return sprintf( |
|
86 | 86 | "mysql:unix_socket=%s;dbname=%s", |
87 | 87 | $this->socket, |
88 | 88 | $this->database |
@@ -94,14 +94,14 @@ discard block |
||
94 | 94 | * @inheritDoc |
95 | 95 | * @return string[] |
96 | 96 | */ |
97 | - public function getListNameTable () |
|
97 | + public function getListNameTable() |
|
98 | 98 | { |
99 | - if ( empty( $this->tableList ) ) { |
|
100 | - $this->tableList = $this->getPDO () |
|
101 | - ->query ( |
|
99 | + if (empty($this->tableList)) { |
|
100 | + $this->tableList = $this->getPDO() |
|
101 | + ->query( |
|
102 | 102 | "show tables" |
103 | 103 | ) |
104 | - ->fetchAll (); |
|
104 | + ->fetchAll(); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | return $this->tableList; |
@@ -112,12 +112,12 @@ discard block |
||
112 | 112 | * |
113 | 113 | * @return array[] |
114 | 114 | */ |
115 | - public function getListColumns () |
|
115 | + public function getListColumns() |
|
116 | 116 | { |
117 | - $sqlTables = !empty($this->tablesName)?"AND table_name IN ( $this->tablesName )":''; |
|
117 | + $sqlTables = ! empty($this->tablesName) ? "AND table_name IN ( $this->tablesName )" : ''; |
|
118 | 118 | |
119 | - return $this->getPDO () |
|
120 | - ->query ( |
|
119 | + return $this->getPDO() |
|
120 | + ->query( |
|
121 | 121 | "select |
122 | 122 | 0 AS table_schema, |
123 | 123 | table_name, |
@@ -129,18 +129,18 @@ discard block |
||
129 | 129 | where table_schema IN ('{$this->database}') $sqlTables |
130 | 130 | order by table_name,ordinal_position" |
131 | 131 | ) |
132 | - ->fetchAll ( \PDO::FETCH_ASSOC ); |
|
132 | + ->fetchAll(\PDO::FETCH_ASSOC); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
136 | 136 | * @return array |
137 | 137 | */ |
138 | - public function getListConstrant () |
|
138 | + public function getListConstrant() |
|
139 | 139 | { |
140 | - $sqlTables = !empty($this->tablesName)?"AND k.table_name IN ( $this->tablesName )":''; |
|
140 | + $sqlTables = ! empty($this->tablesName) ? "AND k.table_name IN ( $this->tablesName )" : ''; |
|
141 | 141 | |
142 | - $objQuery = $this->getPDO () |
|
143 | - ->query ( |
|
142 | + $objQuery = $this->getPDO() |
|
143 | + ->query( |
|
144 | 144 | "SELECT distinct |
145 | 145 | i.constraint_type, |
146 | 146 | k.constraint_name, |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | i.TABLE_SCHEMA IN ('{$this->database}') AND i.CONSTRAINT_TYPE IN ('FOREIGN KEY', 'PRIMARY KEY' ) $sqlTables |
160 | 160 | order by k.table_name;" |
161 | 161 | ); |
162 | - return $objQuery?$objQuery->fetchAll ( \PDO::FETCH_ASSOC ):array(); |
|
162 | + return $objQuery ? $objQuery->fetchAll(\PDO::FETCH_ASSOC) : array(); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
@@ -167,17 +167,17 @@ discard block |
||
167 | 167 | * |
168 | 168 | * @return int |
169 | 169 | */ |
170 | - public function getTotalTables () |
|
170 | + public function getTotalTables() |
|
171 | 171 | { |
172 | - if ( empty( $this->totalTables ) ) { |
|
172 | + if (empty($this->totalTables)) { |
|
173 | 173 | |
174 | - $sqlTables = !empty($this->tablesName)?"AND table_name IN ( $this->tablesName )":''; |
|
174 | + $sqlTables = ! empty($this->tablesName) ? "AND table_name IN ( $this->tablesName )" : ''; |
|
175 | 175 | |
176 | - $this->totalTables = $this->getPDO () |
|
177 | - ->query ( |
|
176 | + $this->totalTables = $this->getPDO() |
|
177 | + ->query( |
|
178 | 178 | "SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = '{$this->database}' $sqlTables" |
179 | 179 | ) |
180 | - ->fetchColumn (); |
|
180 | + ->fetchColumn(); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | return (int) $this->totalTables; |
@@ -191,15 +191,15 @@ discard block |
||
191 | 191 | * |
192 | 192 | * @return string |
193 | 193 | */ |
194 | - public function getSequence ( $table, $column, $schema = 0 ) |
|
194 | + public function getSequence($table, $column, $schema = 0) |
|
195 | 195 | { |
196 | - $return = $this->getPDO () |
|
197 | - ->query ( |
|
196 | + $return = $this->getPDO() |
|
197 | + ->query( |
|
198 | 198 | "select * from information_schema.columns where extra like '%auto_increment%' and TABLE_SCHEMA='{$this->database}' AND TABLE_NAME='{$table}' AND COLUMN_NAME='{$column}';" |
199 | 199 | ) |
200 | - ->fetch ( \PDO::FETCH_ASSOC ); |
|
200 | + ->fetch(\PDO::FETCH_ASSOC); |
|
201 | 201 | |
202 | - if ( !$return ) { |
|
202 | + if ( ! $return) { |
|
203 | 203 | return; |
204 | 204 | } |
205 | 205 |
@@ -22,16 +22,16 @@ discard block |
||
22 | 22 | * @var string |
23 | 23 | */ |
24 | 24 | protected $framework = "phalcon"; |
25 | - public $reservedWord = array ( 'public' => 'Main' ); |
|
25 | + public $reservedWord = array('public' => 'Main'); |
|
26 | 26 | |
27 | - protected $dataTypes = array ( |
|
27 | + protected $dataTypes = array( |
|
28 | 28 | 'int' => 'integer', |
29 | 29 | 'float' => 'decimal' |
30 | 30 | ); |
31 | 31 | |
32 | 32 | const SEPARETOR = "\\"; |
33 | 33 | |
34 | - protected function init () |
|
34 | + protected function init() |
|
35 | 35 | { |
36 | 36 | } |
37 | 37 | |
@@ -40,12 +40,12 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @return array |
42 | 42 | */ |
43 | - protected function getParams () |
|
43 | + protected function getParams() |
|
44 | 44 | { |
45 | 45 | |
46 | 46 | } |
47 | 47 | |
48 | - protected function parseFrameworkConfig () |
|
48 | + protected function parseFrameworkConfig() |
|
49 | 49 | { |
50 | 50 | // TODO: Implement parseFrameworkConfig() method. |
51 | 51 | } |
@@ -53,10 +53,10 @@ discard block |
||
53 | 53 | /** |
54 | 54 | * @inheritdoc |
55 | 55 | */ |
56 | - protected function getBaseNamespace () |
|
56 | + protected function getBaseNamespace() |
|
57 | 57 | { |
58 | - return array ( |
|
59 | - $this->arrConfig[ 'namespace' ], |
|
58 | + return array( |
|
59 | + $this->arrConfig['namespace'], |
|
60 | 60 | 'Models' |
61 | 61 | ); |
62 | 62 | } |
@@ -66,12 +66,12 @@ discard block |
||
66 | 66 | * |
67 | 67 | * @return \Classes\AdapterMakerFile\AbstractAdapter[] |
68 | 68 | */ |
69 | - public function getMakeFileInstances () |
|
69 | + public function getMakeFileInstances() |
|
70 | 70 | { |
71 | - return array ( |
|
72 | - Entity::getInstance (), |
|
73 | - Model::getInstance (), |
|
74 | - Peer::getInstance () |
|
71 | + return array( |
|
72 | + Entity::getInstance(), |
|
73 | + Model::getInstance(), |
|
74 | + Peer::getInstance() |
|
75 | 75 | ); |
76 | 76 | } |
77 | 77 |
@@ -3,20 +3,20 @@ |
||
3 | 3 | /** |
4 | 4 | * Data Entity implementation for this class |
5 | 5 | * |
6 | - * <?=$this->config->last_modify."\n"?> |
|
6 | + * <?=$this->config->last_modify . "\n"?> |
|
7 | 7 | * |
8 | - * @package <?=$objTables->getNamespace()."\n"?> |
|
9 | - * @see <?=$objTables->getNamespace()?>_Entity_<?=\Classes\Maker\AbstractMaker::getClassName ( $objTables->getName () )?>. <?="\n"?> |
|
8 | + * @package <?=$objTables->getNamespace() . "\n"?> |
|
9 | + * @see <?=$objTables->getNamespace()?>_Entity_<?=\Classes\Maker\AbstractMaker::getClassName($objTables->getName())?>. <?="\n"?> |
|
10 | 10 | * |
11 | - * @author <?=$this->config->author."\n"?> |
|
11 | + * @author <?=$this->config->author . "\n"?> |
|
12 | 12 | * |
13 | - * @copyright <?=$this->config->copyright."\n"?> |
|
14 | - * @license <?=$this->config->license."\n"?> |
|
15 | - * @link <?=$this->config->link."\n"?> |
|
16 | - * @version <?=$this->config->version."\n"?> |
|
13 | + * @copyright <?=$this->config->copyright . "\n"?> |
|
14 | + * @license <?=$this->config->license . "\n"?> |
|
15 | + * @link <?=$this->config->link . "\n"?> |
|
16 | + * @version <?=$this->config->version . "\n"?> |
|
17 | 17 | */ |
18 | 18 | |
19 | -class <?=$objTables->getNamespace()?>_<?=\Classes\Maker\AbstractMaker::getClassName ( $objTables->getName () )?> extends <?=$objTables->getNamespace()?>_Entity_<?=\Classes\Maker\AbstractMaker::getClassName ( $objTables->getName () ). "\n"?> |
|
19 | +class <?=$objTables->getNamespace()?>_<?=\Classes\Maker\AbstractMaker::getClassName($objTables->getName())?> extends <?=$objTables->getNamespace()?>_Entity_<?=\Classes\Maker\AbstractMaker::getClassName($objTables->getName()) . "\n"?> |
|
20 | 20 | { |
21 | 21 | /* @TODO Codifique aqui */ |
22 | 22 | } |
@@ -34,6 +34,9 @@ |
||
34 | 34 | return self::$instance; |
35 | 35 | } |
36 | 36 | |
37 | + /** |
|
38 | + * @param string $directory |
|
39 | + */ |
|
37 | 40 | private function scanDir ( $directory ) |
38 | 41 | { |
39 | 42 | if(!is_dir($directory)){ |
@@ -17,16 +17,16 @@ discard block |
||
17 | 17 | /** |
18 | 18 | * @type int |
19 | 19 | */ |
20 | - private $countFileDeleted=0; |
|
20 | + private $countFileDeleted = 0; |
|
21 | 21 | |
22 | - final private function __construct (){ } |
|
22 | + final private function __construct() { } |
|
23 | 23 | |
24 | 24 | /** |
25 | 25 | * @return \Classes\CleanTrash |
26 | 26 | */ |
27 | - public static function getInstance () |
|
27 | + public static function getInstance() |
|
28 | 28 | { |
29 | - if ( self::$instance === null ) |
|
29 | + if (self::$instance === null) |
|
30 | 30 | { |
31 | 31 | self::$instance = new self(); |
32 | 32 | } |
@@ -34,20 +34,20 @@ discard block |
||
34 | 34 | return self::$instance; |
35 | 35 | } |
36 | 36 | |
37 | - private function scanDir ( $directory ) |
|
37 | + private function scanDir($directory) |
|
38 | 38 | { |
39 | - if(!is_dir($directory)){ |
|
39 | + if ( ! is_dir($directory)) { |
|
40 | 40 | return array(); |
41 | 41 | } |
42 | 42 | |
43 | - $diretories = preg_grep ( '*\.ph*' , scandir ( $directory ) ); |
|
44 | - if(!$diretories){ |
|
43 | + $diretories = preg_grep('*\.ph*', scandir($directory)); |
|
44 | + if ( ! $diretories) { |
|
45 | 45 | return array(); |
46 | 46 | } |
47 | 47 | |
48 | - return array_diff ( $diretories, array ( |
|
49 | - '..' , '.' |
|
50 | - ) ); |
|
48 | + return array_diff($diretories, array( |
|
49 | + '..', '.' |
|
50 | + )); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
@@ -57,14 +57,14 @@ discard block |
||
57 | 57 | * |
58 | 58 | * @return array |
59 | 59 | */ |
60 | - private function diffFiles ( $path , $driver , $schema = 0 ) |
|
60 | + private function diffFiles($path, $driver, $schema = 0) |
|
61 | 61 | { |
62 | - $tables = $driver->getTables ( $schema ); |
|
63 | - if(!$tables instanceof DbTables){ |
|
62 | + $tables = $driver->getTables($schema); |
|
63 | + if ( ! $tables instanceof DbTables) { |
|
64 | 64 | return array(); |
65 | 65 | } |
66 | 66 | $tablesName = $tables->toArrayFileName(); |
67 | - return array_diff ( $this->scanDir ( $path ) , $tablesName ); |
|
67 | + return array_diff($this->scanDir($path), $tablesName); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | /** |
@@ -74,14 +74,14 @@ discard block |
||
74 | 74 | * |
75 | 75 | * @return int |
76 | 76 | */ |
77 | - public function run ( $path , $driver , $schema = 0 ) |
|
77 | + public function run($path, $driver, $schema = 0) |
|
78 | 78 | { |
79 | 79 | $count = 0; |
80 | - foreach ( $this->diffFiles ( $path , $driver , $schema ) as $fileDel ) |
|
80 | + foreach ($this->diffFiles($path, $driver, $schema) as $fileDel) |
|
81 | 81 | { |
82 | - if ( unlink ( $path . DIRECTORY_SEPARATOR . $fileDel ) ) |
|
82 | + if (unlink($path . DIRECTORY_SEPARATOR . $fileDel)) |
|
83 | 83 | { |
84 | - ++ $count; |
|
84 | + ++$count; |
|
85 | 85 | } |
86 | 86 | } |
87 | 87 | |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | /** |
94 | 94 | * @return int |
95 | 95 | */ |
96 | - public function getNumFilesDeleted () |
|
96 | + public function getNumFilesDeleted() |
|
97 | 97 | { |
98 | 98 | return $this->countFileDeleted; |
99 | 99 | } |
@@ -55,7 +55,7 @@ |
||
55 | 55 | foreach ( $this->objDbTables as $objDbTable ) |
56 | 56 | { |
57 | 57 | $this->toArrayFileName[] = AbstractMaker::getClassName ( $objDbTable->getName () ) |
58 | - . '.php'; |
|
58 | + . '.php'; |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | return $this->toArrayFileName; |
@@ -5,56 +5,56 @@ discard block |
||
5 | 5 | use Classes\Db\DbTable; |
6 | 6 | use Classes\Maker\AbstractMaker; |
7 | 7 | |
8 | -class DbTables implements \ArrayAccess , \SeekableIterator , \Countable |
|
8 | +class DbTables implements \ArrayAccess, \SeekableIterator, \Countable |
|
9 | 9 | { |
10 | 10 | |
11 | 11 | /** |
12 | 12 | * @type DbTable[] |
13 | 13 | */ |
14 | - private $objDbTables = array (); |
|
14 | + private $objDbTables = array(); |
|
15 | 15 | |
16 | 16 | private $position = 0; |
17 | 17 | |
18 | - public function offsetExists ( $offset ) |
|
18 | + public function offsetExists($offset) |
|
19 | 19 | { |
20 | - return isset( $this->objDbTables[ trim ( $offset ) ] ); |
|
20 | + return isset($this->objDbTables[trim($offset)]); |
|
21 | 21 | } |
22 | 22 | |
23 | - public function offsetGet ( $offset ) |
|
23 | + public function offsetGet($offset) |
|
24 | 24 | { |
25 | - return $this->objDbTables[ trim ( $offset ) ]; |
|
25 | + return $this->objDbTables[trim($offset)]; |
|
26 | 26 | } |
27 | 27 | |
28 | - public function offsetSet ( $offset , $value ) |
|
28 | + public function offsetSet($offset, $value) |
|
29 | 29 | { |
30 | - return $this->objDbTables[ trim ( $offset ) ] = $value; |
|
30 | + return $this->objDbTables[trim($offset)] = $value; |
|
31 | 31 | } |
32 | 32 | |
33 | - public function offsetUnset ( $offset ) |
|
33 | + public function offsetUnset($offset) |
|
34 | 34 | { |
35 | - unset( $this->objDbTables[ trim ( $offset ) ] ); |
|
35 | + unset($this->objDbTables[trim($offset)]); |
|
36 | 36 | |
37 | 37 | return $this; |
38 | 38 | } |
39 | 39 | |
40 | - public function count () |
|
40 | + public function count() |
|
41 | 41 | { |
42 | - return count ( $this->objDbTables ); |
|
42 | + return count($this->objDbTables); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
46 | 46 | * convert array |
47 | 47 | */ |
48 | - public function toArrayFileName () |
|
48 | + public function toArrayFileName() |
|
49 | 49 | { |
50 | - if ( ! empty( $this->toArrayFileName ) ) |
|
50 | + if ( ! empty($this->toArrayFileName)) |
|
51 | 51 | { |
52 | 52 | return $this->toArrayFileName; |
53 | 53 | } |
54 | 54 | |
55 | - foreach ( $this->objDbTables as $objDbTable ) |
|
55 | + foreach ($this->objDbTables as $objDbTable) |
|
56 | 56 | { |
57 | - $this->toArrayFileName[] = AbstractMaker::getClassName ( $objDbTable->getName () ) |
|
57 | + $this->toArrayFileName[] = AbstractMaker::getClassName($objDbTable->getName()) |
|
58 | 58 | . '.php'; |
59 | 59 | } |
60 | 60 | |
@@ -63,12 +63,12 @@ discard block |
||
63 | 63 | |
64 | 64 | /* Method required for SeekableIterator interface */ |
65 | 65 | |
66 | - public function seek ( $position ) |
|
66 | + public function seek($position) |
|
67 | 67 | { |
68 | - $current = array_keys ( $this->objDbTables ); |
|
69 | - if ( ! isset( $this->objDbTables[ $current[ $position ] ] ) ) |
|
68 | + $current = array_keys($this->objDbTables); |
|
69 | + if ( ! isset($this->objDbTables[$current[$position]])) |
|
70 | 70 | { |
71 | - throw new OutOfBoundsException( "invalid seek position ($position)" ); |
|
71 | + throw new OutOfBoundsException("invalid seek position ($position)"); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | $this->position = $position; |
@@ -76,34 +76,34 @@ discard block |
||
76 | 76 | |
77 | 77 | /* Methods required for Iterator interface */ |
78 | 78 | |
79 | - public function rewind () |
|
79 | + public function rewind() |
|
80 | 80 | { |
81 | 81 | $this->position = 0; |
82 | 82 | } |
83 | 83 | |
84 | - public function current () |
|
84 | + public function current() |
|
85 | 85 | { |
86 | - $current = array_keys ( $this->objDbTables ); |
|
86 | + $current = array_keys($this->objDbTables); |
|
87 | 87 | |
88 | - return $this->objDbTables[ $current[ $this->position ] ]; |
|
88 | + return $this->objDbTables[$current[$this->position]]; |
|
89 | 89 | } |
90 | 90 | |
91 | - public function key () |
|
91 | + public function key() |
|
92 | 92 | { |
93 | - $current = array_keys ( $this->objDbTables ); |
|
93 | + $current = array_keys($this->objDbTables); |
|
94 | 94 | |
95 | - return $current[ $this->position ]; |
|
95 | + return $current[$this->position]; |
|
96 | 96 | } |
97 | 97 | |
98 | - public function next () |
|
98 | + public function next() |
|
99 | 99 | { |
100 | - ++ $this->position; |
|
100 | + ++$this->position; |
|
101 | 101 | } |
102 | 102 | |
103 | - public function valid () |
|
103 | + public function valid() |
|
104 | 104 | { |
105 | - $current = array_keys ( $this->objDbTables ); |
|
105 | + $current = array_keys($this->objDbTables); |
|
106 | 106 | |
107 | - return isset( $current[ $this->position ] ); |
|
107 | + return isset($current[$this->position]); |
|
108 | 108 | } |
109 | 109 | } |
110 | 110 | \ No newline at end of file |
@@ -13,15 +13,15 @@ |
||
13 | 13 | |
14 | 14 | public $pastName = 'Peer'; |
15 | 15 | protected $fileTpl = "peer.php"; |
16 | - protected $fileFixedData = array ( |
|
17 | - 'parentclass' => array ( |
|
18 | - 'name' => "AbstractPeer" , |
|
16 | + protected $fileFixedData = array( |
|
17 | + 'parentclass' => array( |
|
18 | + 'name' => "AbstractPeer", |
|
19 | 19 | 'tpl' => "peer_abstract.php" |
20 | 20 | ) |
21 | 21 | ); |
22 | 22 | |
23 | - public function parseRelation ( \Classes\MakerFile $makerFile, \Classes\Db\DbTable $dbTable ) |
|
23 | + public function parseRelation(\Classes\MakerFile $makerFile, \Classes\Db\DbTable $dbTable) |
|
24 | 24 | { |
25 | - return array (); |
|
25 | + return array(); |
|
26 | 26 | } |
27 | 27 | } |