@@ -3,22 +3,22 @@ |
||
| 3 | 3 | /** |
| 4 | 4 | * Data Model implementation for this class |
| 5 | 5 | * |
| 6 | - * <?=$this->config->last_modify."\n"?> |
|
| 6 | + * <?=$this->config->last_modify . "\n"?> |
|
| 7 | 7 | * |
| 8 | - * @see <?=$objTables->getNamespace()?>\<?=$this->getClassName ( $objTables->getName () ). "\n"?> |
|
| 8 | + * @see <?=$objTables->getNamespace()?>\<?=$this->getClassName($objTables->getName()) . "\n"?> |
|
| 9 | 9 | * |
| 10 | - * @author <?=$this->config->author."\n"?> |
|
| 10 | + * @author <?=$this->config->author . "\n"?> |
|
| 11 | 11 | * |
| 12 | - * @copyright <?=$this->config->copyright."\n"?> |
|
| 13 | - * @license <?=$this->config->license."\n"?> |
|
| 14 | - * @link <?=$this->config->link."\n"?> |
|
| 15 | - * @version <?=$this->config->version."\n"?> |
|
| 12 | + * @copyright <?=$this->config->copyright . "\n"?> |
|
| 13 | + * @license <?=$this->config->license . "\n"?> |
|
| 14 | + * @link <?=$this->config->link . "\n"?> |
|
| 15 | + * @version <?=$this->config->version . "\n"?> |
|
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | 18 | |
| 19 | 19 | namespace <?=$objTables->getNamespace()?>; |
| 20 | 20 | |
| 21 | -class <?=$this->getClassName ( $objTables->getName () )?> extends \<?=$objTables->getNamespace()?>\Entity\<?=$this->getClassName ( $objTables->getName () ). "\n"?> |
|
| 21 | +class <?=$this->getClassName($objTables->getName())?> extends \<?=$objTables->getNamespace()?>\Entity\<?=$this->getClassName($objTables->getName()) . "\n"?> |
|
| 22 | 22 | { |
| 23 | 23 | /* @TODO Codifique aqui */ |
| 24 | 24 | } |
@@ -3,18 +3,18 @@ discard block |
||
| 3 | 3 | /** |
| 4 | 4 | * Application Model DbTables |
| 5 | 5 | * |
| 6 | - * <?=$this->config->last_modify."\n"?> |
|
| 6 | + * <?=$this->config->last_modify . "\n"?> |
|
| 7 | 7 | * |
| 8 | 8 | * Classe Abstract pai de todas as tabelas |
| 9 | 9 | * |
| 10 | 10 | * @package <?=$this->config->namespace?>Model |
| 11 | 11 | * @subpackage DbTable |
| 12 | - * @author <?=$this->config->author."\n"?> |
|
| 12 | + * @author <?=$this->config->author . "\n"?> |
|
| 13 | 13 | * |
| 14 | - * @copyright <?=$this->config->copyright."\n"?> |
|
| 15 | - * @license <?=$this->config->license."\n"?> |
|
| 16 | - * @link <?=$this->config->link."\n"?> |
|
| 17 | - * @version <?=$this->config->version."\n"?> |
|
| 14 | + * @copyright <?=$this->config->copyright . "\n"?> |
|
| 15 | + * @license <?=$this->config->license . "\n"?> |
|
| 16 | + * @link <?=$this->config->link . "\n"?> |
|
| 17 | + * @version <?=$this->config->version . "\n"?> |
|
| 18 | 18 | * |
| 19 | 19 | * @abstract |
| 20 | 20 | */ |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | * Zend DB Table Abstract class |
| 24 | 24 | */ |
| 25 | 25 | |
| 26 | -abstract class <?=$this->config->namespace?$this->config->namespace."_":""?>Model_TableAbstract extends Zend_Db_Table_Abstract |
|
| 26 | +abstract class <?=$this->config->namespace ? $this->config->namespace . "_" : ""?>Model_TableAbstract extends Zend_Db_Table_Abstract |
|
| 27 | 27 | { |
| 28 | 28 | /** |
| 29 | 29 | * Nome da tabela do banco de dados |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | /** |
| 151 | 151 | * @param AbstractAdapter $type |
| 152 | 152 | * |
| 153 | - * @return mixed |
|
| 153 | + * @return string |
|
| 154 | 154 | */ |
| 155 | 155 | public function getTypeByConfig ( AbstractAdapter $type ) |
| 156 | 156 | { |
@@ -199,6 +199,7 @@ discard block |
||
| 199 | 199 | * @param $constraint_name |
| 200 | 200 | * @param $table_name |
| 201 | 201 | * @param $column_name |
| 202 | + * @param string $database |
|
| 202 | 203 | * |
| 203 | 204 | * @return $this |
| 204 | 205 | */ |
@@ -205,15 +205,15 @@ |
||
| 205 | 205 | public function createDependece ( $constraint_name, $table_name, $column_name, $database, $schema = null ) |
| 206 | 206 | { |
| 207 | 207 | $objConstrantDependence = Constrant::getInstance () |
| 208 | - ->populate ( |
|
| 209 | - array ( |
|
| 210 | - 'constrant' => $constraint_name, |
|
| 211 | - 'schema' => $schema, |
|
| 212 | - 'table' => $table_name, |
|
| 213 | - 'column' => $column_name, |
|
| 214 | - 'database' => $database |
|
| 215 | - ) |
|
| 216 | - ); |
|
| 208 | + ->populate ( |
|
| 209 | + array ( |
|
| 210 | + 'constrant' => $constraint_name, |
|
| 211 | + 'schema' => $schema, |
|
| 212 | + 'table' => $table_name, |
|
| 213 | + 'column' => $column_name, |
|
| 214 | + 'database' => $database |
|
| 215 | + ) |
|
| 216 | + ); |
|
| 217 | 217 | |
| 218 | 218 | $this->addDependece ( $objConstrantDependence ); |
| 219 | 219 | |
@@ -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 | } |
@@ -35,26 +35,19 @@ |
||
| 35 | 35 | $res = ''; |
| 36 | 36 | if ( preg_match ( '/(tinyint\(1\)|bit)/', $str ) ) { |
| 37 | 37 | $res = 'boolean'; |
| 38 | - } |
|
| 39 | - elseif ( preg_match ( '/(timestamp|blob|char|enum)/', $str ) ) { |
|
| 38 | + } elseif ( preg_match ( '/(timestamp|blob|char|enum)/', $str ) ) { |
|
| 40 | 39 | $res = 'string'; |
| 41 | - } |
|
| 42 | - elseif ( preg_match ( '/(text)/', $str ) ) { |
|
| 40 | + } elseif ( preg_match ( '/(text)/', $str ) ) { |
|
| 43 | 41 | $res = 'text'; |
| 44 | - } |
|
| 45 | - elseif ( preg_match ( '/(decimal|numeric|float|double)/', $str ) ) { |
|
| 42 | + } elseif ( preg_match ( '/(decimal|numeric|float|double)/', $str ) ) { |
|
| 46 | 43 | $res = 'float'; |
| 47 | - } |
|
| 48 | - elseif ( preg_match ( '#^(?:tiny|small|medium|long|big|var)?(\w+)(?:\(\d+\))?(?:\s\w+)*$#', $str, $matches ) ) { |
|
| 44 | + } elseif ( preg_match ( '#^(?:tiny|small|medium|long|big|var)?(\w+)(?:\(\d+\))?(?:\s\w+)*$#', $str, $matches ) ) { |
|
| 49 | 45 | $res = $matches[ 1 ]; |
| 50 | - } |
|
| 51 | - elseif ( preg_match ( '/(date)/', $str ) ) { |
|
| 46 | + } elseif ( preg_match ( '/(date)/', $str ) ) { |
|
| 52 | 47 | $res = 'date'; |
| 53 | - } |
|
| 54 | - elseif ( preg_match ( '/(datetime)/', $str ) ) { |
|
| 48 | + } elseif ( preg_match ( '/(datetime)/', $str ) ) { |
|
| 55 | 49 | $res = 'datetime'; |
| 56 | - } |
|
| 57 | - else { |
|
| 50 | + } else { |
|
| 58 | 51 | print "Can't convert column type to Simple - Unrecognized type: $str"; |
| 59 | 52 | } |
| 60 | 53 | |
@@ -174,10 +174,10 @@ discard block |
||
| 174 | 174 | $sqlTables = !empty($this->tablesName)?"AND table_name IN ( $this->tablesName )":''; |
| 175 | 175 | |
| 176 | 176 | $this->totalTables = $this->getPDO () |
| 177 | - ->query ( |
|
| 178 | - "SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = '{$this->database}' $sqlTables" |
|
| 179 | - ) |
|
| 180 | - ->fetchColumn (); |
|
| 177 | + ->query ( |
|
| 178 | + "SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = '{$this->database}' $sqlTables" |
|
| 179 | + ) |
|
| 180 | + ->fetchColumn (); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | return (int) $this->totalTables; |
@@ -194,10 +194,10 @@ discard block |
||
| 194 | 194 | public function getSequence ( $table, $column, $schema = 0 ) |
| 195 | 195 | { |
| 196 | 196 | $return = $this->getPDO () |
| 197 | - ->query ( |
|
| 198 | - "select * from information_schema.columns where extra like '%auto_increment%' and TABLE_SCHEMA='{$this->database}' AND TABLE_NAME='{$table}' AND COLUMN_NAME='{$column}';" |
|
| 199 | - ) |
|
| 200 | - ->fetch ( \PDO::FETCH_ASSOC ); |
|
| 197 | + ->query ( |
|
| 198 | + "select * from information_schema.columns where extra like '%auto_increment%' and TABLE_SCHEMA='{$this->database}' AND TABLE_NAME='{$table}' AND COLUMN_NAME='{$column}';" |
|
| 199 | + ) |
|
| 200 | + ->fetch ( \PDO::FETCH_ASSOC ); |
|
| 201 | 201 | |
| 202 | 202 | if ( !$return ) { |
| 203 | 203 | return; |
@@ -30,28 +30,28 @@ discard block |
||
| 30 | 30 | * |
| 31 | 31 | * @return string |
| 32 | 32 | */ |
| 33 | - protected function convertTypeToSimple ( $str ) |
|
| 33 | + protected function convertTypeToSimple($str) |
|
| 34 | 34 | { |
| 35 | 35 | $res = ''; |
| 36 | - if ( preg_match ( '/(tinyint\(1\)|bit)/', $str ) ) { |
|
| 36 | + if (preg_match('/(tinyint\(1\)|bit)/', $str)) { |
|
| 37 | 37 | $res = 'boolean'; |
| 38 | 38 | } |
| 39 | - elseif ( preg_match ( '/(timestamp|blob|char|enum)/', $str ) ) { |
|
| 39 | + elseif (preg_match('/(timestamp|blob|char|enum)/', $str)) { |
|
| 40 | 40 | $res = 'string'; |
| 41 | 41 | } |
| 42 | - elseif ( preg_match ( '/(text)/', $str ) ) { |
|
| 42 | + elseif (preg_match('/(text)/', $str)) { |
|
| 43 | 43 | $res = 'text'; |
| 44 | 44 | } |
| 45 | - elseif ( preg_match ( '/(decimal|numeric|float|double)/', $str ) ) { |
|
| 45 | + elseif (preg_match('/(decimal|numeric|float|double)/', $str)) { |
|
| 46 | 46 | $res = 'float'; |
| 47 | 47 | } |
| 48 | - elseif ( preg_match ( '#^(?:tiny|small|medium|long|big|var)?(\w+)(?:\(\d+\))?(?:\s\w+)*$#', $str, $matches ) ) { |
|
| 49 | - $res = $matches[ 1 ]; |
|
| 48 | + elseif (preg_match('#^(?:tiny|small|medium|long|big|var)?(\w+)(?:\(\d+\))?(?:\s\w+)*$#', $str, $matches)) { |
|
| 49 | + $res = $matches[1]; |
|
| 50 | 50 | } |
| 51 | - elseif ( preg_match ( '/(date)/', $str ) ) { |
|
| 51 | + elseif (preg_match('/(date)/', $str)) { |
|
| 52 | 52 | $res = 'date'; |
| 53 | 53 | } |
| 54 | - elseif ( preg_match ( '/(datetime)/', $str ) ) { |
|
| 54 | + elseif (preg_match('/(datetime)/', $str)) { |
|
| 55 | 55 | $res = 'datetime'; |
| 56 | 56 | } |
| 57 | 57 | else { |
@@ -65,9 +65,9 @@ discard block |
||
| 65 | 65 | * @inheritDoc |
| 66 | 66 | * @return string |
| 67 | 67 | */ |
| 68 | - public function getPDOString () |
|
| 68 | + public function getPDOString() |
|
| 69 | 69 | { |
| 70 | - return sprintf ( |
|
| 70 | + return sprintf( |
|
| 71 | 71 | "mysql:host=%s;port=%s;dbname=%s", |
| 72 | 72 | $this->host, |
| 73 | 73 | $this->port, |
@@ -80,9 +80,9 @@ discard block |
||
| 80 | 80 | * @inheritDoc |
| 81 | 81 | * @return string |
| 82 | 82 | */ |
| 83 | - public function getPDOSocketString () |
|
| 83 | + public function getPDOSocketString() |
|
| 84 | 84 | { |
| 85 | - return sprintf ( |
|
| 85 | + return sprintf( |
|
| 86 | 86 | "mysql:unix_socket=%s;dbname=%s", |
| 87 | 87 | $this->socket, |
| 88 | 88 | $this->database |
@@ -94,14 +94,14 @@ discard block |
||
| 94 | 94 | * @inheritDoc |
| 95 | 95 | * @return string[] |
| 96 | 96 | */ |
| 97 | - public function getListNameTable () |
|
| 97 | + public function getListNameTable() |
|
| 98 | 98 | { |
| 99 | - if ( empty( $this->tableList ) ) { |
|
| 100 | - $this->tableList = $this->getPDO () |
|
| 101 | - ->query ( |
|
| 99 | + if (empty($this->tableList)) { |
|
| 100 | + $this->tableList = $this->getPDO() |
|
| 101 | + ->query( |
|
| 102 | 102 | "show tables" |
| 103 | 103 | ) |
| 104 | - ->fetchAll (); |
|
| 104 | + ->fetchAll(); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | return $this->tableList; |
@@ -112,12 +112,12 @@ discard block |
||
| 112 | 112 | * |
| 113 | 113 | * @return array[] |
| 114 | 114 | */ |
| 115 | - public function getListColumns () |
|
| 115 | + public function getListColumns() |
|
| 116 | 116 | { |
| 117 | - $sqlTables = !empty($this->tablesName)?"AND table_name IN ( $this->tablesName )":''; |
|
| 117 | + $sqlTables = ! empty($this->tablesName) ? "AND table_name IN ( $this->tablesName )" : ''; |
|
| 118 | 118 | |
| 119 | - return $this->getPDO () |
|
| 120 | - ->query ( |
|
| 119 | + return $this->getPDO() |
|
| 120 | + ->query( |
|
| 121 | 121 | "select |
| 122 | 122 | 0 AS table_schema, |
| 123 | 123 | table_name, |
@@ -129,18 +129,18 @@ discard block |
||
| 129 | 129 | where table_schema IN ('{$this->database}') $sqlTables |
| 130 | 130 | order by table_name,ordinal_position" |
| 131 | 131 | ) |
| 132 | - ->fetchAll ( \PDO::FETCH_ASSOC ); |
|
| 132 | + ->fetchAll(\PDO::FETCH_ASSOC); |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | /** |
| 136 | 136 | * @return array |
| 137 | 137 | */ |
| 138 | - public function getListConstrant () |
|
| 138 | + public function getListConstrant() |
|
| 139 | 139 | { |
| 140 | - $sqlTables = !empty($this->tablesName)?"AND k.table_name IN ( $this->tablesName )":''; |
|
| 140 | + $sqlTables = ! empty($this->tablesName) ? "AND k.table_name IN ( $this->tablesName )" : ''; |
|
| 141 | 141 | |
| 142 | - $objQuery = $this->getPDO () |
|
| 143 | - ->query ( |
|
| 142 | + $objQuery = $this->getPDO() |
|
| 143 | + ->query( |
|
| 144 | 144 | "SELECT distinct |
| 145 | 145 | i.constraint_type, |
| 146 | 146 | k.constraint_name, |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | i.TABLE_SCHEMA IN ('{$this->database}') AND i.CONSTRAINT_TYPE IN ('FOREIGN KEY', 'PRIMARY KEY' ) $sqlTables |
| 160 | 160 | order by k.table_name;" |
| 161 | 161 | ); |
| 162 | - return $objQuery?$objQuery->fetchAll ( \PDO::FETCH_ASSOC ):array(); |
|
| 162 | + return $objQuery ? $objQuery->fetchAll(\PDO::FETCH_ASSOC) : array(); |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | /** |
@@ -167,17 +167,17 @@ discard block |
||
| 167 | 167 | * |
| 168 | 168 | * @return int |
| 169 | 169 | */ |
| 170 | - public function getTotalTables () |
|
| 170 | + public function getTotalTables() |
|
| 171 | 171 | { |
| 172 | - if ( empty( $this->totalTables ) ) { |
|
| 172 | + if (empty($this->totalTables)) { |
|
| 173 | 173 | |
| 174 | - $sqlTables = !empty($this->tablesName)?"AND table_name IN ( $this->tablesName )":''; |
|
| 174 | + $sqlTables = ! empty($this->tablesName) ? "AND table_name IN ( $this->tablesName )" : ''; |
|
| 175 | 175 | |
| 176 | - $this->totalTables = $this->getPDO () |
|
| 177 | - ->query ( |
|
| 176 | + $this->totalTables = $this->getPDO() |
|
| 177 | + ->query( |
|
| 178 | 178 | "SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = '{$this->database}' $sqlTables" |
| 179 | 179 | ) |
| 180 | - ->fetchColumn (); |
|
| 180 | + ->fetchColumn(); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | return (int) $this->totalTables; |
@@ -191,15 +191,15 @@ discard block |
||
| 191 | 191 | * |
| 192 | 192 | * @return string |
| 193 | 193 | */ |
| 194 | - public function getSequence ( $table, $column, $schema = 0 ) |
|
| 194 | + public function getSequence($table, $column, $schema = 0) |
|
| 195 | 195 | { |
| 196 | - $return = $this->getPDO () |
|
| 197 | - ->query ( |
|
| 196 | + $return = $this->getPDO() |
|
| 197 | + ->query( |
|
| 198 | 198 | "select * from information_schema.columns where extra like '%auto_increment%' and TABLE_SCHEMA='{$this->database}' AND TABLE_NAME='{$table}' AND COLUMN_NAME='{$column}';" |
| 199 | 199 | ) |
| 200 | - ->fetch ( \PDO::FETCH_ASSOC ); |
|
| 200 | + ->fetch(\PDO::FETCH_ASSOC); |
|
| 201 | 201 | |
| 202 | - if ( !$return ) { |
|
| 202 | + if ( ! $return) { |
|
| 203 | 203 | return; |
| 204 | 204 | } |
| 205 | 205 | |
@@ -22,16 +22,16 @@ discard block |
||
| 22 | 22 | * @var string |
| 23 | 23 | */ |
| 24 | 24 | protected $framework = "phalcon"; |
| 25 | - public $reservedWord = array ( 'public' => 'Main' ); |
|
| 25 | + public $reservedWord = array('public' => 'Main'); |
|
| 26 | 26 | |
| 27 | - protected $dataTypes = array ( |
|
| 27 | + protected $dataTypes = array( |
|
| 28 | 28 | 'int' => 'integer', |
| 29 | 29 | 'float' => 'decimal' |
| 30 | 30 | ); |
| 31 | 31 | |
| 32 | 32 | const SEPARETOR = "\\"; |
| 33 | 33 | |
| 34 | - protected function init () |
|
| 34 | + protected function init() |
|
| 35 | 35 | { |
| 36 | 36 | } |
| 37 | 37 | |
@@ -40,12 +40,12 @@ discard block |
||
| 40 | 40 | * |
| 41 | 41 | * @return array |
| 42 | 42 | */ |
| 43 | - protected function getParams () |
|
| 43 | + protected function getParams() |
|
| 44 | 44 | { |
| 45 | 45 | |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - protected function parseFrameworkConfig () |
|
| 48 | + protected function parseFrameworkConfig() |
|
| 49 | 49 | { |
| 50 | 50 | // TODO: Implement parseFrameworkConfig() method. |
| 51 | 51 | } |
@@ -53,10 +53,10 @@ discard block |
||
| 53 | 53 | /** |
| 54 | 54 | * @inheritdoc |
| 55 | 55 | */ |
| 56 | - protected function getBaseNamespace () |
|
| 56 | + protected function getBaseNamespace() |
|
| 57 | 57 | { |
| 58 | - return array ( |
|
| 59 | - $this->arrConfig[ 'namespace' ], |
|
| 58 | + return array( |
|
| 59 | + $this->arrConfig['namespace'], |
|
| 60 | 60 | 'Models' |
| 61 | 61 | ); |
| 62 | 62 | } |
@@ -66,12 +66,12 @@ discard block |
||
| 66 | 66 | * |
| 67 | 67 | * @return \Classes\AdapterMakerFile\AbstractAdapter[] |
| 68 | 68 | */ |
| 69 | - public function getMakeFileInstances () |
|
| 69 | + public function getMakeFileInstances() |
|
| 70 | 70 | { |
| 71 | - return array ( |
|
| 72 | - Entity::getInstance (), |
|
| 73 | - Model::getInstance (), |
|
| 74 | - Peer::getInstance () |
|
| 71 | + return array( |
|
| 72 | + Entity::getInstance(), |
|
| 73 | + Model::getInstance(), |
|
| 74 | + Peer::getInstance() |
|
| 75 | 75 | ); |
| 76 | 76 | } |
| 77 | 77 | |
@@ -3,20 +3,20 @@ |
||
| 3 | 3 | /** |
| 4 | 4 | * Data Entity implementation for this class |
| 5 | 5 | * |
| 6 | - * <?=$this->config->last_modify."\n"?> |
|
| 6 | + * <?=$this->config->last_modify . "\n"?> |
|
| 7 | 7 | * |
| 8 | - * @package <?=$objTables->getNamespace()."\n"?> |
|
| 9 | - * @see <?=$objTables->getNamespace()?>_Entity_<?=\Classes\Maker\AbstractMaker::getClassName ( $objTables->getName () )?>. <?="\n"?> |
|
| 8 | + * @package <?=$objTables->getNamespace() . "\n"?> |
|
| 9 | + * @see <?=$objTables->getNamespace()?>_Entity_<?=\Classes\Maker\AbstractMaker::getClassName($objTables->getName())?>. <?="\n"?> |
|
| 10 | 10 | * |
| 11 | - * @author <?=$this->config->author."\n"?> |
|
| 11 | + * @author <?=$this->config->author . "\n"?> |
|
| 12 | 12 | * |
| 13 | - * @copyright <?=$this->config->copyright."\n"?> |
|
| 14 | - * @license <?=$this->config->license."\n"?> |
|
| 15 | - * @link <?=$this->config->link."\n"?> |
|
| 16 | - * @version <?=$this->config->version."\n"?> |
|
| 13 | + * @copyright <?=$this->config->copyright . "\n"?> |
|
| 14 | + * @license <?=$this->config->license . "\n"?> |
|
| 15 | + * @link <?=$this->config->link . "\n"?> |
|
| 16 | + * @version <?=$this->config->version . "\n"?> |
|
| 17 | 17 | */ |
| 18 | 18 | |
| 19 | -class <?=$objTables->getNamespace()?>_<?=\Classes\Maker\AbstractMaker::getClassName ( $objTables->getName () )?> extends <?=$objTables->getNamespace()?>_Entity_<?=\Classes\Maker\AbstractMaker::getClassName ( $objTables->getName () ). "\n"?> |
|
| 19 | +class <?=$objTables->getNamespace()?>_<?=\Classes\Maker\AbstractMaker::getClassName($objTables->getName())?> extends <?=$objTables->getNamespace()?>_Entity_<?=\Classes\Maker\AbstractMaker::getClassName($objTables->getName()) . "\n"?> |
|
| 20 | 20 | { |
| 21 | 21 | /* @TODO Codifique aqui */ |
| 22 | 22 | } |
@@ -34,6 +34,9 @@ |
||
| 34 | 34 | return self::$instance; |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | + /** |
|
| 38 | + * @param string $directory |
|
| 39 | + */ |
|
| 37 | 40 | private function scanDir ( $directory ) |
| 38 | 41 | { |
| 39 | 42 | if(!is_dir($directory)){ |
@@ -17,16 +17,16 @@ discard block |
||
| 17 | 17 | /** |
| 18 | 18 | * @type int |
| 19 | 19 | */ |
| 20 | - private $countFileDeleted=0; |
|
| 20 | + private $countFileDeleted = 0; |
|
| 21 | 21 | |
| 22 | - final private function __construct (){ } |
|
| 22 | + final private function __construct() { } |
|
| 23 | 23 | |
| 24 | 24 | /** |
| 25 | 25 | * @return \Classes\CleanTrash |
| 26 | 26 | */ |
| 27 | - public static function getInstance () |
|
| 27 | + public static function getInstance() |
|
| 28 | 28 | { |
| 29 | - if ( self::$instance === null ) |
|
| 29 | + if (self::$instance === null) |
|
| 30 | 30 | { |
| 31 | 31 | self::$instance = new self(); |
| 32 | 32 | } |
@@ -34,20 +34,20 @@ discard block |
||
| 34 | 34 | return self::$instance; |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - private function scanDir ( $directory ) |
|
| 37 | + private function scanDir($directory) |
|
| 38 | 38 | { |
| 39 | - if(!is_dir($directory)){ |
|
| 39 | + if ( ! is_dir($directory)) { |
|
| 40 | 40 | return array(); |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - $diretories = preg_grep ( '*\.ph*' , scandir ( $directory ) ); |
|
| 44 | - if(!$diretories){ |
|
| 43 | + $diretories = preg_grep('*\.ph*', scandir($directory)); |
|
| 44 | + if ( ! $diretories) { |
|
| 45 | 45 | return array(); |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - return array_diff ( $diretories, array ( |
|
| 49 | - '..' , '.' |
|
| 50 | - ) ); |
|
| 48 | + return array_diff($diretories, array( |
|
| 49 | + '..', '.' |
|
| 50 | + )); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | /** |
@@ -57,14 +57,14 @@ discard block |
||
| 57 | 57 | * |
| 58 | 58 | * @return array |
| 59 | 59 | */ |
| 60 | - private function diffFiles ( $path , $driver , $schema = 0 ) |
|
| 60 | + private function diffFiles($path, $driver, $schema = 0) |
|
| 61 | 61 | { |
| 62 | - $tables = $driver->getTables ( $schema ); |
|
| 63 | - if(!$tables instanceof DbTables){ |
|
| 62 | + $tables = $driver->getTables($schema); |
|
| 63 | + if ( ! $tables instanceof DbTables) { |
|
| 64 | 64 | return array(); |
| 65 | 65 | } |
| 66 | 66 | $tablesName = $tables->toArrayFileName(); |
| 67 | - return array_diff ( $this->scanDir ( $path ) , $tablesName ); |
|
| 67 | + return array_diff($this->scanDir($path), $tablesName); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /** |
@@ -74,14 +74,14 @@ discard block |
||
| 74 | 74 | * |
| 75 | 75 | * @return int |
| 76 | 76 | */ |
| 77 | - public function run ( $path , $driver , $schema = 0 ) |
|
| 77 | + public function run($path, $driver, $schema = 0) |
|
| 78 | 78 | { |
| 79 | 79 | $count = 0; |
| 80 | - foreach ( $this->diffFiles ( $path , $driver , $schema ) as $fileDel ) |
|
| 80 | + foreach ($this->diffFiles($path, $driver, $schema) as $fileDel) |
|
| 81 | 81 | { |
| 82 | - if ( unlink ( $path . DIRECTORY_SEPARATOR . $fileDel ) ) |
|
| 82 | + if (unlink($path . DIRECTORY_SEPARATOR . $fileDel)) |
|
| 83 | 83 | { |
| 84 | - ++ $count; |
|
| 84 | + ++$count; |
|
| 85 | 85 | } |
| 86 | 86 | } |
| 87 | 87 | |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | /** |
| 94 | 94 | * @return int |
| 95 | 95 | */ |
| 96 | - public function getNumFilesDeleted () |
|
| 96 | + public function getNumFilesDeleted() |
|
| 97 | 97 | { |
| 98 | 98 | return $this->countFileDeleted; |
| 99 | 99 | } |
@@ -55,7 +55,7 @@ |
||
| 55 | 55 | foreach ( $this->objDbTables as $objDbTable ) |
| 56 | 56 | { |
| 57 | 57 | $this->toArrayFileName[] = AbstractMaker::getClassName ( $objDbTable->getName () ) |
| 58 | - . '.php'; |
|
| 58 | + . '.php'; |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | return $this->toArrayFileName; |
@@ -5,56 +5,56 @@ discard block |
||
| 5 | 5 | use Classes\Db\DbTable; |
| 6 | 6 | use Classes\Maker\AbstractMaker; |
| 7 | 7 | |
| 8 | -class DbTables implements \ArrayAccess , \SeekableIterator , \Countable |
|
| 8 | +class DbTables implements \ArrayAccess, \SeekableIterator, \Countable |
|
| 9 | 9 | { |
| 10 | 10 | |
| 11 | 11 | /** |
| 12 | 12 | * @type DbTable[] |
| 13 | 13 | */ |
| 14 | - private $objDbTables = array (); |
|
| 14 | + private $objDbTables = array(); |
|
| 15 | 15 | |
| 16 | 16 | private $position = 0; |
| 17 | 17 | |
| 18 | - public function offsetExists ( $offset ) |
|
| 18 | + public function offsetExists($offset) |
|
| 19 | 19 | { |
| 20 | - return isset( $this->objDbTables[ trim ( $offset ) ] ); |
|
| 20 | + return isset($this->objDbTables[trim($offset)]); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | - public function offsetGet ( $offset ) |
|
| 23 | + public function offsetGet($offset) |
|
| 24 | 24 | { |
| 25 | - return $this->objDbTables[ trim ( $offset ) ]; |
|
| 25 | + return $this->objDbTables[trim($offset)]; |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | - public function offsetSet ( $offset , $value ) |
|
| 28 | + public function offsetSet($offset, $value) |
|
| 29 | 29 | { |
| 30 | - return $this->objDbTables[ trim ( $offset ) ] = $value; |
|
| 30 | + return $this->objDbTables[trim($offset)] = $value; |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - public function offsetUnset ( $offset ) |
|
| 33 | + public function offsetUnset($offset) |
|
| 34 | 34 | { |
| 35 | - unset( $this->objDbTables[ trim ( $offset ) ] ); |
|
| 35 | + unset($this->objDbTables[trim($offset)]); |
|
| 36 | 36 | |
| 37 | 37 | return $this; |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - public function count () |
|
| 40 | + public function count() |
|
| 41 | 41 | { |
| 42 | - return count ( $this->objDbTables ); |
|
| 42 | + return count($this->objDbTables); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | /** |
| 46 | 46 | * convert array |
| 47 | 47 | */ |
| 48 | - public function toArrayFileName () |
|
| 48 | + public function toArrayFileName() |
|
| 49 | 49 | { |
| 50 | - if ( ! empty( $this->toArrayFileName ) ) |
|
| 50 | + if ( ! empty($this->toArrayFileName)) |
|
| 51 | 51 | { |
| 52 | 52 | return $this->toArrayFileName; |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - foreach ( $this->objDbTables as $objDbTable ) |
|
| 55 | + foreach ($this->objDbTables as $objDbTable) |
|
| 56 | 56 | { |
| 57 | - $this->toArrayFileName[] = AbstractMaker::getClassName ( $objDbTable->getName () ) |
|
| 57 | + $this->toArrayFileName[] = AbstractMaker::getClassName($objDbTable->getName()) |
|
| 58 | 58 | . '.php'; |
| 59 | 59 | } |
| 60 | 60 | |
@@ -63,12 +63,12 @@ discard block |
||
| 63 | 63 | |
| 64 | 64 | /* Method required for SeekableIterator interface */ |
| 65 | 65 | |
| 66 | - public function seek ( $position ) |
|
| 66 | + public function seek($position) |
|
| 67 | 67 | { |
| 68 | - $current = array_keys ( $this->objDbTables ); |
|
| 69 | - if ( ! isset( $this->objDbTables[ $current[ $position ] ] ) ) |
|
| 68 | + $current = array_keys($this->objDbTables); |
|
| 69 | + if ( ! isset($this->objDbTables[$current[$position]])) |
|
| 70 | 70 | { |
| 71 | - throw new OutOfBoundsException( "invalid seek position ($position)" ); |
|
| 71 | + throw new OutOfBoundsException("invalid seek position ($position)"); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | $this->position = $position; |
@@ -76,34 +76,34 @@ discard block |
||
| 76 | 76 | |
| 77 | 77 | /* Methods required for Iterator interface */ |
| 78 | 78 | |
| 79 | - public function rewind () |
|
| 79 | + public function rewind() |
|
| 80 | 80 | { |
| 81 | 81 | $this->position = 0; |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - public function current () |
|
| 84 | + public function current() |
|
| 85 | 85 | { |
| 86 | - $current = array_keys ( $this->objDbTables ); |
|
| 86 | + $current = array_keys($this->objDbTables); |
|
| 87 | 87 | |
| 88 | - return $this->objDbTables[ $current[ $this->position ] ]; |
|
| 88 | + return $this->objDbTables[$current[$this->position]]; |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - public function key () |
|
| 91 | + public function key() |
|
| 92 | 92 | { |
| 93 | - $current = array_keys ( $this->objDbTables ); |
|
| 93 | + $current = array_keys($this->objDbTables); |
|
| 94 | 94 | |
| 95 | - return $current[ $this->position ]; |
|
| 95 | + return $current[$this->position]; |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - public function next () |
|
| 98 | + public function next() |
|
| 99 | 99 | { |
| 100 | - ++ $this->position; |
|
| 100 | + ++$this->position; |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - public function valid () |
|
| 103 | + public function valid() |
|
| 104 | 104 | { |
| 105 | - $current = array_keys ( $this->objDbTables ); |
|
| 105 | + $current = array_keys($this->objDbTables); |
|
| 106 | 106 | |
| 107 | - return isset( $current[ $this->position ] ); |
|
| 107 | + return isset($current[$this->position]); |
|
| 108 | 108 | } |
| 109 | 109 | } |
| 110 | 110 | \ No newline at end of file |
@@ -13,15 +13,15 @@ |
||
| 13 | 13 | |
| 14 | 14 | public $pastName = 'Peer'; |
| 15 | 15 | protected $fileTpl = "peer.php"; |
| 16 | - protected $fileFixedData = array ( |
|
| 17 | - 'parentclass' => array ( |
|
| 18 | - 'name' => "AbstractPeer" , |
|
| 16 | + protected $fileFixedData = array( |
|
| 17 | + 'parentclass' => array( |
|
| 18 | + 'name' => "AbstractPeer", |
|
| 19 | 19 | 'tpl' => "peer_abstract.php" |
| 20 | 20 | ) |
| 21 | 21 | ); |
| 22 | 22 | |
| 23 | - public function parseRelation ( \Classes\MakerFile $makerFile, \Classes\Db\DbTable $dbTable ) |
|
| 23 | + public function parseRelation(\Classes\MakerFile $makerFile, \Classes\Db\DbTable $dbTable) |
|
| 24 | 24 | { |
| 25 | - return array (); |
|
| 25 | + return array(); |
|
| 26 | 26 | } |
| 27 | 27 | } |