@@ -1,22 +1,22 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if ( ! ini_get ( 'short_open_tag' ) ) |
|
| 3 | +if ( ! ini_get('short_open_tag')) |
|
| 4 | 4 | { |
| 5 | - die( "\033[0;31mError: please enable short_open_tag directive in php.ini\033[0m\n" ); |
|
| 5 | + die("\033[0;31mError: please enable short_open_tag directive in php.ini\033[0m\n"); |
|
| 6 | 6 | } |
| 7 | 7 | |
| 8 | -if ( ! ini_get ( 'register_argc_argv' ) ) |
|
| 8 | +if ( ! ini_get('register_argc_argv')) |
|
| 9 | 9 | { |
| 10 | - die( "\033[0;31mError: please enable register_argc_argv directive in php.ini\033[0m\n" ); |
|
| 10 | + die("\033[0;31mError: please enable register_argc_argv directive in php.ini\033[0m\n"); |
|
| 11 | 11 | } |
| 12 | 12 | |
| 13 | -if ( function_exists ( 'ini_set' ) ) { |
|
| 14 | - @ini_set ( 'display_errors', 1 ); |
|
| 13 | +if (function_exists('ini_set')) { |
|
| 14 | + @ini_set('display_errors', 1); |
|
| 15 | 15 | |
| 16 | - $memoryInBytes = function ( $value ) { |
|
| 17 | - $unit = strtolower ( substr ( $value, -1, 1 ) ); |
|
| 16 | + $memoryInBytes = function($value) { |
|
| 17 | + $unit = strtolower(substr($value, -1, 1)); |
|
| 18 | 18 | $value = (int) $value; |
| 19 | - switch ( $unit ) { |
|
| 19 | + switch ($unit) { |
|
| 20 | 20 | case 'g': |
| 21 | 21 | $value *= 1024; |
| 22 | 22 | // no break (cumulative multiplier) |
@@ -30,22 +30,22 @@ discard block |
||
| 30 | 30 | return $value; |
| 31 | 31 | }; |
| 32 | 32 | |
| 33 | - $memoryLimit = trim ( ini_get ( 'memory_limit' ) ); |
|
| 33 | + $memoryLimit = trim(ini_get('memory_limit')); |
|
| 34 | 34 | // Increase memory_limit if it is lower than 1GB |
| 35 | - if ( $memoryLimit != -1 && $memoryInBytes( $memoryLimit ) < 1024 * 1024 * 1024 ) { |
|
| 36 | - @ini_set ( 'memory_limit', '1G' ); |
|
| 35 | + if ($memoryLimit != -1 && $memoryInBytes($memoryLimit) < 1024 * 1024 * 1024) { |
|
| 36 | + @ini_set('memory_limit', '1G'); |
|
| 37 | 37 | } |
| 38 | - unset( $memoryInBytes, $memoryLimit ); |
|
| 38 | + unset($memoryInBytes, $memoryLimit); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | -\Phar::interceptFileFuncs (); |
|
| 41 | +\Phar::interceptFileFuncs(); |
|
| 42 | 42 | |
| 43 | -set_include_path ( |
|
| 44 | - implode ( |
|
| 43 | +set_include_path( |
|
| 44 | + implode( |
|
| 45 | 45 | PATH_SEPARATOR, |
| 46 | - array ( |
|
| 47 | - realpath ( __DIR__ ), |
|
| 48 | - get_include_path (), |
|
| 46 | + array( |
|
| 47 | + realpath(__DIR__), |
|
| 48 | + get_include_path(), |
|
| 49 | 49 | ) |
| 50 | 50 | ) |
| 51 | 51 | ); |
@@ -55,15 +55,15 @@ discard block |
||
| 55 | 55 | require_once 'Classes/MakerConfigFile.php'; |
| 56 | 56 | |
| 57 | 57 | try { |
| 58 | - $_path = realpath ( |
|
| 59 | - str_replace ( |
|
| 58 | + $_path = realpath( |
|
| 59 | + str_replace( |
|
| 60 | 60 | 'phar://', |
| 61 | 61 | '', |
| 62 | 62 | __DIR__ |
| 63 | 63 | ) |
| 64 | 64 | ); |
| 65 | 65 | |
| 66 | - $arrValid = array ( |
|
| 66 | + $arrValid = array( |
|
| 67 | 67 | 'version', |
| 68 | 68 | 'help', |
| 69 | 69 | 'status', |
@@ -82,18 +82,18 @@ discard block |
||
| 82 | 82 | 'download:' |
| 83 | 83 | ); |
| 84 | 84 | |
| 85 | - $arg = getopt ( null, $arrValid ); |
|
| 86 | - if ( array_key_exists ( 'init', $arg ) ) { |
|
| 87 | - $maker = new \Classes\MakerConfigFile( $arg, dirname($_path) ); |
|
| 85 | + $arg = getopt(null, $arrValid); |
|
| 86 | + if (array_key_exists('init', $arg)) { |
|
| 87 | + $maker = new \Classes\MakerConfigFile($arg, dirname($_path)); |
|
| 88 | 88 | } |
| 89 | 89 | else { |
| 90 | - $maker = new \Classes\MakerFile( new \Classes\Config( $arg, dirname($_path), count ( $argv ) ) ); |
|
| 90 | + $maker = new \Classes\MakerFile(new \Classes\Config($arg, dirname($_path), count($argv))); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - $maker->run (); |
|
| 93 | + $maker->run(); |
|
| 94 | 94 | |
| 95 | -} catch ( \Exception $e ) { |
|
| 96 | - die( $e->getMessage () ); |
|
| 95 | +} catch (\Exception $e) { |
|
| 96 | + die($e->getMessage()); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | __halt_compiler(); |
| 100 | 100 | \ No newline at end of file |
@@ -85,8 +85,7 @@ |
||
| 85 | 85 | $arg = getopt ( null, $arrValid ); |
| 86 | 86 | if ( array_key_exists ( 'init', $arg ) ) { |
| 87 | 87 | $maker = new \Classes\MakerConfigFile( $arg, dirname($_path) ); |
| 88 | - } |
|
| 89 | - else { |
|
| 88 | + } else { |
|
| 90 | 89 | $maker = new \Classes\MakerFile( new \Classes\Config( $arg, dirname($_path), count ( $argv ) ) ); |
| 91 | 90 | } |
| 92 | 91 | |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?= "<?php\n" ?> |
| 2 | -<?php $classNameModel = $objTables->getNamespace () . '_' . \Classes\Maker\AbstractMaker::getClassName ( $objTables->getName () ) ?> |
|
| 3 | -<?php $className = $objTables->getNamespace () . '_Entity_' . \Classes\Maker\AbstractMaker::getClassName ( |
|
| 4 | - $objTables->getName () |
|
| 2 | +<?php $classNameModel = $objTables->getNamespace() . '_' . \Classes\Maker\AbstractMaker::getClassName($objTables->getName()) ?> |
|
| 3 | +<?php $className = $objTables->getNamespace() . '_Entity_' . \Classes\Maker\AbstractMaker::getClassName( |
|
| 4 | + $objTables->getName() |
|
| 5 | 5 | ) ?> |
| 6 | 6 | |
| 7 | 7 | /** |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | * |
| 10 | 10 | * <?= $this->config->last_modify . "\n" ?> |
| 11 | 11 | * |
| 12 | - * @package <?= $objTables->getNamespace () . "\n" ?> |
|
| 12 | + * @package <?= $objTables->getNamespace() . "\n" ?> |
|
| 13 | 13 | * @subpackage Entity |
| 14 | 14 | * |
| 15 | 15 | * @author <?= $this->config->author . "\n" ?> |
@@ -28,12 +28,12 @@ discard block |
||
| 28 | 28 | . "_" : "" ?>Model_<?= $objMakeFile->getFilesFixeds('parentClass')->getFileName() . "\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 ( strtolower ( $column->getType () ) ) { |
|
| 67 | + switch (strtolower($column->getType())) { |
|
| 68 | 68 | case 'string': |
| 69 | 69 | $filters = 'StripTags", "StringTrim'; |
| 70 | 70 | break; |
@@ -78,15 +78,15 @@ discard block |
||
| 78 | 78 | case 'datetime': |
| 79 | 79 | break; |
| 80 | 80 | case 'boolean': |
| 81 | - $filters='Int'; |
|
| 81 | + $filters = 'Int'; |
|
| 82 | 82 | break; |
| 83 | 83 | default: |
| 84 | - $filters = ucfirst ( $column->getType () ); |
|
| 84 | + $filters = ucfirst($column->getType()); |
|
| 85 | 85 | break; |
| 86 | 86 | } |
| 87 | 87 | ?> |
| 88 | - '<?= $column->getName () ?>' => array ( |
|
| 89 | - <?= ( !empty( $filters ) ) ? "\"{$filters}\"\n" : null; ?> |
|
| 88 | + '<?= $column->getName() ?>' => array ( |
|
| 89 | + <?= ( ! empty($filters)) ? "\"{$filters}\"\n" : null; ?> |
|
| 90 | 90 | ), |
| 91 | 91 | <?php endforeach; ?> |
| 92 | 92 | ); |
@@ -95,13 +95,13 @@ discard block |
||
| 95 | 95 | * @see <?= $this->config->namespace ?>Model_EntityAbstract::$_validators |
| 96 | 96 | */ |
| 97 | 97 | protected $_validators= array( |
| 98 | -<?php foreach ( $objTables->getColumns () as $column ): ?> |
|
| 98 | +<?php foreach ($objTables->getColumns() as $column): ?> |
|
| 99 | 99 | <?php |
| 100 | - $validators = array (); |
|
| 100 | + $validators = array(); |
|
| 101 | 101 | |
| 102 | - $validators[] = $column->isNullable () ? "'allowEmpty' => true" : "'NotEmpty'"; |
|
| 102 | + $validators[] = $column->isNullable() ? "'allowEmpty' => true" : "'NotEmpty'"; |
|
| 103 | 103 | |
| 104 | - switch ( strtolower ( $column->getType () ) ) { |
|
| 104 | + switch (strtolower($column->getType())) { |
|
| 105 | 105 | case 'date': |
| 106 | 106 | break; |
| 107 | 107 | case 'timestamp': |
@@ -109,8 +109,8 @@ discard block |
||
| 109 | 109 | case 'datetime': |
| 110 | 110 | break; |
| 111 | 111 | case 'string': |
| 112 | - if ( $column->getMaxLength () ) { |
|
| 113 | - $validators[] = "array( 'StringLength', array( 'max' => " . $column->getMaxLength () . " ) )"; |
|
| 112 | + if ($column->getMaxLength()) { |
|
| 113 | + $validators[] = "array( 'StringLength', array( 'max' => " . $column->getMaxLength() . " ) )"; |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | break; |
@@ -118,18 +118,18 @@ discard block |
||
| 118 | 118 | $validators[] = "'Int'"; |
| 119 | 119 | break; |
| 120 | 120 | default: |
| 121 | - $name = ucfirst ( $column->getType () ); |
|
| 121 | + $name = ucfirst($column->getType()); |
|
| 122 | 122 | $validators[] = "'$name'"; |
| 123 | 123 | break; |
| 124 | 124 | } |
| 125 | -$validators = implode ( ", ", $validators ) ?> |
|
| 126 | - '<?= $column->getName () ?>' => array ( |
|
| 127 | - <?= ( !empty( $validators ) ) ? "{$validators}\n" : null ?> |
|
| 125 | +$validators = implode(", ", $validators) ?> |
|
| 126 | + '<?= $column->getName() ?>' => array ( |
|
| 127 | + <?= ( ! empty($validators)) ? "{$validators}\n" : null ?> |
|
| 128 | 128 | ), |
| 129 | 129 | <?php endforeach; ?> |
| 130 | 130 | ); |
| 131 | 131 | |
| 132 | -<?php if ( $objTables->hasPrimaryKey () ): ?> |
|
| 132 | +<?php if ($objTables->hasPrimaryKey()): ?> |
|
| 133 | 133 | /** |
| 134 | 134 | * Nome da Primary Key |
| 135 | 135 | * |
@@ -137,171 +137,171 @@ discard block |
||
| 137 | 137 | * @access protected |
| 138 | 138 | */ |
| 139 | 139 | protected $_primary = array( |
| 140 | -<?php foreach ( $objTables->getPrimarykeys () as $pks ) : ?> |
|
| 141 | - '<?= $pks->getName () ?>', |
|
| 140 | +<?php foreach ($objTables->getPrimarykeys() as $pks) : ?> |
|
| 141 | + '<?= $pks->getName() ?>', |
|
| 142 | 142 | <?php endforeach ?> |
| 143 | 143 | ); |
| 144 | 144 | <?php endif ?> |
| 145 | 145 | |
| 146 | -<?php foreach ( $parents as $parent ): ?> |
|
| 146 | +<?php foreach ($parents as $parent): ?> |
|
| 147 | 147 | /** |
| 148 | - * Parent relation <?= \Classes\Maker\AbstractMaker::getClassName ( $parent[ 'table' ] ) . "\n" ?> |
|
| 148 | + * Parent relation <?= \Classes\Maker\AbstractMaker::getClassName($parent['table']) . "\n" ?> |
|
| 149 | 149 | * |
| 150 | - * - CONSTRAINT in DB <?= $parent[ 'name' ] . "\n" ?> |
|
| 150 | + * - CONSTRAINT in DB <?= $parent['name'] . "\n" ?> |
|
| 151 | 151 | * |
| 152 | - * @var <?= $parent[ 'variable' ] . "\n" ?> |
|
| 152 | + * @var <?= $parent['variable'] . "\n" ?> |
|
| 153 | 153 | */ |
| 154 | - protected $_parent_<?= $parent[ 'variable' ] ?>; |
|
| 154 | + protected $_parent_<?= $parent['variable'] ?>; |
|
| 155 | 155 | |
| 156 | 156 | <?php endforeach; ?> |
| 157 | -<?php foreach ( $depends as $depend ): ?> |
|
| 157 | +<?php foreach ($depends as $depend): ?> |
|
| 158 | 158 | /** |
| 159 | - * Depends relation <?= \Classes\Maker\AbstractMaker::getClassName ( $depend[ 'table' ] ) . "\n" ?> |
|
| 159 | + * Depends relation <?= \Classes\Maker\AbstractMaker::getClassName($depend['table']) . "\n" ?> |
|
| 160 | 160 | * |
| 161 | - * - CONSTRAINT in DB <?= $depend[ 'name' ] . "\n" ?> |
|
| 161 | + * - CONSTRAINT in DB <?= $depend['name'] . "\n" ?> |
|
| 162 | 162 | * |
| 163 | - * @var <?= $depend[ 'variable' ] . "\n" ?> |
|
| 163 | + * @var <?= $depend['variable'] . "\n" ?> |
|
| 164 | 164 | */ |
| 165 | - protected $_depend_<?= $depend[ 'variable' ] ?>; |
|
| 165 | + protected $_depend_<?= $depend['variable'] ?>; |
|
| 166 | 166 | |
| 167 | 167 | <?php endforeach; ?> |
| 168 | -<?php foreach ( $objTables->getColumns () as $column ): ?> |
|
| 168 | +<?php foreach ($objTables->getColumns() as $column): ?> |
|
| 169 | 169 | /** |
| 170 | 170 | * |
| 171 | - * Sets column <?= $column->getName () . "\n" ?> |
|
| 171 | + * Sets column <?= $column->getName() . "\n" ?> |
|
| 172 | 172 | * |
| 173 | -<?php if ( $column->equalType ( 'date' ) ): ?> |
|
| 173 | +<?php if ($column->equalType('date')): ?> |
|
| 174 | 174 | * Stored in ISO 8601 format. |
| 175 | 175 | * |
| 176 | - * @param string|Zend_Date $<?= $column->getName () . "\n" ?> |
|
| 176 | + * @param string|Zend_Date $<?= $column->getName() . "\n" ?> |
|
| 177 | 177 | <?php else: ?> |
| 178 | - * @param <?= $column->getType () ?> $<?= $column->getName () . "\n" ?> |
|
| 178 | + * @param <?= $column->getType() ?> $<?= $column->getName() . "\n" ?> |
|
| 179 | 179 | <?php endif; ?> |
| 180 | 180 | * @return <?= $className . "\n" ?> |
| 181 | 181 | */ |
| 182 | - public function set<?= \Classes\Maker\AbstractMaker::getClassName ( $column->getName () ) ?>( $<?= $column->getName ( |
|
| 182 | + public function set<?= \Classes\Maker\AbstractMaker::getClassName($column->getName()) ?>( $<?= $column->getName( |
|
| 183 | 183 | ) ?> ) |
| 184 | 184 | { |
| 185 | -<?php switch ( strtolower( $column->getType () ) ): |
|
| 185 | +<?php switch (strtolower($column->getType())): |
|
| 186 | 186 | case 'timestamp': |
| 187 | 187 | case 'date': |
| 188 | 188 | case 'datetime':?> |
| 189 | - if (! empty($<?= $column->getName () ?>)) |
|
| 189 | + if (! empty($<?= $column->getName() ?>)) |
|
| 190 | 190 | { |
| 191 | - if (! $<?= $column->getName () ?> instanceof Zend_Date) |
|
| 191 | + if (! $<?= $column->getName() ?> instanceof Zend_Date) |
|
| 192 | 192 | { |
| 193 | - $<?= $column->getName () ?> = new Zend_Date($<?= $column->getName () ?>); |
|
| 193 | + $<?= $column->getName() ?> = new Zend_Date($<?= $column->getName() ?>); |
|
| 194 | 194 | } |
| 195 | -<?php if( $column->equalType ( 'date' ) ): ?> |
|
| 196 | - $<?= $column->getName () ?>->setOptions(array('format_type' => 'php')); |
|
| 195 | +<?php if ($column->equalType('date')): ?> |
|
| 196 | + $<?= $column->getName() ?>->setOptions(array('format_type' => 'php')); |
|
| 197 | 197 | <?php endif ?> |
| 198 | -<?php $format = 'Zend_Date::ISO_8601' ?> |
|
| 199 | -<?php if( $column->equalType ( 'date' ) ) { $format = '\'Y-m-d\''; } ?> |
|
| 200 | - $<?= $column->getName () ?> = $<?= $column->getName () ?>->toString( <?=$format?> ); |
|
| 198 | +<?php $format = 'Zend_Date::ISO_8601' ?> |
|
| 199 | +<?php if ($column->equalType('date')) { $format = '\'Y-m-d\''; } ?> |
|
| 200 | + $<?= $column->getName() ?> = $<?= $column->getName() ?>->toString( <?=$format?> ); |
|
| 201 | 201 | } |
| 202 | -<?php if($column->isNullable ()):?> |
|
| 202 | +<?php if ($column->isNullable()):?> |
|
| 203 | 203 | else{ |
| 204 | - $<?= $column->getName () ?> = null; |
|
| 204 | + $<?= $column->getName() ?> = null; |
|
| 205 | 205 | } |
| 206 | 206 | <?php endif ?> |
| 207 | 207 | <?php break; |
| 208 | 208 | case 'boolean': |
| 209 | -if(!$column->isNullable ()):?> |
|
| 210 | - $<?= $column->getName () ?> = intval( $<?= $column->getName () ?> ); |
|
| 209 | +if ( ! $column->isNullable()):?> |
|
| 210 | + $<?= $column->getName() ?> = intval( $<?= $column->getName() ?> ); |
|
| 211 | 211 | <?php endif ?> |
| 212 | 212 | <?php default: ?> |
| 213 | -<?php if(!$column->isNullable () && ($column->getType () != 'boolean')):?> |
|
| 214 | - $<?= $column->getName () ?> = (<?= ucfirst ( $column->getType () ) ?>) $<?= $column->getName () ?> ; |
|
| 213 | +<?php if ( ! $column->isNullable() && ($column->getType() != 'boolean')):?> |
|
| 214 | + $<?= $column->getName() ?> = (<?= ucfirst($column->getType()) ?>) $<?= $column->getName() ?> ; |
|
| 215 | 215 | <?php endif ?> |
| 216 | - $input = new Zend_Filter_Input($this->getFilters(), $this->getValidator(), array('<?= $column->getName () ?>'=>$<?= $column->getName () ?> )); |
|
| 216 | + $input = new Zend_Filter_Input($this->getFilters(), $this->getValidator(), array('<?= $column->getName() ?>'=>$<?= $column->getName() ?> )); |
|
| 217 | 217 | |
| 218 | - if(!$input->isValid ('<?= $column->getName () ?>')) |
|
| 218 | + if(!$input->isValid ('<?= $column->getName() ?>')) |
|
| 219 | 219 | { |
| 220 | 220 | $errors = $input->getMessages (); |
| 221 | - foreach ( $errors['<?= $column->getName () ?>'] as $key => $value ) |
|
| 221 | + foreach ( $errors['<?= $column->getName() ?>'] as $key => $value ) |
|
| 222 | 222 | { |
| 223 | - throw new <?= $this->config->namespace ? $this->config->namespace . "_" : "" ?>Model_EntityException ( '<?= $column->getName () ?> - ' . $value ); |
|
| 223 | + throw new <?= $this->config->namespace ? $this->config->namespace . "_" : "" ?>Model_EntityException ( '<?= $column->getName() ?> - ' . $value ); |
|
| 224 | 224 | } |
| 225 | 225 | } |
| 226 | 226 | <?php break ?> |
| 227 | 227 | <?php endswitch ?> |
| 228 | 228 | |
| 229 | - $this-><?= $column->getName () ?> = $<?= $column->getName () ?> ; |
|
| 229 | + $this-><?= $column->getName() ?> = $<?= $column->getName() ?> ; |
|
| 230 | 230 | return $this; |
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | /** |
| 234 | - * Gets column <?= $column->getName () . "\n" ?> |
|
| 234 | + * Gets column <?= $column->getName() . "\n" ?> |
|
| 235 | 235 | * |
| 236 | -<?php if ( $column->equalType ( 'date' ) or $column->equalType ( 'datetime' ) or $column->equalType ( 'timestamp' ) ): ?> |
|
| 236 | +<?php if ($column->equalType('date') or $column->equalType('datetime') or $column->equalType('timestamp')): ?> |
|
| 237 | 237 | * @param boolean $returnZendDate |
| 238 | 238 | * @return Zend_Date|null|string Zend_Date representation of this datetime if enabled, or ISO 8601 string if not |
| 239 | 239 | <?php else: ?> |
| 240 | - * @return <?= $column->getType () . "\n" ?> |
|
| 240 | + * @return <?= $column->getType() . "\n" ?> |
|
| 241 | 241 | <?php endif; ?> |
| 242 | 242 | */ |
| 243 | - public function get<?= \Classes\Maker\AbstractMaker::getClassName ( |
|
| 244 | - $column->getName () |
|
| 245 | - ) ?>(<?php if ( $column->equalType ( 'date' ) or $column->equalType ( 'datetime' ) or $column->equalType ( 'timestamp' ) ): ?>$format = false <?php endif; ?>) |
|
| 243 | + public function get<?= \Classes\Maker\AbstractMaker::getClassName( |
|
| 244 | + $column->getName() |
|
| 245 | + ) ?>(<?php if ($column->equalType('date') or $column->equalType('datetime') or $column->equalType('timestamp')): ?>$format = false <?php endif; ?>) |
|
| 246 | 246 | { |
| 247 | -<?php switch ( strtolower( $column->getType () ) ): |
|
| 247 | +<?php switch (strtolower($column->getType())): |
|
| 248 | 248 | case 'timestamp': |
| 249 | 249 | case 'date': |
| 250 | 250 | case 'datetime':?> |
| 251 | 251 | if ($format) |
| 252 | 252 | { |
| 253 | - if ($this->_data['<?= $column->getName () ?>'] === null) |
|
| 253 | + if ($this->_data['<?= $column->getName() ?>'] === null) |
|
| 254 | 254 | { |
| 255 | 255 | return null; |
| 256 | 256 | } |
| 257 | 257 | |
| 258 | - $objDate = new Zend_Date($this-><?= $column->getName () ?>, $format ); |
|
| 258 | + $objDate = new Zend_Date($this-><?= $column->getName() ?>, $format ); |
|
| 259 | 259 | |
| 260 | 260 | return $objDate->toString($format); |
| 261 | 261 | } |
| 262 | 262 | <?php break ?> |
| 263 | 263 | <?php endswitch ?> |
| 264 | - return $this-><?= $column->getName () ?>; |
|
| 264 | + return $this-><?= $column->getName() ?>; |
|
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | <?php endforeach; ?> |
| 268 | -<?php foreach ( $parents as $parent ): ?> |
|
| 268 | +<?php foreach ($parents as $parent): ?> |
|
| 269 | 269 | /** |
| 270 | - * Gets parent <?= $parent[ 'table' ] . "\n" ?> |
|
| 270 | + * Gets parent <?= $parent['table'] . "\n" ?> |
|
| 271 | 271 | * |
| 272 | - * @return <?= $parent[ 'class' ] . "\n" ?> |
|
| 272 | + * @return <?= $parent['class'] . "\n" ?> |
|
| 273 | 273 | */ |
| 274 | - public function get<?= $parent[ 'function' ] ?>() |
|
| 274 | + public function get<?= $parent['function'] ?>() |
|
| 275 | 275 | { |
| 276 | - if ($this->_parent_<?= $parent[ 'variable' ] ?> === null) |
|
| 276 | + if ($this->_parent_<?= $parent['variable'] ?> === null) |
|
| 277 | 277 | { |
| 278 | - $this->_parent_<?= $parent[ 'variable' ] ?> = $this->findParentRow('<?= $objTables->getNamespace ( |
|
| 279 | - ) ?>_DbTable_<?= \Classes\Maker\AbstractMaker::getClassName ( |
|
| 280 | - $parent[ 'table' ] |
|
| 281 | - ) ?>', '<?= \Classes\Maker\AbstractMaker::getClassName ( $parent[ 'variable' ] ) ?>'); |
|
| 278 | + $this->_parent_<?= $parent['variable'] ?> = $this->findParentRow('<?= $objTables->getNamespace( |
|
| 279 | + ) ?>_DbTable_<?= \Classes\Maker\AbstractMaker::getClassName( |
|
| 280 | + $parent['table'] |
|
| 281 | + ) ?>', '<?= \Classes\Maker\AbstractMaker::getClassName($parent['variable']) ?>'); |
|
| 282 | 282 | } |
| 283 | 283 | |
| 284 | - return $this->_parent_<?= $parent[ 'variable' ] ?>; |
|
| 284 | + return $this->_parent_<?= $parent['variable'] ?>; |
|
| 285 | 285 | } |
| 286 | 286 | |
| 287 | 287 | <?php endforeach; ?> |
| 288 | 288 | |
| 289 | 289 | |
| 290 | -<?php foreach ( $depends as $depend ): ?> |
|
| 290 | +<?php foreach ($depends as $depend): ?> |
|
| 291 | 291 | /** |
| 292 | - * Gets dependent <?= $depend[ 'table' ] . "\n" ?> |
|
| 292 | + * Gets dependent <?= $depend['table'] . "\n" ?> |
|
| 293 | 293 | * |
| 294 | - * @return <?= $depend[ 'class' ] . "\n" ?> |
|
| 294 | + * @return <?= $depend['class'] . "\n" ?> |
|
| 295 | 295 | */ |
| 296 | - public function get<?= $depend[ 'function' ] ?>() |
|
| 296 | + public function get<?= $depend['function'] ?>() |
|
| 297 | 297 | { |
| 298 | - if ($this->_depend_<?= $depend[ 'variable' ] ?> === null) |
|
| 298 | + if ($this->_depend_<?= $depend['variable'] ?> === null) |
|
| 299 | 299 | { |
| 300 | - $this->_depend_<?= $depend[ 'variable' ] ?> = $this->findDependentRowset('<?= $objTables->getNamespace ( |
|
| 301 | - ) ?>_DbTable_<?= \Classes\Maker\AbstractMaker::getClassName ( $depend[ 'table' ] ) ?>'); |
|
| 300 | + $this->_depend_<?= $depend['variable'] ?> = $this->findDependentRowset('<?= $objTables->getNamespace( |
|
| 301 | + ) ?>_DbTable_<?= \Classes\Maker\AbstractMaker::getClassName($depend['table']) ?>'); |
|
| 302 | 302 | } |
| 303 | 303 | |
| 304 | - return $this->_depend_<?= $depend[ 'variable' ] ?>; |
|
| 304 | + return $this->_depend_<?= $depend['variable'] ?>; |
|
| 305 | 305 | } |
| 306 | 306 | |
| 307 | 307 | <?php endforeach; ?> |
@@ -174,9 +174,12 @@ discard block |
||
| 174 | 174 | * Stored in ISO 8601 format. |
| 175 | 175 | * |
| 176 | 176 | * @param string|Zend_Date $<?= $column->getName () . "\n" ?> |
| 177 | -<?php else: ?> |
|
| 177 | +<?php else { |
|
| 178 | + : ?> |
|
| 178 | 179 | * @param <?= $column->getType () ?> $<?= $column->getName () . "\n" ?> |
| 179 | -<?php endif; ?> |
|
| 180 | +<?php endif; |
|
| 181 | +} |
|
| 182 | +?> |
|
| 180 | 183 | * @return <?= $className . "\n" ?> |
| 181 | 184 | */ |
| 182 | 185 | public function set<?= \Classes\Maker\AbstractMaker::getClassName ( $column->getName () ) ?>( $<?= $column->getName ( |
@@ -236,9 +239,12 @@ discard block |
||
| 236 | 239 | <?php if ( $column->equalType ( 'date' ) or $column->equalType ( 'datetime' ) or $column->equalType ( 'timestamp' ) ): ?> |
| 237 | 240 | * @param boolean $returnZendDate |
| 238 | 241 | * @return Zend_Date|null|string Zend_Date representation of this datetime if enabled, or ISO 8601 string if not |
| 239 | -<?php else: ?> |
|
| 242 | +<?php else { |
|
| 243 | + : ?> |
|
| 240 | 244 | * @return <?= $column->getType () . "\n" ?> |
| 241 | -<?php endif; ?> |
|
| 245 | +<?php endif; |
|
| 246 | +} |
|
| 247 | +?> |
|
| 242 | 248 | */ |
| 243 | 249 | public function get<?= \Classes\Maker\AbstractMaker::getClassName ( |
| 244 | 250 | $column->getName () |
@@ -3,19 +3,19 @@ discard block |
||
| 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"?> |
|
| 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 | -abstract class <?=$this->config->namespace?$this->config->namespace."_":""?>Model_EntityAbstract extends Zend_Db_Table_Row_Abstract |
|
| 18 | +abstract class <?=$this->config->namespace ? $this->config->namespace . "_" : ""?>Model_EntityAbstract extends Zend_Db_Table_Row_Abstract |
|
| 19 | 19 | { |
| 20 | 20 | |
| 21 | 21 | /** |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | |
| 76 | 76 | /** |
| 77 | 77 | * @param array $data |
| 78 | - * @return <?=$this->config->namespace?$this->config->namespace."_":""?>Model_EntityAbstract |
|
| 78 | + * @return <?=$this->config->namespace ? $this->config->namespace . "_" : ""?>Model_EntityAbstract |
|
| 79 | 79 | */ |
| 80 | 80 | public static function getIntance($data = array()) |
| 81 | 81 | { |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | * Array com values dos set deste model. |
| 218 | 218 | * |
| 219 | 219 | * @param array $data |
| 220 | - * @return <?=$this->config->namespace?$this->config->namespace."_":""?>Model_EntityAbstract |
|
| 220 | + * @return <?=$this->config->namespace ? $this->config->namespace . "_" : ""?>Model_EntityAbstract |
|
| 221 | 221 | */ |
| 222 | 222 | public function populate ( array $data ) |
| 223 | 223 | { |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | /** |
| 243 | 243 | * Retorna o nome da coluna da primary key |
| 244 | 244 | * |
| 245 | - * @see <?=$this->config->namespace?$this->config->namespace."_":""?>Model_DbTable_TableAbstract::getPrimaryKeyName() |
|
| 245 | + * @see <?=$this->config->namespace ? $this->config->namespace . "_" : ""?>Model_DbTable_TableAbstract::getPrimaryKeyName() |
|
| 246 | 246 | * @return string|array The name or array of names which form the primary key |
| 247 | 247 | */ |
| 248 | 248 | public function getPrimaryKeyName() |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | /** |
| 254 | 254 | * @param int $primarykey |
| 255 | 255 | * |
| 256 | - * @return <?=$this->config->namespace?$this->config->namespace."_":""?>Model_EntityAbstract |
|
| 256 | + * @return <?=$this->config->namespace ? $this->config->namespace . "_" : ""?>Model_EntityAbstract |
|
| 257 | 257 | */ |
| 258 | 258 | public function find ( $primarykey ) |
| 259 | 259 | { |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | /** |
| 268 | 268 | * @see Zend_Db_Table_Rowset_Abstract::fetchAll |
| 269 | 269 | * |
| 270 | - * @return <?=$this->config->namespace?$this->config->namespace."_":""?>Model_EntityAbstract[] |
|
| 270 | + * @return <?=$this->config->namespace ? $this->config->namespace . "_" : ""?>Model_EntityAbstract[] |
|
| 271 | 271 | */ |
| 272 | 272 | public function fetchAll ( $where = null , $order = null , $count = null , $offset = null ) |
| 273 | 273 | { |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | * Retorna o objeto pela primary key |
| 279 | 279 | * |
| 280 | 280 | * @param int|array $primary_key |
| 281 | - * @return <?=$this->config->namespace?$this->config->namespace."_":""?>Model_EntityAbstract |
|
| 281 | + * @return <?=$this->config->namespace ? $this->config->namespace . "_" : ""?>Model_EntityAbstract |
|
| 282 | 282 | */ |
| 283 | 283 | public static function retrieve ( $primarykey ) |
| 284 | 284 | { |
@@ -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 AbstractEntity extends \Phalcon\Mvc\Model |
| 21 | 21 | { |
@@ -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 | use Phalcon\Mvc\Model; |
| 21 | 21 | |
@@ -20,13 +20,13 @@ |
||
| 20 | 20 | ; database host |
| 21 | 21 | host = <?= $host ?><?= "\n" ?> |
| 22 | 22 | ; database name |
| 23 | -database = "<?= isset( $database ) ? $database : '' ?>"<?= "\n" ?> |
|
| 23 | +database = "<?= isset($database) ? $database : '' ?>"<?= "\n" ?> |
|
| 24 | 24 | ; database schema name (one or more than one) |
| 25 | -<?= isset( $schema ) ? 'schema = ' . $schema : ';schema = public' ?><?= "\n" ?> |
|
| 25 | +<?= isset($schema) ? 'schema = ' . $schema : ';schema = public' ?><?= "\n" ?> |
|
| 26 | 26 | ; database user |
| 27 | -username = <?= isset( $username ) ? $username : '' ?><?= "\n" ?> |
|
| 27 | +username = <?= isset($username) ? $username : '' ?><?= "\n" ?> |
|
| 28 | 28 | ; database password |
| 29 | -password = <?= isset( $password ) ? $password : '' ?><?= "\n" ?> |
|
| 29 | +password = <?= isset($password) ? $password : '' ?><?= "\n" ?> |
|
| 30 | 30 | ; show status of implementation carried out after completing the process |
| 31 | 31 | status = false |
| 32 | 32 | ; table name (parameter can be used more then once) |
@@ -16,9 +16,9 @@ |
||
| 16 | 16 | { |
| 17 | 17 | private $msg = "As configuracoes a seguir sao obrigatorias: \033[0;31m%value%\033[0m\n"; |
| 18 | 18 | |
| 19 | - public function __construct ( $array , $code = 0 ) |
|
| 19 | + public function __construct($array, $code = 0) |
|
| 20 | 20 | { |
| 21 | - $attribs = implode ( ', ' , array_keys ( $array ) ); |
|
| 22 | - parent::__construct ( str_replace ( "%value%" , $attribs , $this->msg ) , (int) $code ); |
|
| 21 | + $attribs = implode(', ', array_keys($array)); |
|
| 22 | + parent::__construct(str_replace("%value%", $attribs, $this->msg), (int) $code); |
|
| 23 | 23 | } |
| 24 | 24 | } |
| 25 | 25 | \ No newline at end of file |
@@ -10,11 +10,11 @@ |
||
| 10 | 10 | */ |
| 11 | 11 | class Dblib extends Mssql |
| 12 | 12 | { |
| 13 | - public function getPDOString () |
|
| 13 | + public function getPDOString() |
|
| 14 | 14 | { |
| 15 | - return sprintf ( |
|
| 16 | - "dblib:host=%s;dbname=%s" , |
|
| 17 | - $this->getHost () , |
|
| 15 | + return sprintf( |
|
| 16 | + "dblib:host=%s;dbname=%s", |
|
| 17 | + $this->getHost(), |
|
| 18 | 18 | $this->database |
| 19 | 19 | ); |
| 20 | 20 | } |
@@ -178,14 +178,14 @@ discard block |
||
| 178 | 178 | $strSchema = implode ( "', '" , $this->schema ); |
| 179 | 179 | |
| 180 | 180 | $this->totalTables = $this->getPDO () |
| 181 | - ->query ( |
|
| 182 | - "SELECT COUNT(table_name) AS total |
|
| 181 | + ->query ( |
|
| 182 | + "SELECT COUNT(table_name) AS total |
|
| 183 | 183 | FROM {$this->database}.information_schema.tables |
| 184 | 184 | WHERE |
| 185 | 185 | table_type = 'BASE TABLE' |
| 186 | 186 | AND table_schema IN ( '" . $strSchema . "' ) $sqlTables" |
| 187 | - ) |
|
| 188 | - ->fetchColumn (); |
|
| 187 | + ) |
|
| 188 | + ->fetchColumn (); |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | 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 is_identity FROM sys.columns WHERE object_id = object_id('{$schema}.{$table}') AND name = '{$column}';" |
|
| 199 | - ) |
|
| 200 | - ->fetchColumn(); |
|
| 197 | + ->query ( |
|
| 198 | + "SELECT is_identity FROM sys.columns WHERE object_id = object_id('{$schema}.{$table}') AND name = '{$column}';" |
|
| 199 | + ) |
|
| 200 | + ->fetchColumn(); |
|
| 201 | 201 | |
| 202 | 202 | if ( ! $return ) |
| 203 | 203 | { |
@@ -24,13 +24,13 @@ discard block |
||
| 24 | 24 | */ |
| 25 | 25 | protected $port; |
| 26 | 26 | |
| 27 | - protected $schema = array ( 'public' ); |
|
| 27 | + protected $schema = array('public'); |
|
| 28 | 28 | |
| 29 | - public function __construct ( AbstractAdapter $adapterConfig ) |
|
| 29 | + public function __construct(AbstractAdapter $adapterConfig) |
|
| 30 | 30 | { |
| 31 | - parent::__construct ( $adapterConfig ); |
|
| 32 | - if ( $adapterConfig->hasSchemas () ) { |
|
| 33 | - $this->schema = $adapterConfig->getSchemas (); |
|
| 31 | + parent::__construct($adapterConfig); |
|
| 32 | + if ($adapterConfig->hasSchemas()) { |
|
| 33 | + $this->schema = $adapterConfig->getSchemas(); |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | } |
@@ -38,33 +38,33 @@ discard block |
||
| 38 | 38 | /** |
| 39 | 39 | * @inheritDoc |
| 40 | 40 | */ |
| 41 | - protected function convertTypeToSimple ( $str ) |
|
| 41 | + protected function convertTypeToSimple($str) |
|
| 42 | 42 | { |
| 43 | - if ( preg_match ( '/(tinyint|bit)/' , $str ) ) |
|
| 43 | + if (preg_match('/(tinyint|bit)/', $str)) |
|
| 44 | 44 | { |
| 45 | 45 | $res = 'boolean'; |
| 46 | - } elseif ( preg_match ( '/(date|time|text|binary|char|xml|uniqueidentifier)/' , $str ) ) |
|
| 46 | + } elseif (preg_match('/(date|time|text|binary|char|xml|uniqueidentifier)/', $str)) |
|
| 47 | 47 | { |
| 48 | 48 | $res = 'string'; |
| 49 | - } elseif ( preg_match ( '/(decimal|numeric|real|float|money)/' , $str ) ) |
|
| 49 | + } elseif (preg_match('/(decimal|numeric|real|float|money)/', $str)) |
|
| 50 | 50 | { |
| 51 | 51 | $res = 'float'; |
| 52 | - } elseif ( preg_match ( '#^(?:tiny|small|medium|long|big|var)?(\w+)(?:\(\d+\))?(?:\s\w+)*$#' , $str , $matches ) ) |
|
| 52 | + } elseif (preg_match('#^(?:tiny|small|medium|long|big|var)?(\w+)(?:\(\d+\))?(?:\s\w+)*$#', $str, $matches)) |
|
| 53 | 53 | { |
| 54 | - $res = $matches[ 1 ]; |
|
| 54 | + $res = $matches[1]; |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | return $res; |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - protected function getHost(){ |
|
| 60 | + protected function getHost() { |
|
| 61 | 61 | $host = $this->host; |
| 62 | - if (!empty($this->port)) { |
|
| 62 | + if ( ! empty($this->port)) { |
|
| 63 | 63 | $seperator = ':'; |
| 64 | 64 | if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { |
| 65 | 65 | $seperator = ','; |
| 66 | 66 | } |
| 67 | - $host .= $seperator . $this->port; |
|
| 67 | + $host .= $seperator . $this->port; |
|
| 68 | 68 | unset($this->port); |
| 69 | 69 | } |
| 70 | 70 | |
@@ -75,11 +75,11 @@ discard block |
||
| 75 | 75 | * @inheritDoc |
| 76 | 76 | * @return string |
| 77 | 77 | */ |
| 78 | - public function getPDOString () |
|
| 78 | + public function getPDOString() |
|
| 79 | 79 | { |
| 80 | - return sprintf ( |
|
| 81 | - "mssql:host=%s;dbname=%s" , |
|
| 82 | - $this->getHost() , |
|
| 80 | + return sprintf( |
|
| 81 | + "mssql:host=%s;dbname=%s", |
|
| 82 | + $this->getHost(), |
|
| 83 | 83 | $this->database |
| 84 | 84 | ); |
| 85 | 85 | } |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | * @inheritDoc |
| 89 | 89 | * @return string |
| 90 | 90 | */ |
| 91 | - public function getPDOSocketString () |
|
| 91 | + public function getPDOSocketString() |
|
| 92 | 92 | { |
| 93 | 93 | // TODO: implement here |
| 94 | 94 | return ""; |
@@ -98,18 +98,18 @@ discard block |
||
| 98 | 98 | * @inheritDoc |
| 99 | 99 | * @return string[] |
| 100 | 100 | */ |
| 101 | - public function getListNameTable () |
|
| 101 | + public function getListNameTable() |
|
| 102 | 102 | { |
| 103 | - if ( empty( $this->tableList ) ) |
|
| 103 | + if (empty($this->tableList)) |
|
| 104 | 104 | { |
| 105 | 105 | |
| 106 | - $sqlTables = ! empty( $this->tablesName ) |
|
| 106 | + $sqlTables = ! empty($this->tablesName) |
|
| 107 | 107 | ? "AND table_name IN ( $this->tablesName )" : ''; |
| 108 | 108 | |
| 109 | - $strSchema = implode ( "', '" , $this->schema ); |
|
| 109 | + $strSchema = implode("', '", $this->schema); |
|
| 110 | 110 | |
| 111 | - $this->tableList = $this->getPDO () |
|
| 112 | - ->query ( |
|
| 111 | + $this->tableList = $this->getPDO() |
|
| 112 | + ->query( |
|
| 113 | 113 | "SELECT table_schema, |
| 114 | 114 | table_name |
| 115 | 115 | FROM {$this->database}.information_schema.tables |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | table_name |
| 122 | 122 | ASC" |
| 123 | 123 | ) |
| 124 | - ->fetchAll (); |
|
| 124 | + ->fetchAll(); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | return $this->tableList; |
@@ -138,14 +138,14 @@ discard block |
||
| 138 | 138 | * |
| 139 | 139 | * @return array |
| 140 | 140 | */ |
| 141 | - public function getListColumns () |
|
| 141 | + public function getListColumns() |
|
| 142 | 142 | { |
| 143 | - $sqlTables = ! empty( $this->tablesName ) |
|
| 143 | + $sqlTables = ! empty($this->tablesName) |
|
| 144 | 144 | ? "AND c.table_name IN ( $this->tablesName )" : ''; |
| 145 | - $strSchema = implode ( "', '" , $this->schema ); |
|
| 145 | + $strSchema = implode("', '", $this->schema); |
|
| 146 | 146 | |
| 147 | - return $this->getPDO () |
|
| 148 | - ->query ( |
|
| 147 | + return $this->getPDO() |
|
| 148 | + ->query( |
|
| 149 | 149 | "SELECT distinct |
| 150 | 150 | c.table_schema, |
| 151 | 151 | c.table_name, |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | $sqlTables and c.table_schema IN ('$strSchema') |
| 161 | 161 | order by c.table_name asc" |
| 162 | 162 | ) |
| 163 | - ->fetchAll ( \PDO::FETCH_ASSOC ); |
|
| 163 | + ->fetchAll(\PDO::FETCH_ASSOC); |
|
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | /** |
@@ -168,38 +168,38 @@ discard block |
||
| 168 | 168 | * |
| 169 | 169 | * @return int |
| 170 | 170 | */ |
| 171 | - public function getTotalTables () |
|
| 171 | + public function getTotalTables() |
|
| 172 | 172 | { |
| 173 | - if ( empty( $this->totalTables ) ) |
|
| 173 | + if (empty($this->totalTables)) |
|
| 174 | 174 | { |
| 175 | - $sqlTables = ! empty( $this->tablesName ) |
|
| 175 | + $sqlTables = ! empty($this->tablesName) |
|
| 176 | 176 | ? "AND table_name IN ( $this->tablesName )" : ''; |
| 177 | 177 | |
| 178 | - $strSchema = implode ( "', '" , $this->schema ); |
|
| 178 | + $strSchema = implode("', '", $this->schema); |
|
| 179 | 179 | |
| 180 | - $this->totalTables = $this->getPDO () |
|
| 181 | - ->query ( |
|
| 180 | + $this->totalTables = $this->getPDO() |
|
| 181 | + ->query( |
|
| 182 | 182 | "SELECT COUNT(table_name) AS total |
| 183 | 183 | FROM {$this->database}.information_schema.tables |
| 184 | 184 | WHERE |
| 185 | 185 | table_type = 'BASE TABLE' |
| 186 | 186 | AND table_schema IN ( '" . $strSchema . "' ) $sqlTables" |
| 187 | 187 | ) |
| 188 | - ->fetchColumn (); |
|
| 188 | + ->fetchColumn(); |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | return (int) $this->totalTables; |
| 192 | 192 | } |
| 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 is_identity FROM sys.columns WHERE object_id = object_id('{$schema}.{$table}') AND name = '{$column}';" |
| 199 | 199 | ) |
| 200 | 200 | ->fetchColumn(); |
| 201 | 201 | |
| 202 | - if ( ! $return ) |
|
| 202 | + if ( ! $return) |
|
| 203 | 203 | { |
| 204 | 204 | return; |
| 205 | 205 | } |
@@ -207,14 +207,14 @@ discard block |
||
| 207 | 207 | return "{$table}_{$column}_seq"; |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | - public function getListConstrant () |
|
| 210 | + public function getListConstrant() |
|
| 211 | 211 | { |
| 212 | - $sqlTables = ! empty( $this->tablesName ) |
|
| 212 | + $sqlTables = ! empty($this->tablesName) |
|
| 213 | 213 | ? "AND tc.table_name IN ( $this->tablesName )" : ''; |
| 214 | - $strSchema = implode ( "', '" , $this->schema ); |
|
| 214 | + $strSchema = implode("', '", $this->schema); |
|
| 215 | 215 | |
| 216 | - return $this->getPDO () |
|
| 217 | - ->query ( |
|
| 216 | + return $this->getPDO() |
|
| 217 | + ->query( |
|
| 218 | 218 | "SELECT distinct |
| 219 | 219 | tc.constraint_type, |
| 220 | 220 | tc.constraint_name, |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | AND tc.constraint_schema = ccu.constraint_schema |
| 237 | 237 | ORDER by tc.table_schema" |
| 238 | 238 | ) |
| 239 | - ->fetchAll ( \PDO::FETCH_ASSOC ); |
|
| 239 | + ->fetchAll(\PDO::FETCH_ASSOC); |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | } |