@@ -3,21 +3,21 @@ 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 | * Tabela definida por 'tablename' |
9 | 9 | * |
10 | 10 | * @package <?=$objTables->getNamespace()?><?="\n"?> |
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 | |
20 | -class <?=$objTables->getNamespace()?>_DbTable_<?=\Classes\Maker\AbstractMaker::getClassName ( $objTables->getName () )?> extends <?=$this->config->namespace?$this->config->namespace."_":""?>Model_<?=$objMakeFile->getParentClass() . "\n"?> |
|
20 | +class <?=$objTables->getNamespace()?>_DbTable_<?=\Classes\Maker\AbstractMaker::getClassName($objTables->getName())?> extends <?=$this->config->namespace ? $this->config->namespace . "_" : ""?>Model_<?=$objMakeFile->getParentClass() . "\n"?> |
|
21 | 21 | { |
22 | 22 | /** |
23 | 23 | * Nome da tabela do banco de dados |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * @access protected |
27 | 27 | */ |
28 | 28 | protected $_name = '<?=$objTables->getName()?>'; |
29 | -<?php if($objTables->hasSchema()): ?> |
|
29 | +<?php if ($objTables->hasSchema()): ?> |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * Schema da tabela do banco de dados |
@@ -43,9 +43,9 @@ discard block |
||
43 | 43 | * @var string |
44 | 44 | * @access protected |
45 | 45 | */ |
46 | - protected $_rowClass = '<?=$objTables->getNamespace()?>_<?=\Classes\Maker\AbstractMaker::getClassName ( $objTables->getName () )?>'; |
|
46 | + protected $_rowClass = '<?=$objTables->getNamespace()?>_<?=\Classes\Maker\AbstractMaker::getClassName($objTables->getName())?>'; |
|
47 | 47 | |
48 | -<?php if( $objTables->hasPrimaryKey() ):?> |
|
48 | +<?php if ($objTables->hasPrimaryKey()):?> |
|
49 | 49 | /** |
50 | 50 | * Nome da Primary Key |
51 | 51 | * |
@@ -53,12 +53,12 @@ discard block |
||
53 | 53 | * @access protected |
54 | 54 | */ |
55 | 55 | protected $_primary = array( |
56 | -<?php foreach($objTables->getPrimaryKeys() as $pks):?> |
|
56 | +<?php foreach ($objTables->getPrimaryKeys() as $pks):?> |
|
57 | 57 | '<?=$pks->getName()?>', |
58 | 58 | <?php endforeach; ?> |
59 | 59 | ); |
60 | 60 | <?php endif ?> |
61 | -<?php if($this->config->{'folder-name'}):?> |
|
61 | +<?php if ($this->config->{'folder-name'}):?> |
|
62 | 62 | /** |
63 | 63 | * Initialize database adapter. |
64 | 64 | * |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | parent::_setupDatabaseAdapter(); |
74 | 74 | } |
75 | 75 | <?php endif ?> |
76 | -<?php if( $objTables->hasSequences() ) : ?> |
|
76 | +<?php if ($objTables->hasSequences()) : ?> |
|
77 | 77 | |
78 | 78 | /** |
79 | 79 | * Definir a lógica para os novos valores na chave primária. |
@@ -81,9 +81,9 @@ discard block |
||
81 | 81 | * |
82 | 82 | * @var mixed |
83 | 83 | */ |
84 | -<?php if ( 1 == count($objTables->getSequences() ) ) : ?> |
|
85 | -<?php if(strpos($this->config->driver, 'pgsql')): ?> |
|
86 | -<?php $seqs = $objTables->getSequences();reset($seqs);$seq = current($seqs);?> |
|
84 | +<?php if (1 == count($objTables->getSequences())) : ?> |
|
85 | +<?php if (strpos($this->config->driver, 'pgsql')): ?> |
|
86 | +<?php $seqs = $objTables->getSequences(); reset($seqs); $seq = current($seqs); ?> |
|
87 | 87 | protected $_sequence = '<?=$seq->getSequence() ?>'; |
88 | 88 | <?php else: ?> |
89 | 89 | protected $_sequence = true; |
@@ -18,8 +18,8 @@ |
||
18 | 18 | protected $parentFileTpl = "peer_abstract.php"; |
19 | 19 | protected $fileTpl = "peer.php"; |
20 | 20 | |
21 | - public function parseRelation ( \Classes\MakerFile $makerFile, \Classes\Db\DbTable $dbTable ) |
|
21 | + public function parseRelation(\Classes\MakerFile $makerFile, \Classes\Db\DbTable $dbTable) |
|
22 | 22 | { |
23 | - return array (); |
|
23 | + return array(); |
|
24 | 24 | } |
25 | 25 | } |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | /** |
201 | 201 | * Retorna o Nome da Sequence da tabela |
202 | 202 | * |
203 | - * @param $table |
|
203 | + * @param string $table |
|
204 | 204 | * @param $column |
205 | 205 | * |
206 | 206 | * @return string |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | * @param $nameTable |
250 | 250 | * @param int $schema |
251 | 251 | * |
252 | - * @return \Classes\Db\DbTable |
|
252 | + * @return AbsractAdapter |
|
253 | 253 | */ |
254 | 254 | public function createTable ( $nameTable, $schema = 0 ) |
255 | 255 | { |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | |
304 | 304 | /** |
305 | 305 | * @param string $nameTable |
306 | - * @param int|string $schema |
|
306 | + * @param integer $schema |
|
307 | 307 | * |
308 | 308 | * @return bool |
309 | 309 | */ |
@@ -115,32 +115,32 @@ discard block |
||
115 | 115 | if ( $table->hasColumn ( $constrant[ "column_name" ] ) ) |
116 | 116 | { |
117 | 117 | $objConstrant = Constrant::getInstance () |
118 | - ->populate ( |
|
119 | - array ( |
|
120 | - 'constrant' => $constrant[ 'constraint_name' ] , |
|
121 | - 'schema' => $constrant[ 'foreign_schema' ] , |
|
122 | - 'table' => $constrant[ 'foreign_table' ] , |
|
123 | - 'column' => $constrant[ 'foreign_column' ] , |
|
124 | - 'database' => $this->database |
|
125 | - ) |
|
126 | - ); |
|
118 | + ->populate ( |
|
119 | + array ( |
|
120 | + 'constrant' => $constrant[ 'constraint_name' ] , |
|
121 | + 'schema' => $constrant[ 'foreign_schema' ] , |
|
122 | + 'table' => $constrant[ 'foreign_table' ] , |
|
123 | + 'column' => $constrant[ 'foreign_column' ] , |
|
124 | + 'database' => $this->database |
|
125 | + ) |
|
126 | + ); |
|
127 | 127 | |
128 | 128 | switch ( $constrant[ 'constraint_type' ] ) |
129 | 129 | { |
130 | 130 | case "FOREIGN KEY": |
131 | 131 | $table->getColumn ( $constrant[ "column_name" ] ) |
132 | - ->addRefFk ( $objConstrant ); |
|
132 | + ->addRefFk ( $objConstrant ); |
|
133 | 133 | break; |
134 | 134 | case"PRIMARY KEY": |
135 | 135 | $table->getColumn ( $constrant[ "column_name" ] ) |
136 | - ->setPrimaryKey ( $objConstrant ) |
|
137 | - ->setSequence ( |
|
138 | - $this->getSequence ( |
|
139 | - $table_name , |
|
140 | - $constrant[ "column_name" ] , |
|
141 | - $schema |
|
142 | - ) |
|
143 | - ); |
|
136 | + ->setPrimaryKey ( $objConstrant ) |
|
137 | + ->setSequence ( |
|
138 | + $this->getSequence ( |
|
139 | + $table_name , |
|
140 | + $constrant[ "column_name" ] , |
|
141 | + $schema |
|
142 | + ) |
|
143 | + ); |
|
144 | 144 | break; |
145 | 145 | } |
146 | 146 | } |
@@ -160,13 +160,13 @@ discard block |
||
160 | 160 | if ( $table->hasColumn ( $constrant[ "foreign_column" ] ) ) |
161 | 161 | { |
162 | 162 | $table->getColumn ( $constrant[ "foreign_column" ] ) |
163 | - ->createDependece ( |
|
164 | - $constrant[ 'constraint_name' ] , |
|
165 | - $constrant[ 'table_name' ] , |
|
166 | - $constrant[ 'column_name' ] , |
|
167 | - $this->database , |
|
168 | - $constrant[ 'table_schema' ] |
|
169 | - ); |
|
163 | + ->createDependece ( |
|
164 | + $constrant[ 'constraint_name' ] , |
|
165 | + $constrant[ 'table_name' ] , |
|
166 | + $constrant[ 'column_name' ] , |
|
167 | + $this->database , |
|
168 | + $constrant[ 'table_schema' ] |
|
169 | + ); |
|
170 | 170 | } |
171 | 171 | } |
172 | 172 | } |
@@ -201,10 +201,10 @@ discard block |
||
201 | 201 | ); |
202 | 202 | |
203 | 203 | $this->getTable ( $key , $schema ) |
204 | - ->addColumn ( $column ) |
|
205 | - ->setNamespace ( |
|
206 | - $this->config->createClassNamespace ( $this->getTable ( $key , $schema ) ) |
|
207 | - ); |
|
204 | + ->addColumn ( $column ) |
|
205 | + ->setNamespace ( |
|
206 | + $this->config->createClassNamespace ( $this->getTable ( $key , $schema ) ) |
|
207 | + ); |
|
208 | 208 | } |
209 | 209 | } |
210 | 210 | |
@@ -279,13 +279,13 @@ discard block |
||
279 | 279 | } |
280 | 280 | |
281 | 281 | $this->objDbTables[ $schema ][ trim ( $nameTable ) ] = DbTable::getInstance () |
282 | - ->populate ( |
|
283 | - array ( |
|
284 | - 'table' => $nameTable , |
|
285 | - 'schema' => $schema , |
|
286 | - 'database' => $this->database |
|
287 | - ) |
|
288 | - ); |
|
282 | + ->populate ( |
|
283 | + array ( |
|
284 | + 'table' => $nameTable , |
|
285 | + 'schema' => $schema , |
|
286 | + 'database' => $this->database |
|
287 | + ) |
|
288 | + ); |
|
289 | 289 | |
290 | 290 | return $this; |
291 | 291 | } |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | /** |
68 | 68 | * @type \Classes\Db\Iterators\DbTables[] |
69 | 69 | */ |
70 | - private $objDbTables = array (); |
|
70 | + private $objDbTables = array(); |
|
71 | 71 | |
72 | 72 | /** |
73 | 73 | * @var AbstractAdapter |
@@ -82,22 +82,22 @@ discard block |
||
82 | 82 | /** |
83 | 83 | * analisa e popula as Foreing keys, Primary keys e dependencias do banco nos objetos |
84 | 84 | */ |
85 | - protected function parseConstrants () |
|
85 | + protected function parseConstrants() |
|
86 | 86 | { |
87 | - foreach ( $this->getListConstrant () as $constrant ) |
|
87 | + foreach ($this->getListConstrant() as $constrant) |
|
88 | 88 | { |
89 | 89 | |
90 | - $schema = $constrant[ 'table_schema' ]; |
|
91 | - $table_name = $constrant [ 'table_name' ]; |
|
92 | - $this->populateForeignAndPrimaryKeys ( $constrant , $table_name , $schema ); |
|
93 | - unset( $table_name , $schema ); |
|
90 | + $schema = $constrant['table_schema']; |
|
91 | + $table_name = $constrant ['table_name']; |
|
92 | + $this->populateForeignAndPrimaryKeys($constrant, $table_name, $schema); |
|
93 | + unset($table_name, $schema); |
|
94 | 94 | |
95 | - if ( $constrant[ 'constraint_type' ] == "FOREIGN KEY" ) |
|
95 | + if ($constrant['constraint_type'] == "FOREIGN KEY") |
|
96 | 96 | { |
97 | - $schema = $constrant[ 'foreign_schema' ]; |
|
98 | - $table_name = $constrant [ 'foreign_table' ]; |
|
99 | - $this->populateDependece ( $constrant , $table_name , $schema ); |
|
100 | - unset( $table_name , $schema ); |
|
97 | + $schema = $constrant['foreign_schema']; |
|
98 | + $table_name = $constrant ['foreign_table']; |
|
99 | + $this->populateDependece($constrant, $table_name, $schema); |
|
100 | + unset($table_name, $schema); |
|
101 | 101 | } |
102 | 102 | } |
103 | 103 | } |
@@ -107,37 +107,37 @@ discard block |
||
107 | 107 | * @param string $table_name |
108 | 108 | * @param int $schema |
109 | 109 | */ |
110 | - private function populateForeignAndPrimaryKeys ( $constrant , $table_name , $schema = 0 ) |
|
110 | + private function populateForeignAndPrimaryKeys($constrant, $table_name, $schema = 0) |
|
111 | 111 | { |
112 | - if ( $this->hasTable ( $table_name , $schema ) ) |
|
112 | + if ($this->hasTable($table_name, $schema)) |
|
113 | 113 | { |
114 | - $table = $this->getTable ( $table_name , $schema ); |
|
115 | - if ( $table->hasColumn ( $constrant[ "column_name" ] ) ) |
|
114 | + $table = $this->getTable($table_name, $schema); |
|
115 | + if ($table->hasColumn($constrant["column_name"])) |
|
116 | 116 | { |
117 | - $objConstrant = Constrant::getInstance () |
|
118 | - ->populate ( |
|
119 | - array ( |
|
120 | - 'constrant' => $constrant[ 'constraint_name' ] , |
|
121 | - 'schema' => $constrant[ 'foreign_schema' ] , |
|
122 | - 'table' => $constrant[ 'foreign_table' ] , |
|
123 | - 'column' => $constrant[ 'foreign_column' ] , |
|
117 | + $objConstrant = Constrant::getInstance() |
|
118 | + ->populate( |
|
119 | + array( |
|
120 | + 'constrant' => $constrant['constraint_name'], |
|
121 | + 'schema' => $constrant['foreign_schema'], |
|
122 | + 'table' => $constrant['foreign_table'], |
|
123 | + 'column' => $constrant['foreign_column'], |
|
124 | 124 | 'database' => $this->database |
125 | 125 | ) |
126 | 126 | ); |
127 | 127 | |
128 | - switch ( $constrant[ 'constraint_type' ] ) |
|
128 | + switch ($constrant['constraint_type']) |
|
129 | 129 | { |
130 | 130 | case "FOREIGN KEY": |
131 | - $table->getColumn ( $constrant[ "column_name" ] ) |
|
132 | - ->addRefFk ( $objConstrant ); |
|
131 | + $table->getColumn($constrant["column_name"]) |
|
132 | + ->addRefFk($objConstrant); |
|
133 | 133 | break; |
134 | 134 | case"PRIMARY KEY": |
135 | - $table->getColumn ( $constrant[ "column_name" ] ) |
|
136 | - ->setPrimaryKey ( $objConstrant ) |
|
137 | - ->setSequence ( |
|
138 | - $this->getSequence ( |
|
139 | - $table_name , |
|
140 | - $constrant[ "column_name" ] , |
|
135 | + $table->getColumn($constrant["column_name"]) |
|
136 | + ->setPrimaryKey($objConstrant) |
|
137 | + ->setSequence( |
|
138 | + $this->getSequence( |
|
139 | + $table_name, |
|
140 | + $constrant["column_name"], |
|
141 | 141 | $schema |
142 | 142 | ) |
143 | 143 | ); |
@@ -152,20 +152,20 @@ discard block |
||
152 | 152 | * @param string $table_name |
153 | 153 | * @param int $schema |
154 | 154 | */ |
155 | - private function populateDependece ( $constrant , $table_name , $schema = 0 ) |
|
155 | + private function populateDependece($constrant, $table_name, $schema = 0) |
|
156 | 156 | { |
157 | - if ( $this->hasTable ( $table_name , $schema ) ) |
|
157 | + if ($this->hasTable($table_name, $schema)) |
|
158 | 158 | { |
159 | - $table = $this->getTable ( $table_name , $schema ); |
|
160 | - if ( $table->hasColumn ( $constrant[ "foreign_column" ] ) ) |
|
159 | + $table = $this->getTable($table_name, $schema); |
|
160 | + if ($table->hasColumn($constrant["foreign_column"])) |
|
161 | 161 | { |
162 | - $table->getColumn ( $constrant[ "foreign_column" ] ) |
|
163 | - ->createDependece ( |
|
164 | - $constrant[ 'constraint_name' ] , |
|
165 | - $constrant[ 'table_name' ] , |
|
166 | - $constrant[ 'column_name' ] , |
|
167 | - $this->database , |
|
168 | - $constrant[ 'table_schema' ] |
|
162 | + $table->getColumn($constrant["foreign_column"]) |
|
163 | + ->createDependece( |
|
164 | + $constrant['constraint_name'], |
|
165 | + $constrant['table_name'], |
|
166 | + $constrant['column_name'], |
|
167 | + $this->database, |
|
168 | + $constrant['table_schema'] |
|
169 | 169 | ); |
170 | 170 | } |
171 | 171 | } |
@@ -174,36 +174,36 @@ discard block |
||
174 | 174 | /** |
175 | 175 | * cria um Array com nome das tabelas |
176 | 176 | */ |
177 | - public function parseTables () |
|
177 | + public function parseTables() |
|
178 | 178 | { |
179 | - if ( $this->hasTables () ) |
|
179 | + if ($this->hasTables()) |
|
180 | 180 | { |
181 | - return $this->getAllTables (); |
|
181 | + return $this->getAllTables(); |
|
182 | 182 | } |
183 | 183 | |
184 | - foreach ( $this->getListColumns () as $table ) |
|
184 | + foreach ($this->getListColumns() as $table) |
|
185 | 185 | { |
186 | - $schema = $table[ 'table_schema' ]; |
|
187 | - $key = $table [ 'table_name' ]; |
|
188 | - if ( ! $this->hasTable ( $key , $schema ) ) |
|
186 | + $schema = $table['table_schema']; |
|
187 | + $key = $table ['table_name']; |
|
188 | + if ( ! $this->hasTable($key, $schema)) |
|
189 | 189 | { |
190 | - $this->createTable ( $key , $schema ); |
|
190 | + $this->createTable($key, $schema); |
|
191 | 191 | } |
192 | 192 | |
193 | - $column = Column::getInstance () |
|
194 | - ->populate ( |
|
195 | - array ( |
|
196 | - 'name' => $table [ 'column_name' ] , |
|
197 | - 'type' => $this->convertTypeToSimple ( $table[ 'data_type' ] ) , |
|
198 | - 'nullable' => (is_string($table[ 'is_nullable' ]) && strtolower($table[ 'is_nullable' ]) != 'no' ) , |
|
199 | - 'max_length' => $table[ 'max_length' ] |
|
193 | + $column = Column::getInstance() |
|
194 | + ->populate( |
|
195 | + array( |
|
196 | + 'name' => $table ['column_name'], |
|
197 | + 'type' => $this->convertTypeToSimple($table['data_type']), |
|
198 | + 'nullable' => (is_string($table['is_nullable']) && strtolower($table['is_nullable']) != 'no'), |
|
199 | + 'max_length' => $table['max_length'] |
|
200 | 200 | ) |
201 | 201 | ); |
202 | 202 | |
203 | - $this->getTable ( $key , $schema ) |
|
204 | - ->addColumn ( $column ) |
|
205 | - ->setNamespace ( |
|
206 | - $this->config->createClassNamespace ( $this->getTable ( $key , $schema ) ) |
|
203 | + $this->getTable($key, $schema) |
|
204 | + ->addColumn($column) |
|
205 | + ->setNamespace( |
|
206 | + $this->config->createClassNamespace($this->getTable($key, $schema)) |
|
207 | 207 | ); |
208 | 208 | } |
209 | 209 | } |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | * |
214 | 214 | * @return int |
215 | 215 | */ |
216 | - abstract public function getTotalTables (); |
|
216 | + abstract public function getTotalTables(); |
|
217 | 217 | |
218 | 218 | /** |
219 | 219 | * Retorna o Nome da Sequence da tabela |
@@ -223,33 +223,33 @@ discard block |
||
223 | 223 | * |
224 | 224 | * @return string |
225 | 225 | */ |
226 | - abstract public function getSequence ( $table , $column , $schema = 0 ); |
|
226 | + abstract public function getSequence($table, $column, $schema = 0); |
|
227 | 227 | |
228 | 228 | /** |
229 | 229 | * @return array |
230 | 230 | */ |
231 | - abstract public function getListConstrant (); |
|
231 | + abstract public function getListConstrant(); |
|
232 | 232 | |
233 | 233 | /** |
234 | 234 | * @param string $str |
235 | 235 | * |
236 | 236 | * @return string |
237 | 237 | */ |
238 | - protected function convertTypeToPhp ( $str ) |
|
238 | + protected function convertTypeToPhp($str) |
|
239 | 239 | { |
240 | - if ( isset( $this->dataTypesToPhp[ $str ] ) ) |
|
240 | + if (isset($this->dataTypesToPhp[$str])) |
|
241 | 241 | { |
242 | - return $this->dataTypesToPhp[ $str ]; |
|
242 | + return $this->dataTypesToPhp[$str]; |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | return 'string'; |
246 | 246 | } |
247 | 247 | |
248 | - protected function convertTypeToSimple ( $str ) |
|
248 | + protected function convertTypeToSimple($str) |
|
249 | 249 | { |
250 | - if ( isset( $this->dataTypesToSimple[ $str ] ) ) |
|
250 | + if (isset($this->dataTypesToSimple[$str])) |
|
251 | 251 | { |
252 | - return $this->dataTypesToSimple[ $str ]; |
|
252 | + return $this->dataTypesToSimple[$str]; |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | return 'string'; |
@@ -258,12 +258,12 @@ discard block |
||
258 | 258 | /** |
259 | 259 | * @return string |
260 | 260 | */ |
261 | - abstract public function getPDOString (); |
|
261 | + abstract public function getPDOString(); |
|
262 | 262 | |
263 | 263 | /** |
264 | 264 | * @return string |
265 | 265 | */ |
266 | - abstract public function getPDOSocketString (); |
|
266 | + abstract public function getPDOSocketString(); |
|
267 | 267 | |
268 | 268 | /** |
269 | 269 | * @param $nameTable |
@@ -271,18 +271,18 @@ discard block |
||
271 | 271 | * |
272 | 272 | * @return \Classes\Db\DbTable |
273 | 273 | */ |
274 | - public function createTable ( $nameTable , $schema = 0 ) |
|
274 | + public function createTable($nameTable, $schema = 0) |
|
275 | 275 | { |
276 | - if ( ! isset( $this->objDbTables[ $schema ] ) ) |
|
276 | + if ( ! isset($this->objDbTables[$schema])) |
|
277 | 277 | { |
278 | - $this->objDbTables[ $schema ] = new DbTables(); |
|
278 | + $this->objDbTables[$schema] = new DbTables(); |
|
279 | 279 | } |
280 | 280 | |
281 | - $this->objDbTables[ $schema ][ trim ( $nameTable ) ] = DbTable::getInstance () |
|
282 | - ->populate ( |
|
283 | - array ( |
|
284 | - 'table' => $nameTable , |
|
285 | - 'schema' => $schema , |
|
281 | + $this->objDbTables[$schema][trim($nameTable)] = DbTable::getInstance() |
|
282 | + ->populate( |
|
283 | + array( |
|
284 | + 'table' => $nameTable, |
|
285 | + 'schema' => $schema, |
|
286 | 286 | 'database' => $this->database |
287 | 287 | ) |
288 | 288 | ); |
@@ -295,24 +295,24 @@ discard block |
||
295 | 295 | * |
296 | 296 | * @return \Classes\Db\Iterators\DbTables |
297 | 297 | */ |
298 | - public function getTables ( $schema = 0 ) |
|
298 | + public function getTables($schema = 0) |
|
299 | 299 | { |
300 | - if ( ! isset( $this->objDbTables[ $schema ] ) ) |
|
300 | + if ( ! isset($this->objDbTables[$schema])) |
|
301 | 301 | { |
302 | - return array (); |
|
302 | + return array(); |
|
303 | 303 | } |
304 | 304 | |
305 | - return $this->objDbTables[ $schema ]; |
|
305 | + return $this->objDbTables[$schema]; |
|
306 | 306 | } |
307 | 307 | |
308 | - public function getAllTables () |
|
308 | + public function getAllTables() |
|
309 | 309 | { |
310 | 310 | return $this->objDbTables; |
311 | 311 | } |
312 | 312 | |
313 | - public function hasTables () |
|
313 | + public function hasTables() |
|
314 | 314 | { |
315 | - return ! empty( $this->objDbTables ); |
|
315 | + return ! empty($this->objDbTables); |
|
316 | 316 | } |
317 | 317 | |
318 | 318 | /** |
@@ -322,9 +322,9 @@ discard block |
||
322 | 322 | * |
323 | 323 | * @return \Classes\Db\DbTable |
324 | 324 | */ |
325 | - public function getTable ( $nameTable , $schema = 0 ) |
|
325 | + public function getTable($nameTable, $schema = 0) |
|
326 | 326 | { |
327 | - return $this->objDbTables[ $schema ][ trim ( $nameTable ) ]; |
|
327 | + return $this->objDbTables[$schema][trim($nameTable)]; |
|
328 | 328 | } |
329 | 329 | |
330 | 330 | /** |
@@ -333,9 +333,9 @@ discard block |
||
333 | 333 | * |
334 | 334 | * @return bool |
335 | 335 | */ |
336 | - public function hasTable ( $nameTable , $schema = 0 ) |
|
336 | + public function hasTable($nameTable, $schema = 0) |
|
337 | 337 | { |
338 | - return isset( $this->objDbTables[ $schema ][ trim ( $nameTable ) ] ); |
|
338 | + return isset($this->objDbTables[$schema][trim($nameTable)]); |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | /** |
@@ -343,66 +343,66 @@ discard block |
||
343 | 343 | * |
344 | 344 | * @return array[] |
345 | 345 | */ |
346 | - abstract public function getListColumns (); |
|
346 | + abstract public function getListColumns(); |
|
347 | 347 | |
348 | 348 | /** |
349 | 349 | * Retorna um Array com nome das tabelas |
350 | 350 | * |
351 | 351 | * @return string[] |
352 | 352 | */ |
353 | - abstract public function getListNameTable (); |
|
353 | + abstract public function getListNameTable(); |
|
354 | 354 | |
355 | 355 | /** |
356 | 356 | * @param \Classes\AdapterConfig\AbstractAdapter $adapterConfig |
357 | 357 | */ |
358 | - public function __construct ( AbstractAdapter $adapterConfig ) |
|
358 | + public function __construct(AbstractAdapter $adapterConfig) |
|
359 | 359 | { |
360 | 360 | $this->config = $adapterConfig; |
361 | - $this->host = $adapterConfig->getHost (); |
|
362 | - $this->database = $adapterConfig->getDatabase (); |
|
363 | - $this->port = $adapterConfig->hasPort () ? $adapterConfig->getPort () |
|
361 | + $this->host = $adapterConfig->getHost(); |
|
362 | + $this->database = $adapterConfig->getDatabase(); |
|
363 | + $this->port = $adapterConfig->hasPort() ? $adapterConfig->getPort() |
|
364 | 364 | : $this->port; |
365 | - $this->username = $adapterConfig->getUser (); |
|
366 | - $this->password = $adapterConfig->getPassword (); |
|
367 | - $this->socket = $adapterConfig->getSocket (); |
|
368 | - $this->tablesName = $adapterConfig->hasTablesName () |
|
369 | - ? $adapterConfig->getListTablesName () : ''; |
|
365 | + $this->username = $adapterConfig->getUser(); |
|
366 | + $this->password = $adapterConfig->getPassword(); |
|
367 | + $this->socket = $adapterConfig->getSocket(); |
|
368 | + $this->tablesName = $adapterConfig->hasTablesName() |
|
369 | + ? $adapterConfig->getListTablesName() : ''; |
|
370 | 370 | |
371 | 371 | } |
372 | 372 | |
373 | 373 | /** |
374 | 374 | * Executa as consultas do banco de dados |
375 | 375 | */ |
376 | - public function runDatabase () |
|
376 | + public function runDatabase() |
|
377 | 377 | { |
378 | - $this->parseTables (); |
|
379 | - $this->parseConstrants (); |
|
378 | + $this->parseTables(); |
|
379 | + $this->parseConstrants(); |
|
380 | 380 | } |
381 | 381 | |
382 | 382 | /** |
383 | 383 | * |
384 | 384 | * @return \PDO |
385 | 385 | */ |
386 | - public function getPDO () |
|
386 | + public function getPDO() |
|
387 | 387 | { |
388 | - if ( is_null ( $this->_pdo ) ) |
|
388 | + if (is_null($this->_pdo)) |
|
389 | 389 | { |
390 | - if ( ! empty( $this->socket ) ) |
|
390 | + if ( ! empty($this->socket)) |
|
391 | 391 | { |
392 | - $pdoString = $this->getPDOSocketString (); |
|
392 | + $pdoString = $this->getPDOSocketString(); |
|
393 | 393 | } else |
394 | 394 | { |
395 | - $pdoString = $this->getPDOString (); |
|
395 | + $pdoString = $this->getPDOString(); |
|
396 | 396 | } |
397 | 397 | |
398 | 398 | try |
399 | 399 | { |
400 | - $this->_pdo = new \PDO ( |
|
401 | - $pdoString , $this->username , $this->password |
|
400 | + $this->_pdo = new \PDO( |
|
401 | + $pdoString, $this->username, $this->password |
|
402 | 402 | ); |
403 | - } catch ( \Exception $e ) |
|
403 | + } catch (\Exception $e) |
|
404 | 404 | { |
405 | - die ( "\033[0;31mPDO error: " . $e->getMessage () . "\033[0m\n" ); |
|
405 | + die ("\033[0;31mPDO error: " . $e->getMessage() . "\033[0m\n"); |
|
406 | 406 | } |
407 | 407 | } |
408 | 408 |
@@ -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 |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | * |
19 | 19 | * @author Pedro Alarcao <[email protected]> |
20 | 20 | */ |
21 | - final private function __construct () |
|
21 | + final private function __construct() |
|
22 | 22 | { |
23 | 23 | } |
24 | 24 | |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | * |
28 | 28 | * @return \Classes\Db\Column |
29 | 29 | */ |
30 | - public static function getInstance () |
|
30 | + public static function getInstance() |
|
31 | 31 | { |
32 | 32 | return new Column(); |
33 | 33 | } |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | /** |
81 | 81 | * @return string |
82 | 82 | */ |
83 | - public function getName () |
|
83 | + public function getName() |
|
84 | 84 | { |
85 | 85 | return $this->name; |
86 | 86 | } |
@@ -90,12 +90,12 @@ discard block |
||
90 | 90 | * |
91 | 91 | * @param $array |
92 | 92 | */ |
93 | - public function populate ( $array ) |
|
93 | + public function populate($array) |
|
94 | 94 | { |
95 | - $this->name = $array[ 'name' ]; |
|
96 | - $this->type = $array[ 'type' ]; |
|
97 | - $this->nullable = $array[ 'nullable' ]; |
|
98 | - $this->max_length = $array[ 'max_length' ]; |
|
95 | + $this->name = $array['name']; |
|
96 | + $this->type = $array['type']; |
|
97 | + $this->nullable = $array['nullable']; |
|
98 | + $this->max_length = $array['max_length']; |
|
99 | 99 | |
100 | 100 | return $this; |
101 | 101 | } |
@@ -103,37 +103,37 @@ discard block |
||
103 | 103 | /** |
104 | 104 | * @return boolean |
105 | 105 | */ |
106 | - public function isPrimaryKey () |
|
106 | + public function isPrimaryKey() |
|
107 | 107 | { |
108 | - return !empty( $this->primarykey ); |
|
108 | + return ! empty($this->primarykey); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
112 | 112 | * @return boolean |
113 | 113 | */ |
114 | - public function isForeingkey () |
|
114 | + public function isForeingkey() |
|
115 | 115 | { |
116 | - return !empty( $this->refForeingkey ); |
|
116 | + return ! empty($this->refForeingkey); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | /** |
120 | 120 | * @return boolean |
121 | 121 | */ |
122 | - public function hasDependence () |
|
122 | + public function hasDependence() |
|
123 | 123 | { |
124 | - return !empty( $this->dependences ); |
|
124 | + return ! empty($this->dependences); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
128 | 128 | * @return string |
129 | 129 | */ |
130 | - public function getType ( $inPHP = true ) |
|
130 | + public function getType($inPHP = true) |
|
131 | 131 | { |
132 | - if ( !$inPHP ) { |
|
132 | + if ( ! $inPHP) { |
|
133 | 133 | return $this->type; |
134 | 134 | } |
135 | 135 | |
136 | - return AbstractAdapter::convertTypeToPHP ( $this->type ); |
|
136 | + return AbstractAdapter::convertTypeToPHP($this->type); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
@@ -142,9 +142,9 @@ discard block |
||
142 | 142 | * |
143 | 143 | * @return bool |
144 | 144 | */ |
145 | - public function equalType ( $type, $inPHP = true ) |
|
145 | + public function equalType($type, $inPHP = true) |
|
146 | 146 | { |
147 | - return $this->getType ( $inPHP ) === $type; |
|
147 | + return $this->getType($inPHP) === $type; |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | /** |
@@ -152,15 +152,15 @@ discard block |
||
152 | 152 | * |
153 | 153 | * @return mixed |
154 | 154 | */ |
155 | - public function getTypeByConfig ( AbstractAdapter $type ) |
|
155 | + public function getTypeByConfig(AbstractAdapter $type) |
|
156 | 156 | { |
157 | - return $type->convertTypeToTypeFramework ( $this->getType ( false ) ); |
|
157 | + return $type->convertTypeToTypeFramework($this->getType(false)); |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | /** |
161 | 161 | * @return string |
162 | 162 | */ |
163 | - public function getComment () |
|
163 | + public function getComment() |
|
164 | 164 | { |
165 | 165 | return $this->comment; |
166 | 166 | } |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | /** |
169 | 169 | * @param string $comment |
170 | 170 | */ |
171 | - public function setComment ( $comment ) |
|
171 | + public function setComment($comment) |
|
172 | 172 | { |
173 | 173 | $this->comment = $comment; |
174 | 174 | |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | /** |
179 | 179 | * @param \Classes\Db\Constrant $primarykey |
180 | 180 | */ |
181 | - public function setPrimaryKey ( Constrant $primarykey ) |
|
181 | + public function setPrimaryKey(Constrant $primarykey) |
|
182 | 182 | { |
183 | 183 | $this->primarykey = $primarykey; |
184 | 184 | |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | /** |
189 | 189 | * @param \Classes\Db\Constrant $dependece |
190 | 190 | */ |
191 | - public function addDependece ( Constrant $dependece ) |
|
191 | + public function addDependece(Constrant $dependece) |
|
192 | 192 | { |
193 | 193 | $this->dependences[] = $dependece; |
194 | 194 | |
@@ -202,11 +202,11 @@ discard block |
||
202 | 202 | * |
203 | 203 | * @return $this |
204 | 204 | */ |
205 | - public function createDependece ( $constraint_name, $table_name, $column_name, $database, $schema = null ) |
|
205 | + public function createDependece($constraint_name, $table_name, $column_name, $database, $schema = null) |
|
206 | 206 | { |
207 | - $objConstrantDependence = Constrant::getInstance () |
|
208 | - ->populate ( |
|
209 | - array ( |
|
207 | + $objConstrantDependence = Constrant::getInstance() |
|
208 | + ->populate( |
|
209 | + array( |
|
210 | 210 | 'constrant' => $constraint_name, |
211 | 211 | 'schema' => $schema, |
212 | 212 | 'table' => $table_name, |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | ) |
216 | 216 | ); |
217 | 217 | |
218 | - $this->addDependece ( $objConstrantDependence ); |
|
218 | + $this->addDependece($objConstrantDependence); |
|
219 | 219 | |
220 | 220 | return $this; |
221 | 221 | } |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | /** |
224 | 224 | * @param \Classes\Db\Constrant $reference |
225 | 225 | */ |
226 | - public function addRefFk ( Constrant $reference ) |
|
226 | + public function addRefFk(Constrant $reference) |
|
227 | 227 | { |
228 | 228 | $this->refForeingkey = $reference; |
229 | 229 | |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | * |
236 | 236 | * @return \Classes\Db\Constrant |
237 | 237 | */ |
238 | - public function getFks () |
|
238 | + public function getFks() |
|
239 | 239 | { |
240 | 240 | return $this->refForeingkey; |
241 | 241 | } |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | * |
246 | 246 | * @return \Classes\Db\Constrant[] |
247 | 247 | */ |
248 | - public function getDependences () |
|
248 | + public function getDependences() |
|
249 | 249 | { |
250 | 250 | return $this->dependences; |
251 | 251 | } |
@@ -253,9 +253,9 @@ discard block |
||
253 | 253 | /** |
254 | 254 | * @return bool |
255 | 255 | */ |
256 | - public function hasDependences () |
|
256 | + public function hasDependences() |
|
257 | 257 | { |
258 | - return (bool) count ( $this->dependences ); |
|
258 | + return (bool) count($this->dependences); |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | /** |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | * |
264 | 264 | * @return \Classes\Db\Constrant[] |
265 | 265 | */ |
266 | - public function getPrimaryKey () |
|
266 | + public function getPrimaryKey() |
|
267 | 267 | { |
268 | 268 | return $this->primarykey; |
269 | 269 | } |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | /** |
272 | 272 | * |
273 | 273 | */ |
274 | - public function getMaxLength () |
|
274 | + public function getMaxLength() |
|
275 | 275 | { |
276 | 276 | return $this->max_length; |
277 | 277 | } |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | /** |
280 | 280 | * @return bool |
281 | 281 | */ |
282 | - public function hasSequence () |
|
282 | + public function hasSequence() |
|
283 | 283 | { |
284 | 284 | return (bool) $this->sequence; |
285 | 285 | } |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | /** |
288 | 288 | * @return string |
289 | 289 | */ |
290 | - public function getSequence () |
|
290 | + public function getSequence() |
|
291 | 291 | { |
292 | 292 | return $this->sequence; |
293 | 293 | } |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | /** |
296 | 296 | * @param string $sequence |
297 | 297 | */ |
298 | - public function setSequence ( $sequence ) |
|
298 | + public function setSequence($sequence) |
|
299 | 299 | { |
300 | 300 | $this->sequence = $sequence; |
301 | 301 | } |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | /** |
304 | 304 | * @return boolean |
305 | 305 | */ |
306 | - public function isNullable () |
|
306 | + public function isNullable() |
|
307 | 307 | { |
308 | 308 | return $this->nullable; |
309 | 309 | } |
@@ -3,19 +3,19 @@ |
||
3 | 3 | /** |
4 | 4 | * Mvc Model |
5 | 5 | * |
6 | - * <?=$this->config->last_modify."\n"?> |
|
6 | + * <?=$this->config->last_modify . "\n"?> |
|
7 | 7 | * |
8 | 8 | * @package <?=$this->config->namespace?>\Models |
9 | 9 | * @subpackage Model |
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 | -namespace <?=$this->config->namespace?$this->config->namespace."\\":""?>Models; |
|
18 | +namespace <?=$this->config->namespace ? $this->config->namespace . "\\" : ""?>Models; |
|
19 | 19 | |
20 | 20 | abstract class AbstractPeer |
21 | 21 | { |
@@ -3,43 +3,43 @@ discard block |
||
3 | 3 | /** |
4 | 4 | * Mvc Model |
5 | 5 | * |
6 | - * <?=$this->config->last_modify."\n"?> |
|
6 | + * <?=$this->config->last_modify . "\n"?> |
|
7 | 7 | * |
8 | 8 | * @package <?=$objTables->getNamespace()?>\Entity |
9 | 9 | * @subpackage Model |
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 | namespace <?=$objTables->getNamespace()?>\Entity; |
19 | 19 | |
20 | 20 | use Phalcon\Validation; |
21 | 21 | |
22 | -abstract class <?=\Classes\Maker\AbstractMaker::getClassName ( $objTables->getName () )?> extends \<?=$this->config->namespace?$this->config->namespace."\\":""?>Models\<?=$objMakeFile->getParentClass() . "\n"?> |
|
22 | +abstract class <?=\Classes\Maker\AbstractMaker::getClassName($objTables->getName())?> extends \<?=$this->config->namespace ? $this->config->namespace . "\\" : ""?>Models\<?=$objMakeFile->getParentClass() . "\n"?> |
|
23 | 23 | { |
24 | 24 | |
25 | 25 | <?php foreach ($objTables->getColumns() as $column): ?> |
26 | 26 | /** |
27 | - * column <?=$column->getName()."\n"?> |
|
27 | + * column <?=$column->getName() . "\n"?> |
|
28 | 28 | * |
29 | -<?php if($column->isPrimaryKey()):?> |
|
29 | +<?php if ($column->isPrimaryKey()):?> |
|
30 | 30 | * @Primary |
31 | 31 | <?php endif ?> |
32 | -<?php if($column->hasSequence()):?> |
|
32 | +<?php if ($column->hasSequence()):?> |
|
33 | 33 | * @Identity |
34 | 34 | <?php endif ?> |
35 | - * @Column(type="<?=$column->getTypeByConfig( $this->config )?>", nullable=<?=$column->isNullable () ? "true" : "false"?><?php |
|
36 | -if ( $column->getMaxLength () ): ?> |
|
37 | -, length=<?=$column->getMaxLength ()?> |
|
35 | + * @Column(type="<?=$column->getTypeByConfig($this->config)?>", nullable=<?=$column->isNullable() ? "true" : "false"?><?php |
|
36 | +if ($column->getMaxLength()): ?> |
|
37 | +, length=<?=$column->getMaxLength()?> |
|
38 | 38 | <?php endif ?>, column="<?=$column->getName()?>" ) |
39 | 39 | */ |
40 | 40 | protected $<?=$column->getName()?>; |
41 | 41 | |
42 | -<?php endforeach;?> |
|
42 | +<?php endforeach; ?> |
|
43 | 43 | /** |
44 | 44 | * Validations and business logic |
45 | 45 | * |
@@ -50,14 +50,14 @@ discard block |
||
50 | 50 | $validator = new Validation(); |
51 | 51 | |
52 | 52 | <?php foreach ($objTables->getColumns() as $column): ?> |
53 | -<?php if(strtolower($column->getName()) == 'email'):?> |
|
53 | +<?php if (strtolower($column->getName()) == 'email'):?> |
|
54 | 54 | $validator->add( |
55 | 55 | 'email', |
56 | 56 | new \Phalcon\Validation\Validator\Email() |
57 | 57 | ); |
58 | 58 | |
59 | 59 | <?php endif ?> |
60 | -<?php endforeach;?> |
|
60 | +<?php endforeach; ?> |
|
61 | 61 | return $this->validate($validator); |
62 | 62 | } |
63 | 63 | |
@@ -66,11 +66,11 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function initialize() |
68 | 68 | { |
69 | - <?=$mapDependents."\n"?> |
|
70 | - <?=$mapParents."\n"?> |
|
69 | + <?=$mapDependents . "\n"?> |
|
70 | + <?=$mapParents . "\n"?> |
|
71 | 71 | } |
72 | 72 | |
73 | -<?php if($objTables->hasSchema()): ?> |
|
73 | +<?php if ($objTables->hasSchema()): ?> |
|
74 | 74 | /** |
75 | 75 | * Returns schema name where table mapped is located |
76 | 76 | * |
@@ -92,28 +92,28 @@ discard block |
||
92 | 92 | return '<?=$objTables->getName()?>'; |
93 | 93 | } |
94 | 94 | |
95 | -<?php if( $objTables->hasSequences() ) : ?> |
|
95 | +<?php if ($objTables->hasSequences()) : ?> |
|
96 | 96 | public function getSequenceName() |
97 | 97 | { |
98 | -<?php if ( 1 == count($objTables->getSequences() ) ) : ?> |
|
99 | - <?php $seqs = $objTables->getSequences();reset($seqs);$seq = current($seqs);?> |
|
98 | +<?php if (1 == count($objTables->getSequences())) : ?> |
|
99 | + <?php $seqs = $objTables->getSequences(); reset($seqs); $seq = current($seqs); ?> |
|
100 | 100 | return "<?=$seq->getSequence() ?>"; |
101 | 101 | <?php endif ?> |
102 | 102 | } |
103 | 103 | |
104 | 104 | <?php endif ?> |
105 | 105 | <?php foreach ($objTables->getColumns() as $column): ?> |
106 | - public function set<?=$this->getClassName ( $column->getName () )?>( $<?=$column->getName()?> ) |
|
106 | + public function set<?=$this->getClassName($column->getName())?>( $<?=$column->getName()?> ) |
|
107 | 107 | { |
108 | 108 | $this-><?=$column->getName()?> = $<?=$column->getName()?>; |
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
112 | - * @return <?=$column->getType ()."\n" ?> |
|
112 | + * @return <?=$column->getType() . "\n" ?> |
|
113 | 113 | **/ |
114 | - public function get<?=$this->getClassName ( $column->getName () )?>() |
|
114 | + public function get<?=$this->getClassName($column->getName())?>() |
|
115 | 115 | { |
116 | - return (<?=$column->getType () ?>) $this-><?=$column->getName()?>; |
|
116 | + return (<?=$column->getType() ?>) $this-><?=$column->getName()?>; |
|
117 | 117 | } |
118 | -<?php endforeach;?> |
|
118 | +<?php endforeach; ?> |
|
119 | 119 | } |
120 | 120 | \ No newline at end of file |
@@ -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 | - return $this->getPDO () |
|
143 | - ->query ( |
|
142 | + return $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_schema, k.table_name;" |
161 | 161 | ) |
162 | - ->fetchAll ( \PDO::FETCH_ASSOC ); |
|
162 | + ->fetchAll(\PDO::FETCH_ASSOC); |
|
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 |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | { |
89 | 89 | foreach ( $arrFoldersName as $index => $folderName ) { |
90 | 90 | $arrFoldersName[ $index ] = $this->getConfig () |
91 | - ->replaceReservedWord ( $folderName ); |
|
91 | + ->replaceReservedWord ( $folderName ); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | return implode ( DIRECTORY_SEPARATOR, array_filter ( $arrFoldersName ) ); |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | $folderName, |
142 | 142 | $this->getClassName ( |
143 | 143 | $this->getConfig () |
144 | - ->getDatabase () |
|
144 | + ->getDatabase () |
|
145 | 145 | ) |
146 | 146 | ); |
147 | 147 | $this->location = array ( $this->filterLocation ( $url ) ); |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | * @return String |
274 | 274 | */ |
275 | 275 | protected function getParsedTplContents ( $tplFile, $vars = array (), \Classes\Db\DbTable $objTables = null, |
276 | - $objMakeFile = null ) |
|
276 | + $objMakeFile = null ) |
|
277 | 277 | { |
278 | 278 | |
279 | 279 | $arrUrl = array ( |
@@ -99,6 +99,7 @@ discard block |
||
99 | 99 | |
100 | 100 | /** |
101 | 101 | * Analisa os caminhos das pastas base |
102 | + * @param string $basePath |
|
102 | 103 | */ |
103 | 104 | public function parseLocation ( $basePath ) |
104 | 105 | { |
@@ -227,6 +228,9 @@ discard block |
||
227 | 228 | echo "\n\033[1;32mSuccessfully process finished!\n\033[0m"; |
228 | 229 | } |
229 | 230 | |
231 | + /** |
|
232 | + * @param integer $cur |
|
233 | + */ |
|
230 | 234 | private function waitOfDatabase ( &$cur ) |
231 | 235 | { |
232 | 236 | printf ( "\033[1;33mWait, the database is being analyzed..\033[0m\n" ); |
@@ -293,6 +297,7 @@ discard block |
||
293 | 297 | * parse a tpl file and return the result |
294 | 298 | * |
295 | 299 | * @param String $tplFile |
300 | + * @param AbstractAdapter $objMakeFile |
|
296 | 301 | * |
297 | 302 | * @return String |
298 | 303 | */ |
@@ -136,8 +136,7 @@ discard block |
||
136 | 136 | unset( $arrUrl ); |
137 | 137 | } |
138 | 138 | |
139 | - } |
|
140 | - else { |
|
139 | + } else { |
|
141 | 140 | $url = array ( |
142 | 141 | $this->baseLocation, |
143 | 142 | $driverBase, |
@@ -213,8 +212,7 @@ discard block |
||
213 | 212 | ); |
214 | 213 | if ( self::makeSourcer ( $file, $tpl, $objMakeFile->isOverwrite () ) ) { |
215 | 214 | ++$numFilesCreated; |
216 | - } |
|
217 | - else { |
|
215 | + } else { |
|
218 | 216 | ++$numFilesIgnored; |
219 | 217 | } |
220 | 218 |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | /** |
20 | 20 | * @type string[] |
21 | 21 | */ |
22 | - public $location = array (); |
|
22 | + public $location = array(); |
|
23 | 23 | |
24 | 24 | /** |
25 | 25 | * caminho de pastas Base |
@@ -43,42 +43,42 @@ discard block |
||
43 | 43 | |
44 | 44 | private $msgReservedWord = "\033[0mPlease enter the value for reserved word \033[0;31m'%index%' \033[1;33m[%config%]:\033[0m "; |
45 | 45 | |
46 | - public function __construct ( Config $config ) |
|
46 | + public function __construct(Config $config) |
|
47 | 47 | { |
48 | - $this->config = $config->getAdapterConfig (); |
|
49 | - $this->parseReservedWord ( $this->getConfig () ); |
|
50 | - $this->driver = $config->getAdapterDriver ( $this->getConfig () ); |
|
51 | - $this->parseLocation ( $config->_basePath ); |
|
48 | + $this->config = $config->getAdapterConfig(); |
|
49 | + $this->parseReservedWord($this->getConfig()); |
|
50 | + $this->driver = $config->getAdapterDriver($this->getConfig()); |
|
51 | + $this->parseLocation($config->_basePath); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
55 | 55 | * @param AdapterConfig\AbstractAdapter $config |
56 | 56 | */ |
57 | - public function parseReservedWord ( AdapterConfig\AbstractAdapter $config ) |
|
57 | + public function parseReservedWord(AdapterConfig\AbstractAdapter $config) |
|
58 | 58 | { |
59 | 59 | $palavrasReservadas = $config->reservedWord; |
60 | - if ( !$palavrasReservadas ) { |
|
60 | + if ( ! $palavrasReservadas) { |
|
61 | 61 | return; |
62 | 62 | } |
63 | 63 | |
64 | - $schema = $config->getSchemas (); |
|
65 | - $db = $config->getDatabase (); |
|
66 | - $hasSchema = array_intersect ( $schema, array_flip ( $palavrasReservadas ) ); |
|
67 | - $hasDatabase = in_array ( $db, $palavrasReservadas ); |
|
68 | - if ( !( $hasSchema or $hasDatabase ) ) { |
|
64 | + $schema = $config->getSchemas(); |
|
65 | + $db = $config->getDatabase(); |
|
66 | + $hasSchema = array_intersect($schema, array_flip($palavrasReservadas)); |
|
67 | + $hasDatabase = in_array($db, $palavrasReservadas); |
|
68 | + if ( ! ($hasSchema or $hasDatabase)) { |
|
69 | 69 | return; |
70 | 70 | } |
71 | 71 | |
72 | 72 | echo "- database has reserved words\n"; |
73 | - foreach ( $palavrasReservadas as $index => $config ) { |
|
74 | - $attribs = array ( |
|
73 | + foreach ($palavrasReservadas as $index => $config) { |
|
74 | + $attribs = array( |
|
75 | 75 | "%index%" => $index, |
76 | 76 | "%config%" => $config |
77 | 77 | ); |
78 | - echo strtr ( $this->msgReservedWord, $attribs ); |
|
79 | - $line = trim ( fgets ( STDIN ) ); |
|
80 | - if ( !empty( $line ) ) { |
|
81 | - $this->getConfig ()->reservedWord[ $index ] = $line; |
|
78 | + echo strtr($this->msgReservedWord, $attribs); |
|
79 | + $line = trim(fgets(STDIN)); |
|
80 | + if ( ! empty($line)) { |
|
81 | + $this->getConfig()->reservedWord[$index] = $line; |
|
82 | 82 | } |
83 | 83 | } |
84 | 84 | } |
@@ -88,179 +88,179 @@ discard block |
||
88 | 88 | * |
89 | 89 | * @return string |
90 | 90 | */ |
91 | - private function filterLocation ( $arrFoldersName ) |
|
91 | + private function filterLocation($arrFoldersName) |
|
92 | 92 | { |
93 | - foreach ( $arrFoldersName as $index => $folderName ) { |
|
94 | - $arrFoldersName[ $index ] = $this->getConfig () |
|
95 | - ->replaceReservedWord ( $folderName ); |
|
93 | + foreach ($arrFoldersName as $index => $folderName) { |
|
94 | + $arrFoldersName[$index] = $this->getConfig() |
|
95 | + ->replaceReservedWord($folderName); |
|
96 | 96 | } |
97 | 97 | |
98 | - return implode ( DIRECTORY_SEPARATOR, array_filter ( $arrFoldersName ) ); |
|
98 | + return implode(DIRECTORY_SEPARATOR, array_filter($arrFoldersName)); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
102 | 102 | * Analisa os caminhos das pastas base |
103 | 103 | */ |
104 | - public function parseLocation ( $basePath ) |
|
104 | + public function parseLocation($basePath) |
|
105 | 105 | { |
106 | 106 | |
107 | - $arrBase = array ( |
|
107 | + $arrBase = array( |
|
108 | 108 | $basePath, |
109 | 109 | $this->config->path |
110 | 110 | ); |
111 | 111 | |
112 | - $this->baseLocation = $this->filterLocation ( $arrBase ); |
|
112 | + $this->baseLocation = $this->filterLocation($arrBase); |
|
113 | 113 | |
114 | 114 | # pasta com nome do driver do banco |
115 | 115 | $driverBase = ''; |
116 | - if ( (bool) @$this->config->{"folder-database"} ) { |
|
117 | - $classDriver = explode ( '\\', get_class ( $this->driver ) ); |
|
118 | - $driverBase = end ( $classDriver ); |
|
116 | + if ((bool) @$this->config->{"folder-database"} ) { |
|
117 | + $classDriver = explode('\\', get_class($this->driver)); |
|
118 | + $driverBase = end($classDriver); |
|
119 | 119 | } |
120 | 120 | $folderName = ''; |
121 | - if ( (bool) @$this->config->{"folder-name"} ) { |
|
122 | - $folderName = $this->getClassName ( trim ( $this->config->{"folder-name"} ) ); |
|
121 | + if ((bool) @$this->config->{"folder-name"} ) { |
|
122 | + $folderName = $this->getClassName(trim($this->config->{"folder-name"} )); |
|
123 | 123 | } |
124 | 124 | |
125 | - if ( $this->config->hasSchemas () ) { |
|
125 | + if ($this->config->hasSchemas()) { |
|
126 | 126 | |
127 | - $schemas = $this->config->getSchemas (); |
|
128 | - foreach ( $schemas as $schema ) { |
|
129 | - $arrUrl = array ( |
|
127 | + $schemas = $this->config->getSchemas(); |
|
128 | + foreach ($schemas as $schema) { |
|
129 | + $arrUrl = array( |
|
130 | 130 | $this->baseLocation, |
131 | 131 | $driverBase, |
132 | 132 | $folderName, |
133 | - $this->getClassName ( $schema ) |
|
133 | + $this->getClassName($schema) |
|
134 | 134 | ); |
135 | 135 | |
136 | - $this->location[ $schema ] = $this->filterLocation ( $arrUrl ); |
|
137 | - unset( $arrUrl ); |
|
136 | + $this->location[$schema] = $this->filterLocation($arrUrl); |
|
137 | + unset($arrUrl); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | } |
141 | 141 | else { |
142 | - $url = array ( |
|
142 | + $url = array( |
|
143 | 143 | $this->baseLocation, |
144 | 144 | $driverBase, |
145 | 145 | $folderName, |
146 | - $this->getClassName ( |
|
147 | - $this->getConfig () |
|
148 | - ->getDatabase () |
|
146 | + $this->getClassName( |
|
147 | + $this->getConfig() |
|
148 | + ->getDatabase() |
|
149 | 149 | ) |
150 | 150 | ); |
151 | - $this->location = array ( $this->filterLocation ( $url ) ); |
|
152 | - unset( $url ); |
|
151 | + $this->location = array($this->filterLocation($url)); |
|
152 | + unset($url); |
|
153 | 153 | } |
154 | 154 | } |
155 | 155 | |
156 | 156 | /** |
157 | 157 | * @return AdapterConfig\AbstractAdapter |
158 | 158 | */ |
159 | - public function getConfig () |
|
159 | + public function getConfig() |
|
160 | 160 | { |
161 | 161 | return $this->config; |
162 | 162 | } |
163 | 163 | |
164 | 164 | /* Get current time */ |
165 | - public function startTime () |
|
165 | + public function startTime() |
|
166 | 166 | { |
167 | 167 | echo "\033[1;32mStarting..\033[0m\n"; |
168 | - $this->startTime = microtime ( true ); |
|
168 | + $this->startTime = microtime(true); |
|
169 | 169 | } |
170 | 170 | |
171 | - private function getRunTime () |
|
171 | + private function getRunTime() |
|
172 | 172 | { |
173 | - return round ( ( microtime ( true ) - $this->startTime ), 3 ); |
|
173 | + return round((microtime(true) - $this->startTime), 3); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | /** |
177 | 177 | * Executa o Make, criando arquivos e Diretorios |
178 | 178 | */ |
179 | - public function run () |
|
179 | + public function run() |
|
180 | 180 | { |
181 | 181 | $cur = 0; |
182 | 182 | $numFilesCreated = 0; |
183 | 183 | $numFilesIgnored = 0; |
184 | 184 | |
185 | - $this->startTime (); |
|
185 | + $this->startTime(); |
|
186 | 186 | $this->waitOfDatabase($cur); |
187 | 187 | |
188 | - $this->max = $this->driver->getTotalTables () * $this->countDiretory (); |
|
188 | + $this->max = $this->driver->getTotalTables() * $this->countDiretory(); |
|
189 | 189 | |
190 | - foreach ( $this->location as $schema => $location ) { |
|
191 | - foreach ( $this->factoryMakerFile () as $objMakeFile ) { |
|
192 | - $path = $location . DIRECTORY_SEPARATOR . $objMakeFile->getPastName (); |
|
193 | - if($this->config->isCleanTrash()){ |
|
194 | - CleanTrash::getInstance ()->run ( $path , $this->driver, $schema ); |
|
190 | + foreach ($this->location as $schema => $location) { |
|
191 | + foreach ($this->factoryMakerFile() as $objMakeFile) { |
|
192 | + $path = $location . DIRECTORY_SEPARATOR . $objMakeFile->getPastName(); |
|
193 | + if ($this->config->isCleanTrash()) { |
|
194 | + CleanTrash::getInstance()->run($path, $this->driver, $schema); |
|
195 | 195 | } |
196 | - self::makeDir ( $path ); |
|
197 | - if ( $objMakeFile->getParentFileTpl () != '' ) { |
|
196 | + self::makeDir($path); |
|
197 | + if ($objMakeFile->getParentFileTpl() != '') { |
|
198 | 198 | $fileAbstract = $this->baseLocation |
199 | 199 | . DIRECTORY_SEPARATOR |
200 | - . $objMakeFile->getParentClass () |
|
200 | + . $objMakeFile->getParentClass() |
|
201 | 201 | . '.php'; |
202 | 202 | |
203 | - $tplAbstract = $this->getParsedTplContents ( $objMakeFile->getParentFileTpl () ); |
|
204 | - self::makeSourcer ( $fileAbstract, $tplAbstract, true ); |
|
205 | - unset( $fileAbstract, $tplAbstract ); |
|
203 | + $tplAbstract = $this->getParsedTplContents($objMakeFile->getParentFileTpl()); |
|
204 | + self::makeSourcer($fileAbstract, $tplAbstract, true); |
|
205 | + unset($fileAbstract, $tplAbstract); |
|
206 | 206 | } |
207 | 207 | |
208 | - foreach ( $this->driver->getTables ( $schema ) as $key => $objTables ) { |
|
209 | - $file = $path . DIRECTORY_SEPARATOR . self::getClassName ( $objTables->getName () ) . '.php'; |
|
208 | + foreach ($this->driver->getTables($schema) as $key => $objTables) { |
|
209 | + $file = $path . DIRECTORY_SEPARATOR . self::getClassName($objTables->getName()) . '.php'; |
|
210 | 210 | |
211 | - $tpl = $this->getParsedTplContents ( |
|
212 | - $objMakeFile->getFileTpl (), |
|
213 | - $objMakeFile->parseRelation ( $this, $objTables ), |
|
211 | + $tpl = $this->getParsedTplContents( |
|
212 | + $objMakeFile->getFileTpl(), |
|
213 | + $objMakeFile->parseRelation($this, $objTables), |
|
214 | 214 | $objTables, |
215 | 215 | $objMakeFile |
216 | 216 | |
217 | 217 | ); |
218 | - if ( self::makeSourcer ( $file, $tpl, $objMakeFile->isOverwrite () ) ) { |
|
218 | + if (self::makeSourcer($file, $tpl, $objMakeFile->isOverwrite())) { |
|
219 | 219 | ++$numFilesCreated; |
220 | 220 | } |
221 | 221 | else { |
222 | 222 | ++$numFilesIgnored; |
223 | 223 | } |
224 | 224 | |
225 | - $this->countCreatedFiles ( $cur ); |
|
225 | + $this->countCreatedFiles($cur); |
|
226 | 226 | } |
227 | 227 | } |
228 | 228 | } |
229 | 229 | |
230 | - $this->reportProcess ( $numFilesCreated, $numFilesIgnored ); |
|
230 | + $this->reportProcess($numFilesCreated, $numFilesIgnored); |
|
231 | 231 | echo "\n\033[1;32mSuccessfully process finished!\n\033[0m"; |
232 | 232 | } |
233 | 233 | |
234 | - private function waitOfDatabase ( &$cur ) |
|
234 | + private function waitOfDatabase(&$cur) |
|
235 | 235 | { |
236 | - printf ( "\033[1;33mWait, the database is being analyzed..\033[0m\n" ); |
|
237 | - $this->driver->runDatabase (); |
|
238 | - printf ( "\r Creating: \033[1;32m%6.2f%%\033[0m", $cur ); |
|
236 | + printf("\033[1;33mWait, the database is being analyzed..\033[0m\n"); |
|
237 | + $this->driver->runDatabase(); |
|
238 | + printf("\r Creating: \033[1;32m%6.2f%%\033[0m", $cur); |
|
239 | 239 | } |
240 | 240 | |
241 | - private function countCreatedFiles ( &$cur ) |
|
241 | + private function countCreatedFiles(&$cur) |
|
242 | 242 | { |
243 | 243 | ++$cur; |
244 | - $total = ( $cur / $this->max ) * 100; |
|
245 | - printf ( "\r Creating: \033[1;32m%6.2f%%\033[0m", $total ); |
|
244 | + $total = ($cur / $this->max) * 100; |
|
245 | + printf("\r Creating: \033[1;32m%6.2f%%\033[0m", $total); |
|
246 | 246 | } |
247 | 247 | |
248 | - private function reportProcess ( $numFilesCreated = 0, $numFilesIgnored = 0 ) |
|
248 | + private function reportProcess($numFilesCreated = 0, $numFilesIgnored = 0) |
|
249 | 249 | { |
250 | - if ( $this->config->isStatusEnabled () ) { |
|
251 | - $databases = count ( $this->location ); |
|
252 | - $countDir = $this->countDiretory (); |
|
253 | - $totalTable = $this->driver->getTotalTables (); |
|
250 | + if ($this->config->isStatusEnabled()) { |
|
251 | + $databases = count($this->location); |
|
252 | + $countDir = $this->countDiretory(); |
|
253 | + $totalTable = $this->driver->getTotalTables(); |
|
254 | 254 | $totalFiles = $numFilesIgnored + $numFilesCreated; |
255 | - $totalFilesDeleted = CleanTrash::getInstance ()->getNumFilesDeleted(); |
|
255 | + $totalFilesDeleted = CleanTrash::getInstance()->getNumFilesDeleted(); |
|
256 | 256 | echo "\n------"; |
257 | - printf ( "\n\r-Files generated/updated: \033[1;33m%s\033[0m" , $numFilesCreated ); |
|
258 | - printf ( "\n\r-Files not upgradeable: \033[1;33m%s\033[0m" , $numFilesIgnored ); |
|
259 | - printf ( "\n\r-Files deleted: \033[1;33m%s\033[0m" , $totalFilesDeleted ); |
|
260 | - printf ( "\n\r-Total files analyzed: \033[1;33m%s of %s\033[0m" , $totalFiles , $this->max ); |
|
261 | - printf ( "\n\r-Diretories: \033[1;33m%s\033[0m" , $databases * $countDir ); |
|
262 | - printf ( "\n\r-Scanned tables: \033[1;33m%s\033[0m" , $totalTable ); |
|
263 | - printf ( "\n\r-Execution time: \033[1;33m%ssec\033[0m" , $this->getRunTime () ); |
|
257 | + printf("\n\r-Files generated/updated: \033[1;33m%s\033[0m", $numFilesCreated); |
|
258 | + printf("\n\r-Files not upgradeable: \033[1;33m%s\033[0m", $numFilesIgnored); |
|
259 | + printf("\n\r-Files deleted: \033[1;33m%s\033[0m", $totalFilesDeleted); |
|
260 | + printf("\n\r-Total files analyzed: \033[1;33m%s of %s\033[0m", $totalFiles, $this->max); |
|
261 | + printf("\n\r-Diretories: \033[1;33m%s\033[0m", $databases * $countDir); |
|
262 | + printf("\n\r-Scanned tables: \033[1;33m%s\033[0m", $totalTable); |
|
263 | + printf("\n\r-Execution time: \033[1;33m%ssec\033[0m", $this->getRunTime()); |
|
264 | 264 | echo "\n------"; |
265 | 265 | } |
266 | 266 | } |
@@ -270,9 +270,9 @@ discard block |
||
270 | 270 | * |
271 | 271 | * @return AbstractAdapter[] |
272 | 272 | */ |
273 | - public function factoryMakerFile () |
|
273 | + public function factoryMakerFile() |
|
274 | 274 | { |
275 | - return $this->config->getMakeFileInstances (); |
|
275 | + return $this->config->getMakeFileInstances(); |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | /** |
@@ -280,12 +280,12 @@ discard block |
||
280 | 280 | * |
281 | 281 | * @return int |
282 | 282 | */ |
283 | - public function countDiretory () |
|
283 | + public function countDiretory() |
|
284 | 284 | { |
285 | - if ( null === $this->countDir ) { |
|
285 | + if (null === $this->countDir) { |
|
286 | 286 | $this->countDir = 1; |
287 | - foreach ( $this->factoryMakerFile () as $abstractAdapter ) { |
|
288 | - if ( $abstractAdapter->hasDiretory () ) { |
|
287 | + foreach ($this->factoryMakerFile() as $abstractAdapter) { |
|
288 | + if ($abstractAdapter->hasDiretory()) { |
|
289 | 289 | ++$this->countDir; |
290 | 290 | } |
291 | 291 | } |
@@ -302,24 +302,24 @@ discard block |
||
302 | 302 | * |
303 | 303 | * @return String |
304 | 304 | */ |
305 | - protected function getParsedTplContents ( $tplFile, $vars = array (), \Classes\Db\DbTable $objTables = null, |
|
306 | - $objMakeFile = null ) |
|
305 | + protected function getParsedTplContents($tplFile, $vars = array(), \Classes\Db\DbTable $objTables = null, |
|
306 | + $objMakeFile = null) |
|
307 | 307 | { |
308 | 308 | |
309 | - $arrUrl = array ( |
|
309 | + $arrUrl = array( |
|
310 | 310 | __DIR__, |
311 | 311 | 'templates', |
312 | 312 | $this->config->framework, |
313 | 313 | $tplFile |
314 | 314 | ); |
315 | 315 | |
316 | - $filePath = implode ( DIRECTORY_SEPARATOR, filter_var_array ( $arrUrl ) ); |
|
316 | + $filePath = implode(DIRECTORY_SEPARATOR, filter_var_array($arrUrl)); |
|
317 | 317 | |
318 | - extract ( $vars ); |
|
319 | - ob_start (); |
|
318 | + extract($vars); |
|
319 | + ob_start(); |
|
320 | 320 | require $filePath; |
321 | - $data = ob_get_contents (); |
|
322 | - ob_end_clean (); |
|
321 | + $data = ob_get_contents(); |
|
322 | + ob_end_clean(); |
|
323 | 323 | |
324 | 324 | return $data; |
325 | 325 | } |
@@ -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 |