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