@@ -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 | */ |
@@ -103,31 +103,31 @@ discard block |
||
103 | 103 | $table = $this->getTable ( $table_name, $schema ); |
104 | 104 | if ( $table->hasColumn ( $constrant[ "column_name" ] ) ) { |
105 | 105 | $objConstrant = Constrant::getInstance () |
106 | - ->populate ( |
|
107 | - array ( |
|
108 | - 'constrant' => $constrant[ 'constraint_name' ], |
|
109 | - 'schema' => $constrant[ 'foreign_schema' ], |
|
110 | - 'table' => $constrant[ 'foreign_table' ], |
|
111 | - 'column' => $constrant[ 'foreign_column' ], |
|
112 | - 'database' => $this->database |
|
113 | - ) |
|
114 | - ); |
|
106 | + ->populate ( |
|
107 | + array ( |
|
108 | + 'constrant' => $constrant[ 'constraint_name' ], |
|
109 | + 'schema' => $constrant[ 'foreign_schema' ], |
|
110 | + 'table' => $constrant[ 'foreign_table' ], |
|
111 | + 'column' => $constrant[ 'foreign_column' ], |
|
112 | + 'database' => $this->database |
|
113 | + ) |
|
114 | + ); |
|
115 | 115 | |
116 | 116 | switch ( $constrant[ 'constraint_type' ] ) { |
117 | 117 | case "FOREIGN KEY": |
118 | 118 | $table->getColumn ( $constrant[ "column_name" ] ) |
119 | - ->addRefFk ( $objConstrant ); |
|
119 | + ->addRefFk ( $objConstrant ); |
|
120 | 120 | break; |
121 | 121 | case"PRIMARY KEY": |
122 | 122 | $table->getColumn ( $constrant[ "column_name" ] ) |
123 | - ->setPrimaryKey ( $objConstrant ) |
|
124 | - ->setSequence ( |
|
125 | - $this->getSequence ( |
|
126 | - $table_name, |
|
127 | - $constrant[ "column_name" ], |
|
128 | - $schema |
|
129 | - ) |
|
130 | - ); |
|
123 | + ->setPrimaryKey ( $objConstrant ) |
|
124 | + ->setSequence ( |
|
125 | + $this->getSequence ( |
|
126 | + $table_name, |
|
127 | + $constrant[ "column_name" ], |
|
128 | + $schema |
|
129 | + ) |
|
130 | + ); |
|
131 | 131 | break; |
132 | 132 | } |
133 | 133 | } |
@@ -145,13 +145,13 @@ discard block |
||
145 | 145 | $table = $this->getTable ( $table_name, $schema ); |
146 | 146 | if ( $table->hasColumn ( $constrant[ "foreign_column" ] ) ) { |
147 | 147 | $table->getColumn ( $constrant[ "foreign_column" ] ) |
148 | - ->createDependece ( |
|
149 | - $constrant[ 'constraint_name' ], |
|
150 | - $constrant[ 'table_name' ], |
|
151 | - $constrant[ 'column_name' ], |
|
152 | - $this->database, |
|
153 | - $constrant[ 'table_schema' ] |
|
154 | - ); |
|
148 | + ->createDependece ( |
|
149 | + $constrant[ 'constraint_name' ], |
|
150 | + $constrant[ 'table_name' ], |
|
151 | + $constrant[ 'column_name' ], |
|
152 | + $this->database, |
|
153 | + $constrant[ 'table_schema' ] |
|
154 | + ); |
|
155 | 155 | } |
156 | 156 | } |
157 | 157 | } |
@@ -183,10 +183,10 @@ discard block |
||
183 | 183 | ); |
184 | 184 | |
185 | 185 | $this->getTable ( $key, $schema ) |
186 | - ->addColumn ( $column ) |
|
187 | - ->setNamespace ( |
|
188 | - $this->config->createClassNamespace ( $this->getTable ( $key, $schema ) ) |
|
189 | - ); |
|
186 | + ->addColumn ( $column ) |
|
187 | + ->setNamespace ( |
|
188 | + $this->config->createClassNamespace ( $this->getTable ( $key, $schema ) ) |
|
189 | + ); |
|
190 | 190 | } |
191 | 191 | } |
192 | 192 | |
@@ -254,13 +254,13 @@ discard block |
||
254 | 254 | public function createTable ( $nameTable, $schema = 0 ) |
255 | 255 | { |
256 | 256 | $this->objDbTables[ $schema ][ trim ( $nameTable ) ] = DbTable::getInstance () |
257 | - ->populate ( |
|
258 | - array ( |
|
259 | - 'table' => $nameTable, |
|
260 | - 'schema' => $schema, |
|
261 | - 'database' => $this->database |
|
262 | - ) |
|
263 | - ); |
|
257 | + ->populate ( |
|
258 | + array ( |
|
259 | + 'table' => $nameTable, |
|
260 | + 'schema' => $schema, |
|
261 | + 'database' => $this->database |
|
262 | + ) |
|
263 | + ); |
|
264 | 264 | |
265 | 265 | return $this; |
266 | 266 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | /** |
60 | 60 | * @type \Classes\Db\DbTable[][] |
61 | 61 | */ |
62 | - private $objDbTables = array (); |
|
62 | + private $objDbTables = array(); |
|
63 | 63 | |
64 | 64 | /** |
65 | 65 | * @var AbstractAdapter |
@@ -74,20 +74,20 @@ discard block |
||
74 | 74 | /** |
75 | 75 | * analisa e popula as Foreing keys, Primary keys e dependencias do banco nos objetos |
76 | 76 | */ |
77 | - protected function parseConstrants () |
|
77 | + protected function parseConstrants() |
|
78 | 78 | { |
79 | - foreach ( $this->getListConstrant () as $constrant ) { |
|
80 | - |
|
81 | - $schema = $constrant[ 'table_schema' ]; |
|
82 | - $table_name = $constrant [ 'table_name' ]; |
|
83 | - $this->populateForeignAndPrimaryKeys ( $constrant, $table_name, $schema ); |
|
84 | - unset( $table_name, $schema ); |
|
85 | - |
|
86 | - if ( $constrant[ 'constraint_type' ] == "FOREIGN KEY" ) { |
|
87 | - $schema = $constrant[ 'foreign_schema' ]; |
|
88 | - $table_name = $constrant [ 'foreign_table' ]; |
|
89 | - $this->populateDependece ( $constrant, $table_name, $schema ); |
|
90 | - unset( $table_name, $schema ); |
|
79 | + foreach ($this->getListConstrant() as $constrant) { |
|
80 | + |
|
81 | + $schema = $constrant['table_schema']; |
|
82 | + $table_name = $constrant ['table_name']; |
|
83 | + $this->populateForeignAndPrimaryKeys($constrant, $table_name, $schema); |
|
84 | + unset($table_name, $schema); |
|
85 | + |
|
86 | + if ($constrant['constraint_type'] == "FOREIGN KEY") { |
|
87 | + $schema = $constrant['foreign_schema']; |
|
88 | + $table_name = $constrant ['foreign_table']; |
|
89 | + $this->populateDependece($constrant, $table_name, $schema); |
|
90 | + unset($table_name, $schema); |
|
91 | 91 | } |
92 | 92 | } |
93 | 93 | } |
@@ -97,34 +97,34 @@ discard block |
||
97 | 97 | * @param string $table_name |
98 | 98 | * @param int $schema |
99 | 99 | */ |
100 | - private function populateForeignAndPrimaryKeys ( $constrant, $table_name, $schema = 0 ) |
|
100 | + private function populateForeignAndPrimaryKeys($constrant, $table_name, $schema = 0) |
|
101 | 101 | { |
102 | - if ( $this->hasTable ( $table_name, $schema ) ) { |
|
103 | - $table = $this->getTable ( $table_name, $schema ); |
|
104 | - if ( $table->hasColumn ( $constrant[ "column_name" ] ) ) { |
|
105 | - $objConstrant = Constrant::getInstance () |
|
106 | - ->populate ( |
|
107 | - array ( |
|
108 | - 'constrant' => $constrant[ 'constraint_name' ], |
|
109 | - 'schema' => $constrant[ 'foreign_schema' ], |
|
110 | - 'table' => $constrant[ 'foreign_table' ], |
|
111 | - 'column' => $constrant[ 'foreign_column' ], |
|
102 | + if ($this->hasTable($table_name, $schema)) { |
|
103 | + $table = $this->getTable($table_name, $schema); |
|
104 | + if ($table->hasColumn($constrant["column_name"])) { |
|
105 | + $objConstrant = Constrant::getInstance() |
|
106 | + ->populate( |
|
107 | + array( |
|
108 | + 'constrant' => $constrant['constraint_name'], |
|
109 | + 'schema' => $constrant['foreign_schema'], |
|
110 | + 'table' => $constrant['foreign_table'], |
|
111 | + 'column' => $constrant['foreign_column'], |
|
112 | 112 | 'database' => $this->database |
113 | 113 | ) |
114 | 114 | ); |
115 | 115 | |
116 | - switch ( $constrant[ 'constraint_type' ] ) { |
|
116 | + switch ($constrant['constraint_type']) { |
|
117 | 117 | case "FOREIGN KEY": |
118 | - $table->getColumn ( $constrant[ "column_name" ] ) |
|
119 | - ->addRefFk ( $objConstrant ); |
|
118 | + $table->getColumn($constrant["column_name"]) |
|
119 | + ->addRefFk($objConstrant); |
|
120 | 120 | break; |
121 | 121 | case"PRIMARY KEY": |
122 | - $table->getColumn ( $constrant[ "column_name" ] ) |
|
123 | - ->setPrimaryKey ( $objConstrant ) |
|
124 | - ->setSequence ( |
|
125 | - $this->getSequence ( |
|
122 | + $table->getColumn($constrant["column_name"]) |
|
123 | + ->setPrimaryKey($objConstrant) |
|
124 | + ->setSequence( |
|
125 | + $this->getSequence( |
|
126 | 126 | $table_name, |
127 | - $constrant[ "column_name" ], |
|
127 | + $constrant["column_name"], |
|
128 | 128 | $schema |
129 | 129 | ) |
130 | 130 | ); |
@@ -139,18 +139,18 @@ discard block |
||
139 | 139 | * @param string $table_name |
140 | 140 | * @param int $schema |
141 | 141 | */ |
142 | - private function populateDependece ( $constrant, $table_name, $schema = 0 ) |
|
142 | + private function populateDependece($constrant, $table_name, $schema = 0) |
|
143 | 143 | { |
144 | - if ( $this->hasTable ( $table_name, $schema ) ) { |
|
145 | - $table = $this->getTable ( $table_name, $schema ); |
|
146 | - if ( $table->hasColumn ( $constrant[ "foreign_column" ] ) ) { |
|
147 | - $table->getColumn ( $constrant[ "foreign_column" ] ) |
|
148 | - ->createDependece ( |
|
149 | - $constrant[ 'constraint_name' ], |
|
150 | - $constrant[ 'table_name' ], |
|
151 | - $constrant[ 'column_name' ], |
|
144 | + if ($this->hasTable($table_name, $schema)) { |
|
145 | + $table = $this->getTable($table_name, $schema); |
|
146 | + if ($table->hasColumn($constrant["foreign_column"])) { |
|
147 | + $table->getColumn($constrant["foreign_column"]) |
|
148 | + ->createDependece( |
|
149 | + $constrant['constraint_name'], |
|
150 | + $constrant['table_name'], |
|
151 | + $constrant['column_name'], |
|
152 | 152 | $this->database, |
153 | - $constrant[ 'table_schema' ] |
|
153 | + $constrant['table_schema'] |
|
154 | 154 | ); |
155 | 155 | } |
156 | 156 | } |
@@ -159,33 +159,33 @@ discard block |
||
159 | 159 | /** |
160 | 160 | * cria um Array com nome das tabelas |
161 | 161 | */ |
162 | - public function parseTables () |
|
162 | + public function parseTables() |
|
163 | 163 | { |
164 | - if ( $this->hasTables () ) { |
|
165 | - return $this->getAllTables (); |
|
164 | + if ($this->hasTables()) { |
|
165 | + return $this->getAllTables(); |
|
166 | 166 | } |
167 | 167 | |
168 | - foreach ( $this->getListColumns () as $table ) { |
|
169 | - $schema = $table[ 'table_schema' ]; |
|
170 | - $key = $table [ 'table_name' ]; |
|
171 | - if ( !$this->hasTable ( $key, $schema ) ) { |
|
172 | - $this->createTable ( $key, $schema ); |
|
168 | + foreach ($this->getListColumns() as $table) { |
|
169 | + $schema = $table['table_schema']; |
|
170 | + $key = $table ['table_name']; |
|
171 | + if ( ! $this->hasTable($key, $schema)) { |
|
172 | + $this->createTable($key, $schema); |
|
173 | 173 | } |
174 | 174 | |
175 | - $column = Column::getInstance () |
|
176 | - ->populate ( |
|
177 | - array ( |
|
178 | - 'name' => $table [ 'column_name' ], |
|
179 | - 'type' => $this->convertTypeToSimple ( $table[ 'data_type' ] ), |
|
180 | - 'nullable' => ( $table[ 'is_nullable' ] == 'YES' ), |
|
181 | - 'max_length' => $table[ 'max_length' ] |
|
175 | + $column = Column::getInstance() |
|
176 | + ->populate( |
|
177 | + array( |
|
178 | + 'name' => $table ['column_name'], |
|
179 | + 'type' => $this->convertTypeToSimple($table['data_type']), |
|
180 | + 'nullable' => ($table['is_nullable'] == 'YES'), |
|
181 | + 'max_length' => $table['max_length'] |
|
182 | 182 | ) |
183 | 183 | ); |
184 | 184 | |
185 | - $this->getTable ( $key, $schema ) |
|
186 | - ->addColumn ( $column ) |
|
187 | - ->setNamespace ( |
|
188 | - $this->config->createClassNamespace ( $this->getTable ( $key, $schema ) ) |
|
185 | + $this->getTable($key, $schema) |
|
186 | + ->addColumn($column) |
|
187 | + ->setNamespace( |
|
188 | + $this->config->createClassNamespace($this->getTable($key, $schema)) |
|
189 | 189 | ); |
190 | 190 | } |
191 | 191 | } |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | * |
196 | 196 | * @return int |
197 | 197 | */ |
198 | - abstract public function getTotalTables (); |
|
198 | + abstract public function getTotalTables(); |
|
199 | 199 | |
200 | 200 | /** |
201 | 201 | * Retorna o Nome da Sequence da tabela |
@@ -205,31 +205,31 @@ discard block |
||
205 | 205 | * |
206 | 206 | * @return string |
207 | 207 | */ |
208 | - abstract public function getSequence ( $table, $column, $schema = 0 ); |
|
208 | + abstract public function getSequence($table, $column, $schema = 0); |
|
209 | 209 | |
210 | 210 | /** |
211 | 211 | * @return array |
212 | 212 | */ |
213 | - abstract public function getListConstrant (); |
|
213 | + abstract public function getListConstrant(); |
|
214 | 214 | |
215 | 215 | /** |
216 | 216 | * @param string $str |
217 | 217 | * |
218 | 218 | * @return string |
219 | 219 | */ |
220 | - protected function convertTypeToPhp ( $str ) |
|
220 | + protected function convertTypeToPhp($str) |
|
221 | 221 | { |
222 | - if ( isset( $this->dataTypesToPhp[ $str ] ) ) { |
|
223 | - return $this->dataTypesToPhp[ $str ]; |
|
222 | + if (isset($this->dataTypesToPhp[$str])) { |
|
223 | + return $this->dataTypesToPhp[$str]; |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | return 'string'; |
227 | 227 | } |
228 | 228 | |
229 | - protected function convertTypeToSimple ( $str ) |
|
229 | + protected function convertTypeToSimple($str) |
|
230 | 230 | { |
231 | - if ( isset( $this->dataTypesToSimple[ $str ] ) ) { |
|
232 | - return $this->dataTypesToSimple[ $str ]; |
|
231 | + if (isset($this->dataTypesToSimple[$str])) { |
|
232 | + return $this->dataTypesToSimple[$str]; |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | return 'string'; |
@@ -238,12 +238,12 @@ discard block |
||
238 | 238 | /** |
239 | 239 | * @return string |
240 | 240 | */ |
241 | - abstract public function getPDOString (); |
|
241 | + abstract public function getPDOString(); |
|
242 | 242 | |
243 | 243 | /** |
244 | 244 | * @return string |
245 | 245 | */ |
246 | - abstract public function getPDOSocketString (); |
|
246 | + abstract public function getPDOSocketString(); |
|
247 | 247 | |
248 | 248 | /** |
249 | 249 | * @param $nameTable |
@@ -251,11 +251,11 @@ discard block |
||
251 | 251 | * |
252 | 252 | * @return \Classes\Db\DbTable |
253 | 253 | */ |
254 | - public function createTable ( $nameTable, $schema = 0 ) |
|
254 | + public function createTable($nameTable, $schema = 0) |
|
255 | 255 | { |
256 | - $this->objDbTables[ $schema ][ trim ( $nameTable ) ] = DbTable::getInstance () |
|
257 | - ->populate ( |
|
258 | - array ( |
|
256 | + $this->objDbTables[$schema][trim($nameTable)] = DbTable::getInstance() |
|
257 | + ->populate( |
|
258 | + array( |
|
259 | 259 | 'table' => $nameTable, |
260 | 260 | 'schema' => $schema, |
261 | 261 | 'database' => $this->database |
@@ -270,23 +270,23 @@ discard block |
||
270 | 270 | * |
271 | 271 | * @return \Classes\Db\DbTable[] |
272 | 272 | */ |
273 | - public function getTables ( $schema = 0 ) |
|
273 | + public function getTables($schema = 0) |
|
274 | 274 | { |
275 | - if ( !isset( $this->objDbTables[ $schema ] ) ) { |
|
276 | - return array (); |
|
275 | + if ( ! isset($this->objDbTables[$schema])) { |
|
276 | + return array(); |
|
277 | 277 | } |
278 | 278 | |
279 | - return $this->objDbTables[ $schema ]; |
|
279 | + return $this->objDbTables[$schema]; |
|
280 | 280 | } |
281 | 281 | |
282 | - public function getAllTables () |
|
282 | + public function getAllTables() |
|
283 | 283 | { |
284 | 284 | return $this->objDbTables; |
285 | 285 | } |
286 | 286 | |
287 | - public function hasTables () |
|
287 | + public function hasTables() |
|
288 | 288 | { |
289 | - return !empty( $this->objDbTables ); |
|
289 | + return ! empty($this->objDbTables); |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | /** |
@@ -296,9 +296,9 @@ discard block |
||
296 | 296 | * |
297 | 297 | * @return \Classes\Db\DbTable |
298 | 298 | */ |
299 | - public function getTable ( $nameTable, $schema = 0 ) |
|
299 | + public function getTable($nameTable, $schema = 0) |
|
300 | 300 | { |
301 | - return $this->objDbTables[ $schema ][ trim ( $nameTable ) ]; |
|
301 | + return $this->objDbTables[$schema][trim($nameTable)]; |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | /** |
@@ -307,9 +307,9 @@ discard block |
||
307 | 307 | * |
308 | 308 | * @return bool |
309 | 309 | */ |
310 | - public function hasTable ( $nameTable, $schema = 0 ) |
|
310 | + public function hasTable($nameTable, $schema = 0) |
|
311 | 311 | { |
312 | - return isset( $this->objDbTables[ $schema ][ trim ( $nameTable ) ] ); |
|
312 | + return isset($this->objDbTables[$schema][trim($nameTable)]); |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | /** |
@@ -317,59 +317,59 @@ discard block |
||
317 | 317 | * |
318 | 318 | * @return array[] |
319 | 319 | */ |
320 | - abstract public function getListColumns (); |
|
320 | + abstract public function getListColumns(); |
|
321 | 321 | |
322 | 322 | /** |
323 | 323 | * Retorna um Array com nome das tabelas |
324 | 324 | * |
325 | 325 | * @return string[] |
326 | 326 | */ |
327 | - abstract public function getListNameTable (); |
|
327 | + abstract public function getListNameTable(); |
|
328 | 328 | |
329 | 329 | /** |
330 | 330 | * @param \Classes\AdapterConfig\AbstractAdapter $adapterConfig |
331 | 331 | */ |
332 | - public function __construct ( AbstractAdapter $adapterConfig ) |
|
332 | + public function __construct(AbstractAdapter $adapterConfig) |
|
333 | 333 | { |
334 | 334 | $this->config = $adapterConfig; |
335 | - $this->host = $adapterConfig->getHost (); |
|
336 | - $this->database = $adapterConfig->getDatabase (); |
|
337 | - $this->port = $adapterConfig->hasPort () ? $adapterConfig->getPort () : $this->port; |
|
338 | - $this->username = $adapterConfig->getUser (); |
|
339 | - $this->password = $adapterConfig->getPassword (); |
|
340 | - $this->socket = $adapterConfig->getSocket (); |
|
335 | + $this->host = $adapterConfig->getHost(); |
|
336 | + $this->database = $adapterConfig->getDatabase(); |
|
337 | + $this->port = $adapterConfig->hasPort() ? $adapterConfig->getPort() : $this->port; |
|
338 | + $this->username = $adapterConfig->getUser(); |
|
339 | + $this->password = $adapterConfig->getPassword(); |
|
340 | + $this->socket = $adapterConfig->getSocket(); |
|
341 | 341 | |
342 | 342 | } |
343 | 343 | |
344 | 344 | /** |
345 | 345 | * Executa as consultas do banco de dados |
346 | 346 | */ |
347 | - public function runDatabase () |
|
347 | + public function runDatabase() |
|
348 | 348 | { |
349 | - $this->parseTables (); |
|
350 | - $this->parseConstrants (); |
|
349 | + $this->parseTables(); |
|
350 | + $this->parseConstrants(); |
|
351 | 351 | } |
352 | 352 | |
353 | 353 | /** |
354 | 354 | * |
355 | 355 | * @return \PDO |
356 | 356 | */ |
357 | - public function getPDO () |
|
357 | + public function getPDO() |
|
358 | 358 | { |
359 | - if ( is_null ( $this->_pdo ) ) { |
|
360 | - if ( !empty( $this->socket ) ) { |
|
361 | - $pdoString = $this->getPDOSocketString (); |
|
359 | + if (is_null($this->_pdo)) { |
|
360 | + if ( ! empty($this->socket)) { |
|
361 | + $pdoString = $this->getPDOSocketString(); |
|
362 | 362 | } |
363 | 363 | else { |
364 | - $pdoString = $this->getPDOString (); |
|
364 | + $pdoString = $this->getPDOString(); |
|
365 | 365 | } |
366 | 366 | |
367 | 367 | try { |
368 | - $this->_pdo = new \PDO ( |
|
368 | + $this->_pdo = new \PDO( |
|
369 | 369 | $pdoString, $this->username, $this->password |
370 | 370 | ); |
371 | - } catch ( \Exception $e ) { |
|
372 | - die ( "pdo error: " . $e->getMessage () . "\n" ); |
|
371 | + } catch (\Exception $e) { |
|
372 | + die ("pdo error: " . $e->getMessage() . "\n"); |
|
373 | 373 | } |
374 | 374 | } |
375 | 375 |
@@ -359,8 +359,7 @@ |
||
359 | 359 | if ( is_null ( $this->_pdo ) ) { |
360 | 360 | if ( !empty( $this->socket ) ) { |
361 | 361 | $pdoString = $this->getPDOSocketString (); |
362 | - } |
|
363 | - else { |
|
362 | + } else { |
|
364 | 363 | $pdoString = $this->getPDOString (); |
365 | 364 | } |
366 | 365 |
@@ -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 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?= "<?php\n" ?> |
2 | -<?php $className = $objTables->getNamespace () . '_Entity_' . \Classes\Maker\AbstractMaker::getClassName ( |
|
3 | - $objTables->getName () |
|
2 | +<?php $className = $objTables->getNamespace() . '_Entity_' . \Classes\Maker\AbstractMaker::getClassName( |
|
3 | + $objTables->getName() |
|
4 | 4 | ) ?> |
5 | 5 | |
6 | 6 | /** |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * |
9 | 9 | * <?= $this->config->last_modify . "\n" ?> |
10 | 10 | * |
11 | -* @package <?= $objTables->getNamespace () . "\n" ?> |
|
11 | +* @package <?= $objTables->getNamespace() . "\n" ?> |
|
12 | 12 | * @subpackage Entity |
13 | 13 | * |
14 | 14 | * @author <?= $this->config->author . "\n" ?> |
@@ -24,16 +24,16 @@ discard block |
||
24 | 24 | */ |
25 | 25 | |
26 | 26 | abstract class <?= $className ?> extends <?= $this->config->namespace ? $this->config->namespace |
27 | - . "_" : "" ?>Model_<?= $objMakeFile->getParentClass ( |
|
27 | + . "_" : "" ?>Model_<?= $objMakeFile->getParentClass( |
|
28 | 28 | ) . "\n" ?> |
29 | 29 | { |
30 | 30 | |
31 | -<?php foreach ( $objTables->getColumns () as $column ): ?> |
|
31 | +<?php foreach ($objTables->getColumns() as $column): ?> |
|
32 | 32 | /** |
33 | - * Database constraint in the column <?= $column->getName () . "\n" ?> |
|
33 | + * Database constraint in the column <?= $column->getName() . "\n" ?> |
|
34 | 34 | * |
35 | 35 | */ |
36 | - const <?= strtoupper ( $column->getName () ) ?> = '<?= $objTables->getName () ?>.<?= $column->getName () ?>'; |
|
36 | + const <?= strtoupper($column->getName()) ?> = '<?= $objTables->getName() ?>.<?= $column->getName() ?>'; |
|
37 | 37 | <?php endforeach; ?> |
38 | 38 | |
39 | 39 | /** |
@@ -42,17 +42,17 @@ discard block |
||
42 | 42 | * @var string |
43 | 43 | * @access protected |
44 | 44 | */ |
45 | -protected $_tableClass = '<?= $objTables->getNamespace () ?>_DbTable_<?= \Classes\Maker\AbstractMaker::getClassName ( |
|
46 | - $objTables->getName () |
|
45 | +protected $_tableClass = '<?= $objTables->getNamespace() ?>_DbTable_<?= \Classes\Maker\AbstractMaker::getClassName( |
|
46 | + $objTables->getName() |
|
47 | 47 | ) ?>'; |
48 | 48 | |
49 | 49 | /** |
50 | 50 | * @see <?= $this->config->namespace ?>Model_EntityAbstract::$_columnsList |
51 | 51 | */ |
52 | 52 | protected $_columnsList = array( |
53 | -<?php foreach ( $objTables->getColumns () as $column ): ?> |
|
54 | - self::<?= strtoupper ( $column->getName () ) ?> => '<?= strtolower ( |
|
55 | - \Classes\Maker\AbstractMaker::getClassName ( $column->getName () ) |
|
53 | +<?php foreach ($objTables->getColumns() as $column): ?> |
|
54 | + self::<?= strtoupper($column->getName()) ?> => '<?= strtolower( |
|
55 | + \Classes\Maker\AbstractMaker::getClassName($column->getName()) |
|
56 | 56 | ) ?>', |
57 | 57 | <?php endforeach; ?> |
58 | 58 | ); |
@@ -61,10 +61,10 @@ discard block |
||
61 | 61 | * @see <?= $this->config->namespace ?>Model_EntityAbstract::$_filters |
62 | 62 | */ |
63 | 63 | protected $_filters = array( |
64 | -<?php foreach ( $objTables->getColumns () as $column ): ?> |
|
64 | +<?php foreach ($objTables->getColumns() as $column): ?> |
|
65 | 65 | <?php |
66 | 66 | $filters = null; |
67 | - switch ( ucfirst ( $column->getType () ) ) { |
|
67 | + switch (ucfirst($column->getType())) { |
|
68 | 68 | case 'String': |
69 | 69 | $filters = 'StripTags", "StringTrim'; |
70 | 70 | break; |
@@ -74,12 +74,12 @@ discard block |
||
74 | 74 | case 'Date': |
75 | 75 | break; |
76 | 76 | default: |
77 | - $filters = ucfirst ( $column->getType () ); |
|
77 | + $filters = ucfirst($column->getType()); |
|
78 | 78 | break; |
79 | 79 | } |
80 | 80 | ?> |
81 | - '<?= $column->getName () ?>'=>array ( |
|
82 | - <?= ( !empty( $filters ) ) ? "\"{$filters}\"\n" : null; ?> |
|
81 | + '<?= $column->getName() ?>'=>array ( |
|
82 | + <?= ( ! empty($filters)) ? "\"{$filters}\"\n" : null; ?> |
|
83 | 83 | ), |
84 | 84 | <?php endforeach; ?> |
85 | 85 | ); |
@@ -88,34 +88,34 @@ discard block |
||
88 | 88 | * @see <?= $this->config->namespace ?>Model_EntityAbstract::$_validators |
89 | 89 | */ |
90 | 90 | protected $_validators= array( |
91 | -<?php foreach ( $objTables->getColumns () as $column ): ?> |
|
91 | +<?php foreach ($objTables->getColumns() as $column): ?> |
|
92 | 92 | <?php |
93 | - $validators = array (); |
|
93 | + $validators = array(); |
|
94 | 94 | |
95 | - $validators[] = $column->isNullable () ? "'allowEmpty' => true" : "'NotEmpty'"; |
|
95 | + $validators[] = $column->isNullable() ? "'allowEmpty' => true" : "'NotEmpty'"; |
|
96 | 96 | |
97 | - switch ( ucfirst ( $column->getType () ) ) { |
|
97 | + switch (ucfirst($column->getType())) { |
|
98 | 98 | case 'String': |
99 | - if ( $column->getMaxLength () ) { |
|
100 | - $validators[] = "array( 'StringLength', array( 'max' => " . $column->getMaxLength () . " ) )"; |
|
99 | + if ($column->getMaxLength()) { |
|
100 | + $validators[] = "array( 'StringLength', array( 'max' => " . $column->getMaxLength() . " ) )"; |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | break; |
104 | 104 | case 'Boolean': |
105 | 105 | break; |
106 | 106 | default: |
107 | - $name = ucfirst ( $column->getType () ); |
|
107 | + $name = ucfirst($column->getType()); |
|
108 | 108 | $validators[] = "'$name'"; |
109 | 109 | break; |
110 | 110 | } |
111 | - $validators = implode ( ", ", $validators ) ?> |
|
112 | - '<?= $column->getName () ?>' => array ( |
|
113 | - <?= ( !empty( $validators ) ) ? "{$validators}\n" : null ?> |
|
111 | + $validators = implode(", ", $validators) ?> |
|
112 | + '<?= $column->getName() ?>' => array ( |
|
113 | + <?= ( ! empty($validators)) ? "{$validators}\n" : null ?> |
|
114 | 114 | ), |
115 | 115 | <?php endforeach; ?> |
116 | 116 | ); |
117 | 117 | |
118 | -<?php if ( $objTables->hasPrimaryKey () ): ?> |
|
118 | +<?php if ($objTables->hasPrimaryKey()): ?> |
|
119 | 119 | /** |
120 | 120 | * Nome da Primary Key |
121 | 121 | * |
@@ -124,78 +124,78 @@ discard block |
||
124 | 124 | */ |
125 | 125 | |
126 | 126 | protected $_primary = array( |
127 | - <?php foreach ( $objTables->getPrimarykeys () as $pks ) : ?> |
|
128 | - '<?= $pks->getName () ?>', |
|
127 | + <?php foreach ($objTables->getPrimarykeys() as $pks) : ?> |
|
128 | + '<?= $pks->getName() ?>', |
|
129 | 129 | <?php endforeach ?> |
130 | 130 | ); |
131 | 131 | <?php endif ?> |
132 | 132 | |
133 | -<?php foreach ( $parents as $parent ): ?> |
|
133 | +<?php foreach ($parents as $parent): ?> |
|
134 | 134 | /** |
135 | - * Parent relation <?= \Classes\Maker\AbstractMaker::getClassName ( $parent[ 'table' ] ) . "\n" ?> |
|
135 | + * Parent relation <?= \Classes\Maker\AbstractMaker::getClassName($parent['table']) . "\n" ?> |
|
136 | 136 | * |
137 | - * @var <?= $parent[ 'name' ] . "\n" ?> |
|
137 | + * @var <?= $parent['name'] . "\n" ?> |
|
138 | 138 | */ |
139 | - protected $_parent_<?= $parent[ 'name' ] ?>; |
|
139 | + protected $_parent_<?= $parent['name'] ?>; |
|
140 | 140 | |
141 | 141 | <?php endforeach; ?> |
142 | -<?php foreach ( $depends as $depend ): ?> |
|
142 | +<?php foreach ($depends as $depend): ?> |
|
143 | 143 | /** |
144 | - * Depends relation <?= \Classes\Maker\AbstractMaker::getClassName ( $depend[ 'table' ] ) . "\n" ?> |
|
144 | + * Depends relation <?= \Classes\Maker\AbstractMaker::getClassName($depend['table']) . "\n" ?> |
|
145 | 145 | * |
146 | - * @var <?= $depend[ 'class' ] . "\n" ?> |
|
146 | + * @var <?= $depend['class'] . "\n" ?> |
|
147 | 147 | */ |
148 | - protected $_depend_<?= $depend[ 'name' ] ?>; |
|
148 | + protected $_depend_<?= $depend['name'] ?>; |
|
149 | 149 | |
150 | 150 | <?php endforeach; ?> |
151 | -<?php foreach ( $objTables->getColumns () as $column ): ?> |
|
151 | +<?php foreach ($objTables->getColumns() as $column): ?> |
|
152 | 152 | /** |
153 | 153 | * |
154 | - * Sets column <?= $column->getName () . "\n" ?> |
|
154 | + * Sets column <?= $column->getName() . "\n" ?> |
|
155 | 155 | * |
156 | - <?php if ( $column->equalType ( 'date' ) ): ?> |
|
156 | + <?php if ($column->equalType('date')): ?> |
|
157 | 157 | * Stored in ISO 8601 format. |
158 | 158 | * |
159 | - * @param string|Zend_Date $<?= $column->getName () . "\n" ?> |
|
159 | + * @param string|Zend_Date $<?= $column->getName() . "\n" ?> |
|
160 | 160 | <?php else: ?> |
161 | - * @param <?= $column->getType () ?> $<?= $column->getName () . "\n" ?> |
|
161 | + * @param <?= $column->getType() ?> $<?= $column->getName() . "\n" ?> |
|
162 | 162 | <?php endif; ?> |
163 | 163 | * @return <?= $className . "\n" ?> |
164 | 164 | */ |
165 | - public function set<?= \Classes\Maker\AbstractMaker::getClassName ( $column->getName () ) ?>($<?= $column->getName ( |
|
165 | + public function set<?= \Classes\Maker\AbstractMaker::getClassName($column->getName()) ?>($<?= $column->getName( |
|
166 | 166 | ) ?>) |
167 | 167 | { |
168 | - <?php switch ( $column->getType () ): |
|
168 | + <?php switch ($column->getType()): |
|
169 | 169 | case 'date': ?> |
170 | - if (! empty($<?= $column->getName () ?>)) |
|
170 | + if (! empty($<?= $column->getName() ?>)) |
|
171 | 171 | { |
172 | - if (! $<?= $column->getName () ?> instanceof Zend_Date) |
|
172 | + if (! $<?= $column->getName() ?> instanceof Zend_Date) |
|
173 | 173 | { |
174 | - $<?= $column->getName () ?> = new Zend_Date($<?= $column->getName () ?>); |
|
174 | + $<?= $column->getName() ?> = new Zend_Date($<?= $column->getName() ?>); |
|
175 | 175 | } |
176 | 176 | |
177 | - $this-><?= $column->getName () ?> = $<?= $column->getName () ?>->toString(Zend_Date::ISO_8601); |
|
177 | + $this-><?= $column->getName() ?> = $<?= $column->getName() ?>->toString(Zend_Date::ISO_8601); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | <?php break ?> |
181 | 181 | <?php case 'boolean': ?> |
182 | - $this-><?= $column->getName () ?> = $<?= $column->getName () ?> ? true : false; |
|
182 | + $this-><?= $column->getName() ?> = $<?= $column->getName() ?> ? true : false; |
|
183 | 183 | |
184 | 184 | <?php break ?> |
185 | 185 | <?php default: ?> |
186 | - $<?= $column->getName () ?> = (<?= ucfirst ( $column->getType () ) ?>) $<?= $column->getName () ?> ; |
|
187 | - $input = new Zend_Filter_Input($this->_filters, $this->_validators, array('<?= $column->getName ( |
|
188 | - ) ?>'=>$<?= $column->getName () ?> )); |
|
189 | - if(!$input->isValid ('<?= $column->getName () ?>')) |
|
186 | + $<?= $column->getName() ?> = (<?= ucfirst($column->getType()) ?>) $<?= $column->getName() ?> ; |
|
187 | + $input = new Zend_Filter_Input($this->_filters, $this->_validators, array('<?= $column->getName( |
|
188 | + ) ?>'=>$<?= $column->getName() ?> )); |
|
189 | + if(!$input->isValid ('<?= $column->getName() ?>')) |
|
190 | 190 | { |
191 | 191 | $errors = $input->getMessages (); |
192 | - foreach ( $errors['<?= $column->getName () ?>'] as $key => $value ) |
|
192 | + foreach ( $errors['<?= $column->getName() ?>'] as $key => $value ) |
|
193 | 193 | { |
194 | 194 | throw new Exception ( $value ); |
195 | 195 | } |
196 | 196 | } |
197 | 197 | |
198 | - $this-><?= $column->getName () ?> = $<?= $column->getName () ?> ; |
|
198 | + $this-><?= $column->getName() ?> = $<?= $column->getName() ?> ; |
|
199 | 199 | |
200 | 200 | <?php break ?> |
201 | 201 | <?php endswitch ?> |
@@ -203,72 +203,72 @@ discard block |
||
203 | 203 | } |
204 | 204 | |
205 | 205 | /** |
206 | - * Gets column <?= $column->getName () . "\n" ?> |
|
206 | + * Gets column <?= $column->getName() . "\n" ?> |
|
207 | 207 | * |
208 | - <?php if ( $column->equalType ( 'date' ) ): ?> |
|
208 | + <?php if ($column->equalType('date')): ?> |
|
209 | 209 | * @param boolean $returnZendDate |
210 | 210 | * @return Zend_Date|null|string Zend_Date representation of this datetime if enabled, or ISO 8601 string if not |
211 | 211 | <?php else: ?> |
212 | - * @return <?= $column->getType () . "\n" ?> |
|
212 | + * @return <?= $column->getType() . "\n" ?> |
|
213 | 213 | <?php endif; ?> |
214 | 214 | */ |
215 | - public function get<?= \Classes\Maker\AbstractMaker::getClassName ( |
|
216 | - $column->getName () |
|
217 | - ) ?>(<?php if ( $column->equalType ( 'date' ) ): ?>$returnZendDate = false <?php endif; ?>) |
|
215 | + public function get<?= \Classes\Maker\AbstractMaker::getClassName( |
|
216 | + $column->getName() |
|
217 | + ) ?>(<?php if ($column->equalType('date')): ?>$returnZendDate = false <?php endif; ?>) |
|
218 | 218 | { |
219 | - <?php if ( $column->equalType ( 'date' ) ): ?> |
|
219 | + <?php if ($column->equalType('date')): ?> |
|
220 | 220 | if ($returnZendDate) |
221 | 221 | { |
222 | - if ($this->_data['<?= $column->getName () ?>'] === null) |
|
222 | + if ($this->_data['<?= $column->getName() ?>'] === null) |
|
223 | 223 | { |
224 | 224 | return null; |
225 | 225 | } |
226 | 226 | |
227 | - return new Zend_Date($this-><?= $column->getName () ?>, Zend_Date::ISO_8601); |
|
227 | + return new Zend_Date($this-><?= $column->getName() ?>, Zend_Date::ISO_8601); |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | <?php endif; ?> |
231 | - return $this-><?= $column->getName () ?>; |
|
231 | + return $this-><?= $column->getName() ?>; |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | <?php endforeach; ?> |
235 | -<?php foreach ( $parents as $parent ): ?> |
|
235 | +<?php foreach ($parents as $parent): ?> |
|
236 | 236 | /** |
237 | - * Gets parent <?= $parent[ 'table' ] . "\n" ?> |
|
237 | + * Gets parent <?= $parent['table'] . "\n" ?> |
|
238 | 238 | * |
239 | - * @return <?= $parent[ 'class' ] . "\n" ?> |
|
239 | + * @return <?= $parent['class'] . "\n" ?> |
|
240 | 240 | */ |
241 | - public function get<?= $parent[ 'function' ] ?>() |
|
241 | + public function get<?= $parent['function'] ?>() |
|
242 | 242 | { |
243 | - if ($this->_parent_<?= $parent[ 'name' ] ?> === null) |
|
243 | + if ($this->_parent_<?= $parent['name'] ?> === null) |
|
244 | 244 | { |
245 | - $this->_parent_<?= $parent[ 'name' ] ?> = $this->findParentRow('<?= $objTables->getNamespace ( |
|
246 | - ) ?>_DbTable_<?= \Classes\Maker\AbstractMaker::getClassName ( |
|
247 | - $parent[ 'table' ] |
|
248 | - ) ?>', '<?= \Classes\Maker\AbstractMaker::getClassName ( $parent[ 'name' ] ) ?>'); |
|
245 | + $this->_parent_<?= $parent['name'] ?> = $this->findParentRow('<?= $objTables->getNamespace( |
|
246 | + ) ?>_DbTable_<?= \Classes\Maker\AbstractMaker::getClassName( |
|
247 | + $parent['table'] |
|
248 | + ) ?>', '<?= \Classes\Maker\AbstractMaker::getClassName($parent['name']) ?>'); |
|
249 | 249 | } |
250 | 250 | |
251 | - return $this->_parent_<?= $parent[ 'name' ] ?>; |
|
251 | + return $this->_parent_<?= $parent['name'] ?>; |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | <?php endforeach; ?> |
255 | 255 | |
256 | 256 | |
257 | -<?php foreach ( $depends as $depend ): ?> |
|
257 | +<?php foreach ($depends as $depend): ?> |
|
258 | 258 | /** |
259 | - * Gets dependent <?= $depend[ 'table' ] . "\n" ?> |
|
259 | + * Gets dependent <?= $depend['table'] . "\n" ?> |
|
260 | 260 | * |
261 | - * @return <?= $depend[ 'class' ] . "\n" ?> |
|
261 | + * @return <?= $depend['class'] . "\n" ?> |
|
262 | 262 | */ |
263 | - public function get<?= $depend[ 'function' ] ?>() |
|
263 | + public function get<?= $depend['function'] ?>() |
|
264 | 264 | { |
265 | - if ($this->_depend_<?= $depend[ 'name' ] ?> === null) |
|
265 | + if ($this->_depend_<?= $depend['name'] ?> === null) |
|
266 | 266 | { |
267 | - $this->_depend_<?= $depend[ 'name' ] ?> = $this->findDependentRowset('<?= $objTables->getNamespace ( |
|
268 | - ) ?>_DbTable_<?= \Classes\Maker\AbstractMaker::getClassName ( $depend[ 'table' ] ) ?>'); |
|
267 | + $this->_depend_<?= $depend['name'] ?> = $this->findDependentRowset('<?= $objTables->getNamespace( |
|
268 | + ) ?>_DbTable_<?= \Classes\Maker\AbstractMaker::getClassName($depend['table']) ?>'); |
|
269 | 269 | } |
270 | 270 | |
271 | - return $this->_depend_<?= $depend[ 'name' ] ?>; |
|
271 | + return $this->_depend_<?= $depend['name'] ?>; |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | <?php endforeach; ?> |
@@ -157,9 +157,12 @@ discard block |
||
157 | 157 | * Stored in ISO 8601 format. |
158 | 158 | * |
159 | 159 | * @param string|Zend_Date $<?= $column->getName () . "\n" ?> |
160 | - <?php else: ?> |
|
160 | + <?php else { |
|
161 | + : ?> |
|
161 | 162 | * @param <?= $column->getType () ?> $<?= $column->getName () . "\n" ?> |
162 | - <?php endif; ?> |
|
163 | + <?php endif; |
|
164 | +} |
|
165 | +?> |
|
163 | 166 | * @return <?= $className . "\n" ?> |
164 | 167 | */ |
165 | 168 | public function set<?= \Classes\Maker\AbstractMaker::getClassName ( $column->getName () ) ?>($<?= $column->getName ( |
@@ -208,9 +211,12 @@ discard block |
||
208 | 211 | <?php if ( $column->equalType ( 'date' ) ): ?> |
209 | 212 | * @param boolean $returnZendDate |
210 | 213 | * @return Zend_Date|null|string Zend_Date representation of this datetime if enabled, or ISO 8601 string if not |
211 | - <?php else: ?> |
|
214 | + <?php else { |
|
215 | + : ?> |
|
212 | 216 | * @return <?= $column->getType () . "\n" ?> |
213 | - <?php endif; ?> |
|
217 | + <?php endif; |
|
218 | +} |
|
219 | +?> |
|
214 | 220 | */ |
215 | 221 | public function get<?= \Classes\Maker\AbstractMaker::getClassName ( |
216 | 222 | $column->getName () |
@@ -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 |
@@ -169,10 +169,10 @@ discard block |
||
169 | 169 | if ( empty( $this->totalTables ) ) { |
170 | 170 | |
171 | 171 | $this->totalTables = $this->getPDO () |
172 | - ->query ( |
|
173 | - "SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = '{$this->database}'" |
|
174 | - ) |
|
175 | - ->fetchColumn (); |
|
172 | + ->query ( |
|
173 | + "SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = '{$this->database}'" |
|
174 | + ) |
|
175 | + ->fetchColumn (); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | return (int) $this->totalTables; |
@@ -189,10 +189,10 @@ discard block |
||
189 | 189 | public function getSequence ( $table, $column, $schema = 0 ) |
190 | 190 | { |
191 | 191 | $return = $this->getPDO () |
192 | - ->query ( |
|
193 | - "select * from information_schema.columns where extra like '%auto_increment%' and TABLE_SCHEMA='{$this->database}' AND TABLE_NAME='{$table}' AND COLUMN_NAME='{$column}';" |
|
194 | - ) |
|
195 | - ->fetch ( \PDO::FETCH_ASSOC ); |
|
192 | + ->query ( |
|
193 | + "select * from information_schema.columns where extra like '%auto_increment%' and TABLE_SCHEMA='{$this->database}' AND TABLE_NAME='{$table}' AND COLUMN_NAME='{$column}';" |
|
194 | + ) |
|
195 | + ->fetch ( \PDO::FETCH_ASSOC ); |
|
196 | 196 | |
197 | 197 | if ( !$return ) { |
198 | 198 | 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,11 +112,11 @@ discard block |
||
112 | 112 | * |
113 | 113 | * @return array[] |
114 | 114 | */ |
115 | - public function getListColumns () |
|
115 | + public function getListColumns() |
|
116 | 116 | { |
117 | 117 | |
118 | - return $this->getPDO () |
|
119 | - ->query ( |
|
118 | + return $this->getPDO() |
|
119 | + ->query( |
|
120 | 120 | "select |
121 | 121 | 0 AS table_schema, |
122 | 122 | table_name, |
@@ -128,16 +128,16 @@ discard block |
||
128 | 128 | where table_schema IN ('{$this->database}') |
129 | 129 | order by table_name,ordinal_position" |
130 | 130 | ) |
131 | - ->fetchAll ( \PDO::FETCH_ASSOC ); |
|
131 | + ->fetchAll(\PDO::FETCH_ASSOC); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | /** |
135 | 135 | * @return array |
136 | 136 | */ |
137 | - public function getListConstrant () |
|
137 | + public function getListConstrant() |
|
138 | 138 | { |
139 | - return $this->getPDO () |
|
140 | - ->query ( |
|
139 | + return $this->getPDO() |
|
140 | + ->query( |
|
141 | 141 | "SELECT distinct |
142 | 142 | i.constraint_type, |
143 | 143 | k.constraint_name, |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | i.TABLE_SCHEMA IN ('{$this->database}') AND i.CONSTRAINT_TYPE IN ('FOREIGN KEY', 'PRIMARY KEY' ) |
157 | 157 | order by k.table_schema, k.table_name;" |
158 | 158 | ) |
159 | - ->fetchAll ( \PDO::FETCH_ASSOC ); |
|
159 | + ->fetchAll(\PDO::FETCH_ASSOC); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | /** |
@@ -164,15 +164,15 @@ discard block |
||
164 | 164 | * |
165 | 165 | * @return int |
166 | 166 | */ |
167 | - public function getTotalTables () |
|
167 | + public function getTotalTables() |
|
168 | 168 | { |
169 | - if ( empty( $this->totalTables ) ) { |
|
169 | + if (empty($this->totalTables)) { |
|
170 | 170 | |
171 | - $this->totalTables = $this->getPDO () |
|
172 | - ->query ( |
|
171 | + $this->totalTables = $this->getPDO() |
|
172 | + ->query( |
|
173 | 173 | "SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = '{$this->database}'" |
174 | 174 | ) |
175 | - ->fetchColumn (); |
|
175 | + ->fetchColumn(); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | return (int) $this->totalTables; |
@@ -186,15 +186,15 @@ discard block |
||
186 | 186 | * |
187 | 187 | * @return string |
188 | 188 | */ |
189 | - public function getSequence ( $table, $column, $schema = 0 ) |
|
189 | + public function getSequence($table, $column, $schema = 0) |
|
190 | 190 | { |
191 | - $return = $this->getPDO () |
|
192 | - ->query ( |
|
191 | + $return = $this->getPDO() |
|
192 | + ->query( |
|
193 | 193 | "select * from information_schema.columns where extra like '%auto_increment%' and TABLE_SCHEMA='{$this->database}' AND TABLE_NAME='{$table}' AND COLUMN_NAME='{$column}';" |
194 | 194 | ) |
195 | - ->fetch ( \PDO::FETCH_ASSOC ); |
|
195 | + ->fetch(\PDO::FETCH_ASSOC); |
|
196 | 196 | |
197 | - if ( !$return ) { |
|
197 | + if ( ! $return) { |
|
198 | 198 | return; |
199 | 199 | } |
200 | 200 |
@@ -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 |
@@ -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 |