@@ -298,8 +298,8 @@ |
||
298 | 298 | public function getSequence ( $table , $column ) |
299 | 299 | { |
300 | 300 | $return = $this->getPDO () |
301 | - ->query ( "select * from information_schema.columns where extra like '%auto_increment%' and TABLE_SCHEMA='{$this->database}' AND TABLE_NAME='{$table}' AND COLUMN_NAME='{$column}';" ) |
|
302 | - ->fetch ( \PDO::FETCH_ASSOC ); |
|
301 | + ->query ( "select * from information_schema.columns where extra like '%auto_increment%' and TABLE_SCHEMA='{$this->database}' AND TABLE_NAME='{$table}' AND COLUMN_NAME='{$column}';" ) |
|
302 | + ->fetch ( \PDO::FETCH_ASSOC ); |
|
303 | 303 | |
304 | 304 | if ( ! $return ) |
305 | 305 | { |
@@ -30,21 +30,21 @@ discard block |
||
30 | 30 | * |
31 | 31 | * @return string |
32 | 32 | */ |
33 | - protected function convertTypeToPhp ( $str ) |
|
33 | + protected function convertTypeToPhp($str) |
|
34 | 34 | { |
35 | 35 | $res = ''; |
36 | - if ( preg_match ( '/(tinyint\(1\)|bit)/' , $str ) ) |
|
36 | + if (preg_match('/(tinyint\(1\)|bit)/', $str)) |
|
37 | 37 | { |
38 | 38 | $res = 'boolean'; |
39 | - } elseif ( preg_match ( '/(datetime|timestamp|blob|char|enum|text|date)/' , $str ) ) |
|
39 | + } elseif (preg_match('/(datetime|timestamp|blob|char|enum|text|date)/', $str)) |
|
40 | 40 | { |
41 | 41 | $res = 'string'; |
42 | - } elseif ( preg_match ( '/(decimal|numeric|float|double)/' , $str ) ) |
|
42 | + } elseif (preg_match('/(decimal|numeric|float|double)/', $str)) |
|
43 | 43 | { |
44 | 44 | $res = 'float'; |
45 | - } elseif ( preg_match ( '#^(?:tiny|small|medium|long|big|var)?(\w+)(?:\(\d+\))?(?:\s\w+)*$#' , $str , $matches ) ) |
|
45 | + } elseif (preg_match('#^(?:tiny|small|medium|long|big|var)?(\w+)(?:\(\d+\))?(?:\s\w+)*$#', $str, $matches)) |
|
46 | 46 | { |
47 | - $res = $matches[ 1 ]; |
|
47 | + $res = $matches[1]; |
|
48 | 48 | } else |
49 | 49 | { |
50 | 50 | print "Can't convert column type to PHP - Unrecognized type: $str"; |
@@ -57,12 +57,12 @@ discard block |
||
57 | 57 | * @inheritDoc |
58 | 58 | * @return string |
59 | 59 | */ |
60 | - public function getPDOString () |
|
60 | + public function getPDOString() |
|
61 | 61 | { |
62 | - return sprintf ( |
|
63 | - "mysql:host=%s;port=%s;dbname=%s" , |
|
64 | - $this->host , |
|
65 | - $this->port , |
|
62 | + return sprintf( |
|
63 | + "mysql:host=%s;port=%s;dbname=%s", |
|
64 | + $this->host, |
|
65 | + $this->port, |
|
66 | 66 | $this->database |
67 | 67 | |
68 | 68 | ); |
@@ -72,11 +72,11 @@ discard block |
||
72 | 72 | * @inheritDoc |
73 | 73 | * @return string |
74 | 74 | */ |
75 | - public function getPDOSocketString () |
|
75 | + public function getPDOSocketString() |
|
76 | 76 | { |
77 | - return sprintf ( |
|
78 | - "mysql:unix_socket=%s;dbname=%s" , |
|
79 | - $this->socket , |
|
77 | + return sprintf( |
|
78 | + "mysql:unix_socket=%s;dbname=%s", |
|
79 | + $this->socket, |
|
80 | 80 | $this->database |
81 | 81 | |
82 | 82 | ); |
@@ -86,13 +86,13 @@ discard block |
||
86 | 86 | * @inheritDoc |
87 | 87 | * @return string[] |
88 | 88 | */ |
89 | - public function getListNameTable () |
|
89 | + public function getListNameTable() |
|
90 | 90 | { |
91 | - if ( empty( $this->tableList ) ) |
|
91 | + if (empty($this->tableList)) |
|
92 | 92 | { |
93 | - $this->tableList = $this->getPDO ()->query ( |
|
93 | + $this->tableList = $this->getPDO()->query( |
|
94 | 94 | "show tables" |
95 | - )->fetchAll (); |
|
95 | + )->fetchAll(); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | return $this->tableList; |
@@ -103,10 +103,10 @@ discard block |
||
103 | 103 | * |
104 | 104 | * @return array[] |
105 | 105 | */ |
106 | - public function getListColumns () |
|
106 | + public function getListColumns() |
|
107 | 107 | { |
108 | 108 | |
109 | - return $this->getPDO ()->query ( |
|
109 | + return $this->getPDO()->query( |
|
110 | 110 | "select |
111 | 111 | 0 AS table_schema, |
112 | 112 | table_name, |
@@ -117,15 +117,15 @@ discard block |
||
117 | 117 | from information_schema.columns |
118 | 118 | where table_schema IN ('{$this->database}') |
119 | 119 | order by table_name,ordinal_position" |
120 | - )->fetchAll ( \PDO::FETCH_ASSOC ); |
|
120 | + )->fetchAll(\PDO::FETCH_ASSOC); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
124 | 124 | * @return array |
125 | 125 | */ |
126 | - public function getListConstrant () |
|
126 | + public function getListConstrant() |
|
127 | 127 | { |
128 | - return $this->getPDO ()->query ( |
|
128 | + return $this->getPDO()->query( |
|
129 | 129 | "SELECT distinct |
130 | 130 | i.constraint_type, |
131 | 131 | k.constraint_name, |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | WHERE |
143 | 143 | i.TABLE_SCHEMA IN ('{$this->database}') AND i.CONSTRAINT_TYPE IN ('FOREIGN KEY', 'PRIMARY KEY' ) |
144 | 144 | order by k.table_schema, k.table_name;" |
145 | - )->fetchAll ( \PDO::FETCH_ASSOC ); |
|
145 | + )->fetchAll(\PDO::FETCH_ASSOC); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | /** |
@@ -150,14 +150,14 @@ discard block |
||
150 | 150 | * |
151 | 151 | * @return int |
152 | 152 | */ |
153 | - public function getTotalTables () |
|
153 | + public function getTotalTables() |
|
154 | 154 | { |
155 | - if ( empty( $this->totalTables ) ) |
|
155 | + if (empty($this->totalTables)) |
|
156 | 156 | { |
157 | 157 | |
158 | - $this->totalTables = $this->getPDO ()->query ( |
|
158 | + $this->totalTables = $this->getPDO()->query( |
|
159 | 159 | "SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = '{$this->database}'" |
160 | - )->fetchColumn (); |
|
160 | + )->fetchColumn(); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | return (int) $this->totalTables; |
@@ -171,13 +171,13 @@ discard block |
||
171 | 171 | * |
172 | 172 | * @return string |
173 | 173 | */ |
174 | - public function getSequence ( $table , $column ) |
|
174 | + public function getSequence($table, $column) |
|
175 | 175 | { |
176 | - $return = $this->getPDO () |
|
177 | - ->query ( "select * from information_schema.columns where extra like '%auto_increment%' and TABLE_SCHEMA='{$this->database}' AND TABLE_NAME='{$table}' AND COLUMN_NAME='{$column}';" ) |
|
178 | - ->fetch ( \PDO::FETCH_ASSOC ); |
|
176 | + $return = $this->getPDO() |
|
177 | + ->query("select * from information_schema.columns where extra like '%auto_increment%' and TABLE_SCHEMA='{$this->database}' AND TABLE_NAME='{$table}' AND COLUMN_NAME='{$column}';") |
|
178 | + ->fetch(\PDO::FETCH_ASSOC); |
|
179 | 179 | |
180 | - if ( ! $return ) |
|
180 | + if ( ! $return) |
|
181 | 181 | { |
182 | 182 | return; |
183 | 183 | } |
@@ -247,7 +247,7 @@ |
||
247 | 247 | { |
248 | 248 | $pdo = $this->getPDO (); |
249 | 249 | $return1 = $pdo->query ( "SELECT pg_get_serial_sequence('$table', '$column');" ) |
250 | - ->fetchColumn (); |
|
250 | + ->fetchColumn (); |
|
251 | 251 | |
252 | 252 | if ( $return1 ) |
253 | 253 | { |
@@ -27,43 +27,43 @@ discard block |
||
27 | 27 | /** |
28 | 28 | * @type array|\string[] |
29 | 29 | */ |
30 | - protected $schema = array ( 'public' ); |
|
30 | + protected $schema = array('public'); |
|
31 | 31 | |
32 | - protected $dataTypes = array ( |
|
32 | + protected $dataTypes = array( |
|
33 | 33 | /* Numeric Types */ |
34 | - 'smallint' => 'int' , |
|
35 | - 'integer' => 'int' , |
|
36 | - 'bigint' => 'float' , |
|
37 | - 'decimal' => 'float' , |
|
38 | - 'numeric' => 'float' , |
|
39 | - 'real' => 'float' , |
|
40 | - 'double precision' => 'float' , |
|
41 | - 'serial' => 'int' , |
|
42 | - 'bigserial' => 'float' , |
|
34 | + 'smallint' => 'int', |
|
35 | + 'integer' => 'int', |
|
36 | + 'bigint' => 'float', |
|
37 | + 'decimal' => 'float', |
|
38 | + 'numeric' => 'float', |
|
39 | + 'real' => 'float', |
|
40 | + 'double precision' => 'float', |
|
41 | + 'serial' => 'int', |
|
42 | + 'bigserial' => 'float', |
|
43 | 43 | /* Monetary Types */ |
44 | - 'money' => 'float' , |
|
44 | + 'money' => 'float', |
|
45 | 45 | /* Character Types */ |
46 | - 'character varyin' => 'string' , |
|
47 | - 'varchar' => 'string' , |
|
48 | - 'character' => 'string' , |
|
49 | - 'char' => 'string' , |
|
50 | - 'text' => 'string' , |
|
46 | + 'character varyin' => 'string', |
|
47 | + 'varchar' => 'string', |
|
48 | + 'character' => 'string', |
|
49 | + 'char' => 'string', |
|
50 | + 'text' => 'string', |
|
51 | 51 | /* Binary Data Types */ |
52 | - 'bytea' => 'string' , |
|
52 | + 'bytea' => 'string', |
|
53 | 53 | /* Date/Time Types */ |
54 | - 'datatime' => 'date' , |
|
55 | - 'date' => 'date' , |
|
54 | + 'datatime' => 'date', |
|
55 | + 'date' => 'date', |
|
56 | 56 | |
57 | 57 | /* Boolean Type */ |
58 | 58 | 'boolean' => 'boolean' |
59 | 59 | ); |
60 | 60 | |
61 | - public function __construct ( AbstractAdapter $adapterConfig ) |
|
61 | + public function __construct(AbstractAdapter $adapterConfig) |
|
62 | 62 | { |
63 | - parent::__construct ( $adapterConfig ); |
|
64 | - if ( $adapterConfig->hasSchemas () ) |
|
63 | + parent::__construct($adapterConfig); |
|
64 | + if ($adapterConfig->hasSchemas()) |
|
65 | 65 | { |
66 | - $this->schema = $adapterConfig->getSchemas (); |
|
66 | + $this->schema = $adapterConfig->getSchemas(); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | } |
@@ -75,13 +75,13 @@ discard block |
||
75 | 75 | * |
76 | 76 | * @return string[] |
77 | 77 | */ |
78 | - public function getListNameTable () |
|
78 | + public function getListNameTable() |
|
79 | 79 | { |
80 | - if ( empty( $this->tableList ) ) |
|
80 | + if (empty($this->tableList)) |
|
81 | 81 | { |
82 | - $strSchema = implode ( "', '" , $this->schema ); |
|
82 | + $strSchema = implode("', '", $this->schema); |
|
83 | 83 | |
84 | - $this->tableList = $this->getPDO ()->query ( |
|
84 | + $this->tableList = $this->getPDO()->query( |
|
85 | 85 | "SELECT table_schema, |
86 | 86 | table_name |
87 | 87 | FROM information_schema.tables |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | table_schema, |
93 | 93 | table_name |
94 | 94 | ASC" |
95 | - )->fetchAll (); |
|
95 | + )->fetchAll(); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | return $this->tableList; |
@@ -103,11 +103,11 @@ discard block |
||
103 | 103 | * |
104 | 104 | * @return array |
105 | 105 | */ |
106 | - public function getListColumns () |
|
106 | + public function getListColumns() |
|
107 | 107 | { |
108 | - $strSchema = implode ( "', '" , $this->schema ); |
|
108 | + $strSchema = implode("', '", $this->schema); |
|
109 | 109 | |
110 | - return $this->getPDO ()->query ( |
|
110 | + return $this->getPDO()->query( |
|
111 | 111 | "SELECT distinct |
112 | 112 | c.table_schema, |
113 | 113 | c.table_name, |
@@ -121,14 +121,14 @@ discard block |
||
121 | 121 | ON st.table_name=c.table_name and st.table_type = 'BASE TABLE' |
122 | 122 | and c.table_schema IN ('$strSchema') |
123 | 123 | order by c.table_name asc" |
124 | - )->fetchAll ( \PDO::FETCH_ASSOC ); |
|
124 | + )->fetchAll(\PDO::FETCH_ASSOC); |
|
125 | 125 | } |
126 | 126 | |
127 | - public function getListConstrant () |
|
127 | + public function getListConstrant() |
|
128 | 128 | { |
129 | - $strSchema = implode ( "', '" , $this->schema ); |
|
129 | + $strSchema = implode("', '", $this->schema); |
|
130 | 130 | |
131 | - return $this->getPDO ()->query ( |
|
131 | + return $this->getPDO()->query( |
|
132 | 132 | "SELECT distinct |
133 | 133 | tc.constraint_type, |
134 | 134 | tc.constraint_name, |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | ON tc.constraint_name = ccu.constraint_name |
149 | 149 | AND tc.constraint_schema = ccu.constraint_schema |
150 | 150 | ORDER by tc.table_schema" |
151 | - )->fetchAll ( \PDO::FETCH_ASSOC ); |
|
151 | + )->fetchAll(\PDO::FETCH_ASSOC); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | |
@@ -160,20 +160,20 @@ discard block |
||
160 | 160 | * |
161 | 161 | * @return string |
162 | 162 | */ |
163 | - public function getSequence ( $table , $column ) |
|
163 | + public function getSequence($table, $column) |
|
164 | 164 | { |
165 | - $pdo = $this->getPDO (); |
|
166 | - $return1 = $pdo->query ( "SELECT pg_get_serial_sequence('$table', '$column');" ) |
|
167 | - ->fetchColumn (); |
|
165 | + $pdo = $this->getPDO(); |
|
166 | + $return1 = $pdo->query("SELECT pg_get_serial_sequence('$table', '$column');") |
|
167 | + ->fetchColumn(); |
|
168 | 168 | |
169 | - if ( $return1 ) |
|
169 | + if ($return1) |
|
170 | 170 | { |
171 | 171 | return $return1; |
172 | 172 | } |
173 | 173 | |
174 | - $dtbase = explode ( '.' , $table );; |
|
174 | + $dtbase = explode('.', $table); ; |
|
175 | 175 | |
176 | - $stmt = $pdo->prepare ( |
|
176 | + $stmt = $pdo->prepare( |
|
177 | 177 | "SELECT adsrc FROM pg_attrdef AS att |
178 | 178 | INNER JOIN pg_class AS c |
179 | 179 | ON adrelid = c.oid AND att.adnum=1 AND c.relname = ? |
@@ -181,19 +181,19 @@ discard block |
||
181 | 181 | ON n.oid = c.relnamespace and n.nspname=?" |
182 | 182 | ); |
183 | 183 | |
184 | - $schema = isset( $dtbase[ 1 ] ) ? $dtbase[ 1 ] : 'public'; |
|
184 | + $schema = isset($dtbase[1]) ? $dtbase[1] : 'public'; |
|
185 | 185 | |
186 | - $stmt->bindParam ( 1 , $schema ); |
|
187 | - $stmt->bindParam ( 2 , $dtbase[ 0 ] ); |
|
188 | - $stmt->execute (); |
|
189 | - $return2 = $stmt->fetchColumn (); |
|
190 | - if ( $return2 ) |
|
186 | + $stmt->bindParam(1, $schema); |
|
187 | + $stmt->bindParam(2, $dtbase[0]); |
|
188 | + $stmt->execute(); |
|
189 | + $return2 = $stmt->fetchColumn(); |
|
190 | + if ($return2) |
|
191 | 191 | { |
192 | - return preg_filter ( |
|
193 | - array ( |
|
194 | - '/nextval\(\'/' , |
|
192 | + return preg_filter( |
|
193 | + array( |
|
194 | + '/nextval\(\'/', |
|
195 | 195 | '/\'::regclass\)/' |
196 | - ) , '' , $return2 |
|
196 | + ), '', $return2 |
|
197 | 197 | ); |
198 | 198 | } |
199 | 199 | |
@@ -204,12 +204,12 @@ discard block |
||
204 | 204 | * @inheritDoc |
205 | 205 | * @return string |
206 | 206 | */ |
207 | - public function getPDOString () |
|
207 | + public function getPDOString() |
|
208 | 208 | { |
209 | - return sprintf ( |
|
210 | - "pgsql:host=%s;port=%s;dbname=%s" , |
|
211 | - $this->host , |
|
212 | - $this->port , |
|
209 | + return sprintf( |
|
210 | + "pgsql:host=%s;port=%s;dbname=%s", |
|
211 | + $this->host, |
|
212 | + $this->port, |
|
213 | 213 | $this->database |
214 | 214 | |
215 | 215 | ); |
@@ -219,11 +219,11 @@ discard block |
||
219 | 219 | * @inheritDoc |
220 | 220 | * @return string |
221 | 221 | */ |
222 | - public function getPDOSocketString () |
|
222 | + public function getPDOSocketString() |
|
223 | 223 | { |
224 | - return sprintf ( |
|
225 | - "pgsql:unix_socket=%s;dbname=%s" , |
|
226 | - $this->socket , |
|
224 | + return sprintf( |
|
225 | + "pgsql:unix_socket=%s;dbname=%s", |
|
226 | + $this->socket, |
|
227 | 227 | $this->database |
228 | 228 | |
229 | 229 | ); |
@@ -234,19 +234,19 @@ discard block |
||
234 | 234 | * |
235 | 235 | * @return int |
236 | 236 | */ |
237 | - public function getTotalTables () |
|
237 | + public function getTotalTables() |
|
238 | 238 | { |
239 | - if ( empty( $this->totalTables ) ) |
|
239 | + if (empty($this->totalTables)) |
|
240 | 240 | { |
241 | - $strSchema = implode ( "', '" , $this->schema ); |
|
241 | + $strSchema = implode("', '", $this->schema); |
|
242 | 242 | |
243 | - $this->totalTables = $this->getPDO ()->query ( |
|
243 | + $this->totalTables = $this->getPDO()->query( |
|
244 | 244 | "SELECT COUNT(table_name) AS total |
245 | 245 | FROM information_schema.tables |
246 | 246 | WHERE |
247 | 247 | table_type = 'BASE TABLE' |
248 | 248 | AND table_schema IN ( '" . $strSchema . "' )" |
249 | - )->fetchColumn (); |
|
249 | + )->fetchColumn(); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | return (int) $this->totalTables; |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | /** |
50 | 50 | * @var array |
51 | 51 | */ |
52 | - private $argv = array (); |
|
52 | + private $argv = array(); |
|
53 | 53 | |
54 | 54 | /** |
55 | 55 | * @var \Classes\AdapterConfig\AbstractAdapter |
@@ -61,18 +61,18 @@ discard block |
||
61 | 61 | */ |
62 | 62 | private $adapterDriver; |
63 | 63 | |
64 | - public function __construct ( $argv , $basePath ) |
|
64 | + public function __construct($argv, $basePath) |
|
65 | 65 | { |
66 | - if ( array_key_exists ( 'help' , $argv ) ) |
|
66 | + if (array_key_exists('help', $argv)) |
|
67 | 67 | { |
68 | - die ( $this->getUsage () ); |
|
68 | + die ($this->getUsage()); |
|
69 | 69 | } |
70 | - if ( array_key_exists ( 'status' , $argv ) ) |
|
70 | + if (array_key_exists('status', $argv)) |
|
71 | 71 | { |
72 | - $argv[ 'status' ] = true; |
|
72 | + $argv['status'] = true; |
|
73 | 73 | } |
74 | 74 | |
75 | - $this->argv = $this->parseConfig ( $basePath , $argv ); |
|
75 | + $this->argv = $this->parseConfig($basePath, $argv); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @return string |
82 | 82 | */ |
83 | - public function getUsage () |
|
83 | + public function getUsage() |
|
84 | 84 | { |
85 | 85 | $version = static::$version; |
86 | 86 | |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | EOF; |
106 | 106 | } |
107 | 107 | |
108 | - public function getVersion () |
|
108 | + public function getVersion() |
|
109 | 109 | { |
110 | 110 | $version = static::$version; |
111 | 111 | |
@@ -121,22 +121,22 @@ discard block |
||
121 | 121 | * @return array |
122 | 122 | * @throws \Exception |
123 | 123 | */ |
124 | - private function parseConfig ( $basePath , $argv ) |
|
124 | + private function parseConfig($basePath, $argv) |
|
125 | 125 | { |
126 | - $this->_basePath = dirname ( $basePath ); |
|
126 | + $this->_basePath = dirname($basePath); |
|
127 | 127 | |
128 | - $configIni = isset( $argv[ 'config-ini' ] ) ? $argv[ 'config-ini' ] |
|
128 | + $configIni = isset($argv['config-ini']) ? $argv['config-ini'] |
|
129 | 129 | : $this->_basePath . $this->configIniDefault; |
130 | 130 | |
131 | - $configTemp = $this->loadIniFile ( realpath ( $configIni ) ); |
|
132 | - $configCurrent = self::parseConfigEnv ( $configTemp , $argv ); |
|
131 | + $configTemp = $this->loadIniFile(realpath($configIni)); |
|
132 | + $configCurrent = self::parseConfigEnv($configTemp, $argv); |
|
133 | 133 | |
134 | - if ( ! isset( $configCurrent[ 'framework' ] ) ) |
|
134 | + if ( ! isset($configCurrent['framework'])) |
|
135 | 135 | { |
136 | - throw new \Exception( "configure which framework you want to use! \n" ); |
|
136 | + throw new \Exception("configure which framework you want to use! \n"); |
|
137 | 137 | } |
138 | 138 | |
139 | - return $argv + array_filter ( $configCurrent ); |
|
139 | + return $argv + array_filter($configCurrent); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | /** |
@@ -146,22 +146,22 @@ discard block |
||
146 | 146 | * |
147 | 147 | * @return string |
148 | 148 | */ |
149 | - private static function parseConfigEnv ( $configTemp , $argv ) |
|
149 | + private static function parseConfigEnv($configTemp, $argv) |
|
150 | 150 | { |
151 | - $thisSection = isset( $configTemp[ key ( $configTemp ) ][ 'config-env' ] ) ? |
|
152 | - $configTemp[ key ( $configTemp ) ][ 'config-env' ] : null; |
|
151 | + $thisSection = isset($configTemp[key($configTemp)]['config-env']) ? |
|
152 | + $configTemp[key($configTemp)]['config-env'] : null; |
|
153 | 153 | |
154 | - $thisSection = isset( $argv[ 'config-env' ] ) ? $argv[ 'config-env' ] |
|
154 | + $thisSection = isset($argv['config-env']) ? $argv['config-env'] |
|
155 | 155 | : $thisSection; |
156 | 156 | |
157 | - if ( isset( $configTemp[ $thisSection ][ 'extends' ] ) ) |
|
157 | + if (isset($configTemp[$thisSection]['extends'])) |
|
158 | 158 | { |
159 | 159 | #faz marge da config principal com a config extendida |
160 | - return $configTemp[ $thisSection ] |
|
161 | - + $configTemp[ $configTemp[ $thisSection ][ 'extends' ] ]; |
|
160 | + return $configTemp[$thisSection] |
|
161 | + + $configTemp[$configTemp[$thisSection]['extends']]; |
|
162 | 162 | } |
163 | 163 | |
164 | - return $configTemp[ key ( $configTemp ) ]; |
|
164 | + return $configTemp[key($configTemp)]; |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | /** |
@@ -175,32 +175,32 @@ discard block |
||
175 | 175 | * @throws \Exception |
176 | 176 | * @return array |
177 | 177 | */ |
178 | - protected function loadIniFile ( $filename ) |
|
178 | + protected function loadIniFile($filename) |
|
179 | 179 | { |
180 | - if ( ! is_file ( $filename ) ) |
|
180 | + if ( ! is_file($filename)) |
|
181 | 181 | { |
182 | - throw new \Exception( "configuration file does not exist! \n" ); |
|
182 | + throw new \Exception("configuration file does not exist! \n"); |
|
183 | 183 | } |
184 | 184 | |
185 | - $loaded = parse_ini_file ( $filename , true ); |
|
186 | - $iniArray = array (); |
|
187 | - foreach ( $loaded as $key => $data ) |
|
185 | + $loaded = parse_ini_file($filename, true); |
|
186 | + $iniArray = array(); |
|
187 | + foreach ($loaded as $key => $data) |
|
188 | 188 | { |
189 | - $pieces = explode ( $this->sectionSeparator , $key ); |
|
190 | - $thisSection = trim ( $pieces[ 0 ] ); |
|
191 | - switch ( count ( $pieces ) ) |
|
189 | + $pieces = explode($this->sectionSeparator, $key); |
|
190 | + $thisSection = trim($pieces[0]); |
|
191 | + switch (count($pieces)) |
|
192 | 192 | { |
193 | 193 | case 1: |
194 | - $iniArray[ $thisSection ] = $data; |
|
194 | + $iniArray[$thisSection] = $data; |
|
195 | 195 | break; |
196 | 196 | |
197 | 197 | case 2: |
198 | - $extendedSection = trim ( $pieces[ 1 ] ); |
|
199 | - $iniArray[ $thisSection ] = array_merge ( array ( 'extends' => $extendedSection ) , $data ); |
|
198 | + $extendedSection = trim($pieces[1]); |
|
199 | + $iniArray[$thisSection] = array_merge(array('extends' => $extendedSection), $data); |
|
200 | 200 | break; |
201 | 201 | |
202 | 202 | default: |
203 | - throw new \Exception( "Section '$thisSection' may not extend multiple sections in $filename" ); |
|
203 | + throw new \Exception("Section '$thisSection' may not extend multiple sections in $filename"); |
|
204 | 204 | } |
205 | 205 | } |
206 | 206 | |
@@ -211,15 +211,15 @@ discard block |
||
211 | 211 | * analisa a opção e cria a instancia do Atapter do determinado framework |
212 | 212 | * |
213 | 213 | */ |
214 | - private function factoryConfig () |
|
214 | + private function factoryConfig() |
|
215 | 215 | { |
216 | - switch ( strtolower ( $this->argv[ 'framework' ] ) ) |
|
216 | + switch (strtolower($this->argv['framework'])) |
|
217 | 217 | { |
218 | 218 | case 'none': |
219 | - $this->adapterConfig = new None( $this->argv ); |
|
219 | + $this->adapterConfig = new None($this->argv); |
|
220 | 220 | break; |
221 | 221 | case 'zend_framework': |
222 | - $this->adapterConfig = new ZendFrameworkOne( $this->argv ); |
|
222 | + $this->adapterConfig = new ZendFrameworkOne($this->argv); |
|
223 | 223 | break; |
224 | 224 | } |
225 | 225 | |
@@ -229,26 +229,26 @@ discard block |
||
229 | 229 | * Analisa a opção e instancia o determinado banco de dados |
230 | 230 | * |
231 | 231 | */ |
232 | - private function factoryDriver () |
|
232 | + private function factoryDriver() |
|
233 | 233 | { |
234 | - switch ( $this->argv[ 'driver' ] ) |
|
234 | + switch ($this->argv['driver']) |
|
235 | 235 | { |
236 | 236 | case 'pgsql': |
237 | 237 | case 'pdo_pgsql': |
238 | - $this->adapterDriver = new Pgsql( $this->getAdapterConfig () ); |
|
238 | + $this->adapterDriver = new Pgsql($this->getAdapterConfig()); |
|
239 | 239 | break; |
240 | 240 | case 'mysql': |
241 | 241 | case 'pdo_mysql': |
242 | - $this->adapterDriver = new Mysql( $this->getAdapterConfig () ); |
|
242 | + $this->adapterDriver = new Mysql($this->getAdapterConfig()); |
|
243 | 243 | break; |
244 | 244 | case 'mssql': |
245 | - $this->adapterDriver = new Mssql( $this->getAdapterConfig () ); |
|
245 | + $this->adapterDriver = new Mssql($this->getAdapterConfig()); |
|
246 | 246 | break; |
247 | 247 | case 'dblib': |
248 | - $this->adapterDriver = new Dblib( $this->getAdapterConfig () ); |
|
248 | + $this->adapterDriver = new Dblib($this->getAdapterConfig()); |
|
249 | 249 | break; |
250 | 250 | case 'sqlsrv': |
251 | - $this->adapterDriver = new Sqlsrv( $this->getAdapterConfig () ); |
|
251 | + $this->adapterDriver = new Sqlsrv($this->getAdapterConfig()); |
|
252 | 252 | break; |
253 | 253 | } |
254 | 254 | |
@@ -257,11 +257,11 @@ discard block |
||
257 | 257 | /** |
258 | 258 | * @return AdapterConfig\AbstractAdapter |
259 | 259 | */ |
260 | - public function getAdapterConfig () |
|
260 | + public function getAdapterConfig() |
|
261 | 261 | { |
262 | - if ( ! $this->adapterConfig ) |
|
262 | + if ( ! $this->adapterConfig) |
|
263 | 263 | { |
264 | - $this->factoryConfig (); |
|
264 | + $this->factoryConfig(); |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | return $this->adapterConfig; |
@@ -270,11 +270,11 @@ discard block |
||
270 | 270 | /** |
271 | 271 | * @return AdaptersDriver\AbsractAdapter |
272 | 272 | */ |
273 | - public function getAdapterDriver () |
|
273 | + public function getAdapterDriver() |
|
274 | 274 | { |
275 | - if ( ! $this->adapterDriver ) |
|
275 | + if ( ! $this->adapterDriver) |
|
276 | 276 | { |
277 | - $this->factoryDriver (); |
|
277 | + $this->factoryDriver(); |
|
278 | 278 | } |
279 | 279 | |
280 | 280 | return $this->adapterDriver; |
@@ -107,30 +107,30 @@ 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 | - ) |
|
117 | - ); |
|
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 | + ) |
|
117 | + ); |
|
118 | 118 | |
119 | 119 | switch ( $constrant[ 'constraint_type' ] ) |
120 | 120 | { |
121 | 121 | case "FOREIGN KEY": |
122 | 122 | $table->getColumn ( $constrant[ "column_name" ] ) |
123 | - ->addRefFk ( $objConstrant ); |
|
123 | + ->addRefFk ( $objConstrant ); |
|
124 | 124 | break; |
125 | 125 | case"PRIMARY KEY": |
126 | 126 | $table->getColumn ( $constrant[ "column_name" ] ) |
127 | - ->setPrimaryKey ( $objConstrant ) |
|
128 | - ->setSequence ( |
|
129 | - $this->getSequence ( |
|
130 | - $schema . '.' . $table_name , |
|
131 | - $constrant[ "column_name" ] |
|
132 | - ) |
|
133 | - ); |
|
127 | + ->setPrimaryKey ( $objConstrant ) |
|
128 | + ->setSequence ( |
|
129 | + $this->getSequence ( |
|
130 | + $schema . '.' . $table_name , |
|
131 | + $constrant[ "column_name" ] |
|
132 | + ) |
|
133 | + ); |
|
134 | 134 | break; |
135 | 135 | } |
136 | 136 | } |
@@ -150,12 +150,12 @@ discard block |
||
150 | 150 | if ( $table->hasColumn ( $constrant[ "foreign_column" ] ) ) |
151 | 151 | { |
152 | 152 | $table->getColumn ( $constrant[ "foreign_column" ] ) |
153 | - ->createDependece ( |
|
154 | - $constrant[ 'constraint_name' ] , |
|
155 | - $constrant[ 'table_name' ] , |
|
156 | - $constrant[ 'column_name' ] , |
|
157 | - $constrant[ 'table_schema' ] |
|
158 | - ); |
|
153 | + ->createDependece ( |
|
154 | + $constrant[ 'constraint_name' ] , |
|
155 | + $constrant[ 'table_name' ] , |
|
156 | + $constrant[ 'column_name' ] , |
|
157 | + $constrant[ 'table_schema' ] |
|
158 | + ); |
|
159 | 159 | } |
160 | 160 | } |
161 | 161 | } |
@@ -190,10 +190,10 @@ discard block |
||
190 | 190 | ); |
191 | 191 | |
192 | 192 | $this->getTable ( $key , $schema ) |
193 | - ->addColumn ( $column ) |
|
194 | - ->setNamespace ( |
|
195 | - $this->config->createClassNamespace ( $this->getTable ( $key , $schema ) ) |
|
196 | - ); |
|
193 | + ->addColumn ( $column ) |
|
194 | + ->setNamespace ( |
|
195 | + $this->config->createClassNamespace ( $this->getTable ( $key , $schema ) ) |
|
196 | + ); |
|
197 | 197 | } |
198 | 198 | } |
199 | 199 | |
@@ -253,13 +253,13 @@ discard block |
||
253 | 253 | public function createTable ( $nameTable , $schema = 0 ) |
254 | 254 | { |
255 | 255 | $this->objDbTables[ $schema ][ trim ( $nameTable ) ] = DbTable::getInstance () |
256 | - ->populate ( |
|
257 | - array ( |
|
258 | - 'table' => $nameTable , |
|
259 | - 'schema' => $schema , |
|
260 | - 'database' => $this->database |
|
261 | - ) |
|
262 | - ); |
|
256 | + ->populate ( |
|
257 | + array ( |
|
258 | + 'table' => $nameTable , |
|
259 | + 'schema' => $schema , |
|
260 | + 'database' => $this->database |
|
261 | + ) |
|
262 | + ); |
|
263 | 263 | |
264 | 264 | return $this; |
265 | 265 | } |
@@ -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,36 +99,36 @@ 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 | ) |
117 | 117 | ); |
118 | 118 | |
119 | - switch ( $constrant[ 'constraint_type' ] ) |
|
119 | + switch ($constrant['constraint_type']) |
|
120 | 120 | { |
121 | 121 | case "FOREIGN KEY": |
122 | - $table->getColumn ( $constrant[ "column_name" ] ) |
|
123 | - ->addRefFk ( $objConstrant ); |
|
122 | + $table->getColumn($constrant["column_name"]) |
|
123 | + ->addRefFk($objConstrant); |
|
124 | 124 | break; |
125 | 125 | case"PRIMARY KEY": |
126 | - $table->getColumn ( $constrant[ "column_name" ] ) |
|
127 | - ->setPrimaryKey ( $objConstrant ) |
|
128 | - ->setSequence ( |
|
129 | - $this->getSequence ( |
|
130 | - $schema . '.' . $table_name , |
|
131 | - $constrant[ "column_name" ] |
|
126 | + $table->getColumn($constrant["column_name"]) |
|
127 | + ->setPrimaryKey($objConstrant) |
|
128 | + ->setSequence( |
|
129 | + $this->getSequence( |
|
130 | + $schema . '.' . $table_name, |
|
131 | + $constrant["column_name"] |
|
132 | 132 | ) |
133 | 133 | ); |
134 | 134 | break; |
@@ -142,19 +142,19 @@ discard block |
||
142 | 142 | * @param string $table_name |
143 | 143 | * @param int $schema |
144 | 144 | */ |
145 | - private function populateDependece ( $constrant , $table_name , $schema = 0 ) |
|
145 | + private function populateDependece($constrant, $table_name, $schema = 0) |
|
146 | 146 | { |
147 | - if ( $this->hasTable ( $table_name , $schema ) ) |
|
147 | + if ($this->hasTable($table_name, $schema)) |
|
148 | 148 | { |
149 | - $table = $this->getTable ( $table_name , $schema ); |
|
150 | - if ( $table->hasColumn ( $constrant[ "foreign_column" ] ) ) |
|
149 | + $table = $this->getTable($table_name, $schema); |
|
150 | + if ($table->hasColumn($constrant["foreign_column"])) |
|
151 | 151 | { |
152 | - $table->getColumn ( $constrant[ "foreign_column" ] ) |
|
153 | - ->createDependece ( |
|
154 | - $constrant[ 'constraint_name' ] , |
|
155 | - $constrant[ 'table_name' ] , |
|
156 | - $constrant[ 'column_name' ] , |
|
157 | - $constrant[ 'table_schema' ] |
|
152 | + $table->getColumn($constrant["foreign_column"]) |
|
153 | + ->createDependece( |
|
154 | + $constrant['constraint_name'], |
|
155 | + $constrant['table_name'], |
|
156 | + $constrant['column_name'], |
|
157 | + $constrant['table_schema'] |
|
158 | 158 | ); |
159 | 159 | } |
160 | 160 | } |
@@ -163,36 +163,36 @@ discard block |
||
163 | 163 | /** |
164 | 164 | * cria um Array com nome das tabelas |
165 | 165 | */ |
166 | - public function parseTables () |
|
166 | + public function parseTables() |
|
167 | 167 | { |
168 | - if ( $this->hasTables () ) |
|
168 | + if ($this->hasTables()) |
|
169 | 169 | { |
170 | - return $this->getAllTables (); |
|
170 | + return $this->getAllTables(); |
|
171 | 171 | } |
172 | 172 | |
173 | - foreach ( $this->getListColumns () as $table ) |
|
173 | + foreach ($this->getListColumns() as $table) |
|
174 | 174 | { |
175 | - $schema = $table[ 'table_schema' ]; |
|
176 | - $key = $table [ 'table_name' ]; |
|
177 | - if ( ! $this->hasTable ( $key , $schema ) ) |
|
175 | + $schema = $table['table_schema']; |
|
176 | + $key = $table ['table_name']; |
|
177 | + if ( ! $this->hasTable($key, $schema)) |
|
178 | 178 | { |
179 | - $this->createTable ( $key , $schema ); |
|
179 | + $this->createTable($key, $schema); |
|
180 | 180 | } |
181 | 181 | |
182 | - $column = Column::getInstance () |
|
183 | - ->populate ( |
|
184 | - array ( |
|
185 | - 'name' => $table [ 'column_name' ] , |
|
186 | - 'type' => $this->convertTypeToPhp ( $table[ 'data_type' ] ) , |
|
187 | - 'nullable' => ( $table[ 'is_nullable' ] == 'YES' ) , |
|
188 | - 'max_length' => $table[ 'max_length' ] |
|
182 | + $column = Column::getInstance() |
|
183 | + ->populate( |
|
184 | + array( |
|
185 | + 'name' => $table ['column_name'], |
|
186 | + 'type' => $this->convertTypeToPhp($table['data_type']), |
|
187 | + 'nullable' => ($table['is_nullable'] == 'YES'), |
|
188 | + 'max_length' => $table['max_length'] |
|
189 | 189 | ) |
190 | 190 | ); |
191 | 191 | |
192 | - $this->getTable ( $key , $schema ) |
|
193 | - ->addColumn ( $column ) |
|
194 | - ->setNamespace ( |
|
195 | - $this->config->createClassNamespace ( $this->getTable ( $key , $schema ) ) |
|
192 | + $this->getTable($key, $schema) |
|
193 | + ->addColumn($column) |
|
194 | + ->setNamespace( |
|
195 | + $this->config->createClassNamespace($this->getTable($key, $schema)) |
|
196 | 196 | ); |
197 | 197 | } |
198 | 198 | } |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | * |
203 | 203 | * @return int |
204 | 204 | */ |
205 | - abstract public function getTotalTables (); |
|
205 | + abstract public function getTotalTables(); |
|
206 | 206 | |
207 | 207 | /** |
208 | 208 | * Retorna o Nome da Sequence da tabela |
@@ -212,23 +212,23 @@ discard block |
||
212 | 212 | * |
213 | 213 | * @return string |
214 | 214 | */ |
215 | - abstract public function getSequence ( $table , $column ); |
|
215 | + abstract public function getSequence($table, $column); |
|
216 | 216 | |
217 | 217 | /** |
218 | 218 | * @return array |
219 | 219 | */ |
220 | - abstract public function getListConstrant (); |
|
220 | + abstract public function getListConstrant(); |
|
221 | 221 | |
222 | 222 | /** |
223 | 223 | * @param string $str |
224 | 224 | * |
225 | 225 | * @return string |
226 | 226 | */ |
227 | - protected function convertTypeToPhp ( $str ) |
|
227 | + protected function convertTypeToPhp($str) |
|
228 | 228 | { |
229 | - if ( isset( $this->dataTypes[ $str ] ) ) |
|
229 | + if (isset($this->dataTypes[$str])) |
|
230 | 230 | { |
231 | - return $this->dataTypes[ $str ]; |
|
231 | + return $this->dataTypes[$str]; |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | return 'string'; |
@@ -237,12 +237,12 @@ discard block |
||
237 | 237 | /** |
238 | 238 | * @return string |
239 | 239 | */ |
240 | - abstract public function getPDOString (); |
|
240 | + abstract public function getPDOString(); |
|
241 | 241 | |
242 | 242 | /** |
243 | 243 | * @return string |
244 | 244 | */ |
245 | - abstract public function getPDOSocketString (); |
|
245 | + abstract public function getPDOSocketString(); |
|
246 | 246 | |
247 | 247 | /** |
248 | 248 | * @param $nameTable |
@@ -250,13 +250,13 @@ discard block |
||
250 | 250 | * |
251 | 251 | * @return \Classes\Db\DbTable |
252 | 252 | */ |
253 | - public function createTable ( $nameTable , $schema = 0 ) |
|
253 | + public function createTable($nameTable, $schema = 0) |
|
254 | 254 | { |
255 | - $this->objDbTables[ $schema ][ trim ( $nameTable ) ] = DbTable::getInstance () |
|
256 | - ->populate ( |
|
257 | - array ( |
|
258 | - 'table' => $nameTable , |
|
259 | - 'schema' => $schema , |
|
255 | + $this->objDbTables[$schema][trim($nameTable)] = DbTable::getInstance() |
|
256 | + ->populate( |
|
257 | + array( |
|
258 | + 'table' => $nameTable, |
|
259 | + 'schema' => $schema, |
|
260 | 260 | 'database' => $this->database |
261 | 261 | ) |
262 | 262 | ); |
@@ -269,24 +269,24 @@ discard block |
||
269 | 269 | * |
270 | 270 | * @return \Classes\Db\DbTable[] |
271 | 271 | */ |
272 | - public function getTables ( $schema = 0 ) |
|
272 | + public function getTables($schema = 0) |
|
273 | 273 | { |
274 | - if ( ! isset( $this->objDbTables[ $schema ] ) ) |
|
274 | + if ( ! isset($this->objDbTables[$schema])) |
|
275 | 275 | { |
276 | - return array (); |
|
276 | + return array(); |
|
277 | 277 | } |
278 | 278 | |
279 | - return $this->objDbTables[ $schema ]; |
|
279 | + return $this->objDbTables[$schema]; |
|
280 | 280 | } |
281 | 281 | |
282 | - public function getAllTables () |
|
282 | + public function getAllTables() |
|
283 | 283 | { |
284 | 284 | return $this->objDbTables; |
285 | 285 | } |
286 | 286 | |
287 | - public function hasTables () |
|
287 | + public function hasTables() |
|
288 | 288 | { |
289 | - return ! empty( $this->objDbTables ); |
|
289 | + return ! empty($this->objDbTables); |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | /** |
@@ -296,9 +296,9 @@ discard block |
||
296 | 296 | * |
297 | 297 | * @return \Classes\Db\DbTable |
298 | 298 | */ |
299 | - public function getTable ( $nameTable , $schema = 0 ) |
|
299 | + public function getTable($nameTable, $schema = 0) |
|
300 | 300 | { |
301 | - return $this->objDbTables[ $schema ][ trim ( $nameTable ) ]; |
|
301 | + return $this->objDbTables[$schema][trim($nameTable)]; |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | /** |
@@ -307,9 +307,9 @@ discard block |
||
307 | 307 | * |
308 | 308 | * @return bool |
309 | 309 | */ |
310 | - public function hasTable ( $nameTable , $schema = 0 ) |
|
310 | + public function hasTable($nameTable, $schema = 0) |
|
311 | 311 | { |
312 | - return isset( $this->objDbTables[ $schema ][ trim ( $nameTable ) ] ); |
|
312 | + return isset($this->objDbTables[$schema][trim($nameTable)]); |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | /** |
@@ -317,64 +317,64 @@ discard block |
||
317 | 317 | * |
318 | 318 | * @return array[] |
319 | 319 | */ |
320 | - abstract public function getListColumns (); |
|
320 | + abstract public function getListColumns(); |
|
321 | 321 | |
322 | 322 | /** |
323 | 323 | * Retorna um Array com nome das tabelas |
324 | 324 | * |
325 | 325 | * @return string[] |
326 | 326 | */ |
327 | - abstract public function getListNameTable (); |
|
327 | + abstract public function getListNameTable(); |
|
328 | 328 | |
329 | 329 | /** |
330 | 330 | * @param \Classes\AdapterConfig\AbstractAdapter $adapterConfig |
331 | 331 | */ |
332 | - public function __construct ( AbstractAdapter $adapterConfig ) |
|
332 | + public function __construct(AbstractAdapter $adapterConfig) |
|
333 | 333 | { |
334 | 334 | $this->config = $adapterConfig; |
335 | - $this->host = $adapterConfig->getHost (); |
|
336 | - $this->database = $adapterConfig->getDatabase (); |
|
337 | - $this->port = $adapterConfig->hasPort () ? $adapterConfig->getPort () |
|
335 | + $this->host = $adapterConfig->getHost(); |
|
336 | + $this->database = $adapterConfig->getDatabase(); |
|
337 | + $this->port = $adapterConfig->hasPort() ? $adapterConfig->getPort() |
|
338 | 338 | : $this->port; |
339 | - $this->username = $adapterConfig->getUser (); |
|
340 | - $this->password = $adapterConfig->getPassword (); |
|
341 | - $this->socket = $adapterConfig->getSocket (); |
|
339 | + $this->username = $adapterConfig->getUser(); |
|
340 | + $this->password = $adapterConfig->getPassword(); |
|
341 | + $this->socket = $adapterConfig->getSocket(); |
|
342 | 342 | |
343 | 343 | } |
344 | 344 | |
345 | 345 | /** |
346 | 346 | * Executa as consultas do banco de dados |
347 | 347 | */ |
348 | - public function runDatabase () |
|
348 | + public function runDatabase() |
|
349 | 349 | { |
350 | - $this->parseTables (); |
|
351 | - $this->parseConstrants (); |
|
350 | + $this->parseTables(); |
|
351 | + $this->parseConstrants(); |
|
352 | 352 | } |
353 | 353 | |
354 | 354 | /** |
355 | 355 | * |
356 | 356 | * @return \PDO |
357 | 357 | */ |
358 | - public function getPDO () |
|
358 | + public function getPDO() |
|
359 | 359 | { |
360 | - if ( is_null ( $this->_pdo ) ) |
|
360 | + if (is_null($this->_pdo)) |
|
361 | 361 | { |
362 | - if ( ! empty( $this->socket ) ) |
|
362 | + if ( ! empty($this->socket)) |
|
363 | 363 | { |
364 | - $pdoString = $this->getPDOSocketString (); |
|
364 | + $pdoString = $this->getPDOSocketString(); |
|
365 | 365 | } else |
366 | 366 | { |
367 | - $pdoString = $this->getPDOString (); |
|
367 | + $pdoString = $this->getPDOString(); |
|
368 | 368 | } |
369 | 369 | |
370 | 370 | try |
371 | 371 | { |
372 | - $this->_pdo = new \PDO ( |
|
373 | - $pdoString , $this->username , $this->password |
|
372 | + $this->_pdo = new \PDO( |
|
373 | + $pdoString, $this->username, $this->password |
|
374 | 374 | ); |
375 | - } catch ( \Exception $e ) |
|
375 | + } catch (\Exception $e) |
|
376 | 376 | { |
377 | - die ( "pdo error: " . $e->getMessage () . "\n" ); |
|
377 | + die ("pdo error: " . $e->getMessage() . "\n"); |
|
378 | 378 | } |
379 | 379 | } |
380 | 380 |