@@ -39,8 +39,8 @@ |
||
| 39 | 39 | public function getPHPType() |
| 40 | 40 | { |
| 41 | 41 | $dbtype = strtolower($this->getDbType()); |
| 42 | - foreach (self::$types as $type => $dbtypes) { |
|
| 43 | - if (in_array($dbtype, $dbtypes)) { |
|
| 42 | + foreach(self::$types as $type => $dbtypes) { |
|
| 43 | + if(in_array($dbtype, $dbtypes)) { |
|
| 44 | 44 | return $type; |
| 45 | 45 | } |
| 46 | 46 | } |
@@ -39,7 +39,7 @@ |
||
| 39 | 39 | */ |
| 40 | 40 | public function getTableFullName() |
| 41 | 41 | { |
| 42 | - if (($schema = $this->getSchemaName()) !== null) { |
|
| 42 | + if(($schema = $this->getSchemaName()) !== null) { |
|
| 43 | 43 | return $schema . '.' . $this->getTableName(); |
| 44 | 44 | } else { |
| 45 | 45 | return $this->getTableName(); |
@@ -34,8 +34,8 @@ discard block |
||
| 34 | 34 | public function getSearchExpression($fields, $keywords) |
| 35 | 35 | { |
| 36 | 36 | $columns = []; |
| 37 | - foreach ($fields as $field) { |
|
| 38 | - if ($this->isSearchableColumn($this->getTableInfo()->getColumn($field))) { |
|
| 37 | + foreach($fields as $field) { |
|
| 38 | + if($this->isSearchableColumn($this->getTableInfo()->getColumn($field))) { |
|
| 39 | 39 | $columns[] = $field; |
| 40 | 40 | } |
| 41 | 41 | } |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | protected function getSearchCondition($column, $words) |
| 62 | 62 | { |
| 63 | 63 | $conditions = []; |
| 64 | - foreach ($words as $word) { |
|
| 64 | + foreach($words as $word) { |
|
| 65 | 65 | $conditions[] = $column . ' ILIKE ' . $this->getDbConnection()->quoteString('%' . $word . '%'); |
| 66 | 66 | } |
| 67 | 67 | return '(' . implode(' AND ', $conditions) . ')'; |
@@ -61,10 +61,10 @@ discard block |
||
| 61 | 61 | */ |
| 62 | 62 | protected function getSchemaTableName($table) |
| 63 | 63 | { |
| 64 | - if (count($parts = explode('.', str_replace('"', '', $table))) > 1) { |
|
| 64 | + if(count($parts = explode('.', str_replace('"', '', $table))) > 1) { |
|
| 65 | 65 | return [$parts[0], $parts[1]]; |
| 66 | 66 | } else { |
| 67 | - return [$this->getDefaultSchema(),$parts[0]]; |
|
| 67 | + return [$this->getDefaultSchema(), $parts[0]]; |
|
| 68 | 68 | } |
| 69 | 69 | } |
| 70 | 70 | |
@@ -105,11 +105,11 @@ discard block |
||
| 105 | 105 | //$command->bindValue(':schema', $schemaName); |
| 106 | 106 | $tableInfo = $this->createNewTableInfo($schemaName, $tableName); |
| 107 | 107 | $index = 0; |
| 108 | - foreach ($command->query() as $col) { |
|
| 108 | + foreach($command->query() as $col) { |
|
| 109 | 109 | $col['index'] = $index++; |
| 110 | 110 | $this->processColumn($tableInfo, $col); |
| 111 | 111 | } |
| 112 | - if ($index === 0) { |
|
| 112 | + if($index === 0) { |
|
| 113 | 113 | throw new TDbException('dbmetadata_invalid_table_view', $table); |
| 114 | 114 | } |
| 115 | 115 | return $tableInfo; |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | $info['SchemaName'] = $this->assertIdentifier($schemaName); |
| 126 | 126 | $info['TableName'] = $this->assertIdentifier($tableName); |
| 127 | 127 | $info['IsView'] = false; |
| 128 | - if ($this->getIsView($schemaName, $tableName)) { |
|
| 128 | + if($this->getIsView($schemaName, $tableName)) { |
|
| 129 | 129 | $info['IsView'] = true; |
| 130 | 130 | } |
| 131 | 131 | list($primary, $foreign) = $this->getConstraintKeys($schemaName, $tableName); |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | */ |
| 141 | 141 | protected function assertIdentifier($name) |
| 142 | 142 | { |
| 143 | - if (strpos($name, '"') !== false) { |
|
| 143 | + if(strpos($name, '"') !== false) { |
|
| 144 | 144 | $ref = 'http://www.oracle.com'; |
| 145 | 145 | throw new TDbException('dbcommon_invalid_identifier_name', $name, $ref); |
| 146 | 146 | } |
@@ -181,19 +181,19 @@ discard block |
||
| 181 | 181 | $info['ColumnName'] = $columnId; //NOT quote the column names! |
| 182 | 182 | $info['ColumnId'] = $columnId; |
| 183 | 183 | $info['ColumnIndex'] = $col['index']; |
| 184 | - if (! (bool)$col['attnotnull']) { |
|
| 184 | + if(!(bool) $col['attnotnull']) { |
|
| 185 | 185 | $info['AllowNull'] = true; |
| 186 | 186 | } |
| 187 | - if (in_array($columnId, $tableInfo->getPrimaryKeys())) { |
|
| 187 | + if(in_array($columnId, $tableInfo->getPrimaryKeys())) { |
|
| 188 | 188 | $info['IsPrimaryKey'] = true; |
| 189 | 189 | } |
| 190 | - if ($this->isForeignKeyColumn($columnId, $tableInfo)) { |
|
| 190 | + if($this->isForeignKeyColumn($columnId, $tableInfo)) { |
|
| 191 | 191 | $info['IsForeignKey'] = true; |
| 192 | 192 | } |
| 193 | - if ((int)$col['atttypmod'] > 0) { |
|
| 193 | + if((int) $col['atttypmod'] > 0) { |
|
| 194 | 194 | $info['ColumnSize'] = $col['atttypmod']; |
| 195 | 195 | } // - 4; |
| 196 | - if ((bool)$col['atthasdef']) { |
|
| 196 | + if((bool) $col['atthasdef']) { |
|
| 197 | 197 | $info['DefaultValue'] = $col['adsrc']; |
| 198 | 198 | } |
| 199 | 199 | // |
@@ -210,11 +210,11 @@ discard block |
||
| 210 | 210 | } |
| 211 | 211 | */ |
| 212 | 212 | $matches = []; |
| 213 | - if (preg_match('/\((\d+)(?:,(\d+))?+\)/', $col['type'], $matches)) { |
|
| 213 | + if(preg_match('/\((\d+)(?:,(\d+))?+\)/', $col['type'], $matches)) { |
|
| 214 | 214 | $info['DbType'] = preg_replace('/\(\d+(?:,\d+)?\)/', '', $col['type']); |
| 215 | - if ($this->isPrecisionType($info['DbType'])) { |
|
| 215 | + if($this->isPrecisionType($info['DbType'])) { |
|
| 216 | 216 | $info['NumericPrecision'] = intval($matches[1]); |
| 217 | - if (count($matches) > 2) { |
|
| 217 | + if(count($matches) > 2) { |
|
| 218 | 218 | $info['NumericScale'] = intval($matches[2]); |
| 219 | 219 | } |
| 220 | 220 | } else { |
@@ -232,8 +232,8 @@ discard block |
||
| 232 | 232 | protected function getSequenceName($tableInfo, $src) |
| 233 | 233 | { |
| 234 | 234 | $matches = []; |
| 235 | - if (preg_match('/nextval\([^\']*\'([^\']+)\'[^\)]*\)/i', $src, $matches)) { |
|
| 236 | - if (is_int(strpos($matches[1], '.'))) { |
|
| 235 | + if(preg_match('/nextval\([^\']*\'([^\']+)\'[^\)]*\)/i', $src, $matches)) { |
|
| 236 | + if(is_int(strpos($matches[1], '.'))) { |
|
| 237 | 237 | return $matches[1]; |
| 238 | 238 | } else { |
| 239 | 239 | return $tableInfo->getSchemaName() . '.' . $matches[1]; |
@@ -276,8 +276,8 @@ discard block |
||
| 276 | 276 | //$command->bindValue(':schema', $schemaName); |
| 277 | 277 | $primary = []; |
| 278 | 278 | $foreign = []; |
| 279 | - foreach ($command->query() as $row) { |
|
| 280 | - switch (strtolower($row['contype'])) { |
|
| 279 | + foreach($command->query() as $row) { |
|
| 280 | + switch(strtolower($row['contype'])) { |
|
| 281 | 281 | case 'p': |
| 282 | 282 | $primary = array_merge($primary, [strtolower($row['consrc'])]); |
| 283 | 283 | /* |
@@ -295,7 +295,7 @@ discard block |
||
| 295 | 295 | break; |
| 296 | 296 | } |
| 297 | 297 | } |
| 298 | - return [$primary,$foreign]; |
|
| 298 | + return [$primary, $foreign]; |
|
| 299 | 299 | } |
| 300 | 300 | |
| 301 | 301 | /** |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | protected function getPrimaryKeys($src) |
| 307 | 307 | { |
| 308 | 308 | $matches = []; |
| 309 | - if (preg_match('/PRIMARY\s+KEY\s+\(([^\)]+)\)/i', $src, $matches)) { |
|
| 309 | + if(preg_match('/PRIMARY\s+KEY\s+\(([^\)]+)\)/i', $src, $matches)) { |
|
| 310 | 310 | return preg_split('/,\s+/', $matches[1]); |
| 311 | 311 | } |
| 312 | 312 | return []; |
@@ -322,10 +322,10 @@ discard block |
||
| 322 | 322 | $matches = []; |
| 323 | 323 | $brackets = '\(([^\)]+)\)'; |
| 324 | 324 | $find = "/FOREIGN\s+KEY\s+{$brackets}\s+REFERENCES\s+([^\(]+){$brackets}/i"; |
| 325 | - if (preg_match($find, $src, $matches)) { |
|
| 325 | + if(preg_match($find, $src, $matches)) { |
|
| 326 | 326 | $keys = preg_split('/,\s+/', $matches[1]); |
| 327 | 327 | $fkeys = []; |
| 328 | - foreach (preg_split('/,\s+/', $matches[3]) as $i => $fkey) { |
|
| 328 | + foreach(preg_split('/,\s+/', $matches[3]) as $i => $fkey) { |
|
| 329 | 329 | $fkeys[$keys[$i]] = $fkey; |
| 330 | 330 | } |
| 331 | 331 | return ['table' => str_replace('"', '', $matches[2]), 'keys' => $fkeys]; |
@@ -339,8 +339,8 @@ discard block |
||
| 339 | 339 | */ |
| 340 | 340 | protected function isForeignKeyColumn($columnId, $tableInfo) |
| 341 | 341 | { |
| 342 | - foreach ($tableInfo->getForeignKeys() as $fk) { |
|
| 343 | - if ($fk == $columnId) { |
|
| 342 | + foreach($tableInfo->getForeignKeys() as $fk) { |
|
| 343 | + if($fk == $columnId) { |
|
| 344 | 344 | //if(in_array($columnId, array_keys($fk['keys']))) |
| 345 | 345 | return true; |
| 346 | 346 | } |
@@ -356,7 +356,7 @@ discard block |
||
| 356 | 356 | */ |
| 357 | 357 | public function findTableNames($schema = '') |
| 358 | 358 | { |
| 359 | - if ($schema === '') { |
|
| 359 | + if($schema === '') { |
|
| 360 | 360 | $sql = <<<EOD |
| 361 | 361 | SELECT table_name, '{$schema}' as table_schema FROM user_tables |
| 362 | 362 | EOD; |
@@ -372,8 +372,8 @@ discard block |
||
| 372 | 372 | |
| 373 | 373 | $rows = $command->queryAll(); |
| 374 | 374 | $names = []; |
| 375 | - foreach ($rows as $row) { |
|
| 376 | - if ($schema === $this->getDefaultSchema() || $schema === '') { |
|
| 375 | + foreach($rows as $row) { |
|
| 376 | + if($schema === $this->getDefaultSchema() || $schema === '') { |
|
| 377 | 377 | $names[] = $row['TABLE_NAME']; |
| 378 | 378 | } else { |
| 379 | 379 | $names[] = $row['TABLE_SCHEMA'] . '.' . $row['TABLE_NAME']; |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | TABLE_NAME = '{$tableName}' |
| 98 | 98 | AND OWNER = '{$schemaName}' |
| 99 | 99 | ORDER BY a.COLUMN_ID |
| 100 | -EOD; |
|
| 100 | +eod; |
|
| 101 | 101 | $this->getDbConnection()->setActive(true); |
| 102 | 102 | $this->getDbConnection()->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER); |
| 103 | 103 | $command = $this->getDbConnection()->createCommand($sql); |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | from ALL_OBJECTS |
| 162 | 162 | where OBJECT_NAME = '{$tableName}' |
| 163 | 163 | and OWNER = '{$schemaName}' |
| 164 | -EOD; |
|
| 164 | +eod; |
|
| 165 | 165 | $this->getDbConnection()->setActive(true); |
| 166 | 166 | $command = $this->getDbConnection()->createCommand($sql); |
| 167 | 167 | //$command->bindValue(':schema',$schemaName); |
@@ -269,7 +269,7 @@ discard block |
||
| 269 | 269 | and a.TABLE_NAME = '{$tableName}' |
| 270 | 270 | and a.OWNER = '{$schemaName}' |
| 271 | 271 | and a.CONSTRAINT_TYPE in ('P','R') |
| 272 | -EOD; |
|
| 272 | +eod; |
|
| 273 | 273 | $this->getDbConnection()->setActive(true); |
| 274 | 274 | $command = $this->getDbConnection()->createCommand($sql); |
| 275 | 275 | //$command->bindValue(':table', $tableName); |
@@ -359,13 +359,13 @@ discard block |
||
| 359 | 359 | if ($schema === '') { |
| 360 | 360 | $sql = <<<EOD |
| 361 | 361 | SELECT table_name, '{$schema}' as table_schema FROM user_tables |
| 362 | -EOD; |
|
| 362 | +eod; |
|
| 363 | 363 | $command = $this->getDbConnection()->createCommand($sql); |
| 364 | 364 | } else { |
| 365 | 365 | $sql = <<<EOD |
| 366 | 366 | SELECT object_name as table_name, owner as table_schema FROM all_objects |
| 367 | 367 | WHERE object_type = 'TABLE' AND owner=:schema |
| 368 | -EOD; |
|
| 368 | +eod; |
|
| 369 | 369 | $command = $this->getDbConnection()->createCommand($sql); |
| 370 | 370 | $command->bindParam(':schema', $schema); |
| 371 | 371 | } |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | */ |
| 113 | 113 | public function getColumn($name) |
| 114 | 114 | { |
| 115 | - if (($column = $this->_columns->itemAt($name)) !== null) { |
|
| 115 | + if(($column = $this->_columns->itemAt($name)) !== null) { |
|
| 116 | 116 | return $column; |
| 117 | 117 | } |
| 118 | 118 | throw new TDbException('dbtableinfo_invalid_column_name', $name, $this->getTableFullName()); |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | */ |
| 125 | 125 | public function getColumnNames() |
| 126 | 126 | { |
| 127 | - foreach ($this->getColumns() as $column) { |
|
| 127 | + foreach($this->getColumns() as $column) { |
|
| 128 | 128 | $names[] = $column->getColumnName(); |
| 129 | 129 | } |
| 130 | 130 | return $names; |
@@ -151,9 +151,9 @@ discard block |
||
| 151 | 151 | */ |
| 152 | 152 | public function getLowerCaseColumnNames() |
| 153 | 153 | { |
| 154 | - if ($this->_lowercase === null) { |
|
| 154 | + if($this->_lowercase === null) { |
|
| 155 | 155 | $this->_lowercase = []; |
| 156 | - foreach ($this->getColumns()->getKeys() as $key) { |
|
| 156 | + foreach($this->getColumns()->getKeys() as $key) { |
|
| 157 | 157 | $this->_lowercase[strtolower($key)] = $key; |
| 158 | 158 | } |
| 159 | 159 | } |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | class TOracleTableColumn extends TDbTableColumn |
| 28 | 28 | { |
| 29 | 29 | private static $types = [ |
| 30 | - 'numeric' => [ 'numeric' ] |
|
| 30 | + 'numeric' => ['numeric'] |
|
| 31 | 31 | // 'integer' => array('bit', 'bit varying', 'real', 'serial', 'int', 'integer'), |
| 32 | 32 | // 'boolean' => array('boolean'), |
| 33 | 33 | // 'float' => array('bigint', 'bigserial', 'double precision', 'money', 'numeric') |
@@ -40,8 +40,8 @@ discard block |
||
| 40 | 40 | public function getPHPType() |
| 41 | 41 | { |
| 42 | 42 | $dbtype = strtolower($this->getDbType()); |
| 43 | - foreach (self::$types as $type => $dbtypes) { |
|
| 44 | - if (in_array($dbtype, $dbtypes)) { |
|
| 43 | + foreach(self::$types as $type => $dbtypes) { |
|
| 44 | + if(in_array($dbtype, $dbtypes)) { |
|
| 45 | 45 | return $type; |
| 46 | 46 | } |
| 47 | 47 | } |
@@ -36,8 +36,8 @@ discard block |
||
| 36 | 36 | public function getSearchExpression($fields, $keywords) |
| 37 | 37 | { |
| 38 | 38 | $columns = []; |
| 39 | - foreach ($fields as $field) { |
|
| 40 | - if ($this->isSearchableColumn($this->getTableInfo()->getColumn($field))) { |
|
| 39 | + foreach($fields as $field) { |
|
| 40 | + if($this->isSearchableColumn($this->getTableInfo()->getColumn($field))) { |
|
| 41 | 41 | $columns[] = $field; |
| 42 | 42 | } |
| 43 | 43 | } |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | */ |
| 82 | 82 | public function applyLimitOffset($sql, $limit = -1, $offset = -1) |
| 83 | 83 | { |
| 84 | - if ((int) $limit <= 0 && (int) $offset <= 0) { |
|
| 84 | + if((int) $limit <= 0 && (int) $offset <= 0) { |
|
| 85 | 85 | return $sql; |
| 86 | 86 | } |
| 87 | 87 | |
@@ -94,12 +94,12 @@ discard block |
||
| 94 | 94 | $nfimDoSelect = (strpos($sql, 'FROM') !== false ? strpos($sql, 'FROM') : $nfimDaSQL); |
| 95 | 95 | |
| 96 | 96 | $WhereInSubSelect = ""; |
| 97 | - if (strpos($sql, 'WHERE') !== false) { |
|
| 97 | + if(strpos($sql, 'WHERE') !== false) { |
|
| 98 | 98 | $WhereInSubSelect = "WHERE " . substr($sql, strpos($sql, 'WHERE') + 5, $nfimDoWhere - $niniDoWhere); |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | $sORDERBY = ''; |
| 102 | - if (stripos($sql, 'ORDER') !== false) { |
|
| 102 | + if(stripos($sql, 'ORDER') !== false) { |
|
| 103 | 103 | $p = stripos($sql, 'ORDER'); |
| 104 | 104 | $sORDERBY = substr($sql, $p + 8); |
| 105 | 105 | } |
@@ -108,23 +108,23 @@ discard block |
||
| 108 | 108 | $fields = trim(substr($fields, $niniDoSelect)); |
| 109 | 109 | $aliasedFields = ', '; |
| 110 | 110 | |
| 111 | - if (trim($fields) == '*') { |
|
| 111 | + if(trim($fields) == '*') { |
|
| 112 | 112 | $aliasedFields = ", {$fieldsALIAS}.{$fields}"; |
| 113 | 113 | $fields = ''; |
| 114 | 114 | $arr = $this->getTableInfo()->getColumns(); |
| 115 | - foreach ($arr as $field) { |
|
| 115 | + foreach($arr as $field) { |
|
| 116 | 116 | $fields .= strtolower($field->getColumnName()) . ', '; |
| 117 | 117 | } |
| 118 | 118 | $fields = str_replace('"', '', $fields); |
| 119 | 119 | $fields = trim($fields); |
| 120 | 120 | $fields = substr($fields, 0, strlen($fields) - 1); |
| 121 | 121 | } else { |
| 122 | - if (strpos($fields, ',') !== false) { |
|
| 122 | + if(strpos($fields, ',') !== false) { |
|
| 123 | 123 | $arr = $this->getTableInfo()->getColumns(); |
| 124 | - foreach ($arr as $field) { |
|
| 124 | + foreach($arr as $field) { |
|
| 125 | 125 | $field = strtolower($field); |
| 126 | 126 | $existAS = str_ireplace(' as ', '-as-', $field); |
| 127 | - if (strpos($existAS, '-as-') === false) { |
|
| 127 | + if(strpos($existAS, '-as-') === false) { |
|
| 128 | 128 | $aliasedFields .= "{$fieldsALIAS}." . trim($field) . ", "; |
| 129 | 129 | } else { |
| 130 | 130 | $aliasedFields .= "{$field}, "; |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | $aliasedFields = substr($aliasedFields, 0, strlen($aliasedFields) - 1); |
| 135 | 135 | } |
| 136 | 136 | } |
| 137 | - if ($aliasedFields == ', ') { |
|
| 137 | + if($aliasedFields == ', ') { |
|
| 138 | 138 | $aliasedFields = " , $fieldsALIAS.* "; |
| 139 | 139 | } |
| 140 | 140 | |
@@ -146,10 +146,10 @@ discard block |
||
| 146 | 146 | ") WHERE {$pradoNUMLIN} >= {$offset} "; |
| 147 | 147 | |
| 148 | 148 | ************************* */ |
| 149 | - $offset = (int)$offset; |
|
| 150 | - $toReg = $offset + $limit ; |
|
| 149 | + $offset = (int) $offset; |
|
| 150 | + $toReg = $offset + $limit; |
|
| 151 | 151 | $fullTableName = $this->getTableInfo()->getTableFullName(); |
| 152 | - if (empty($sORDERBY)) { |
|
| 152 | + if(empty($sORDERBY)) { |
|
| 153 | 153 | $sORDERBY = "ROWNUM"; |
| 154 | 154 | } |
| 155 | 155 | |
@@ -39,7 +39,7 @@ |
||
| 39 | 39 | */ |
| 40 | 40 | public function getTableFullName() |
| 41 | 41 | { |
| 42 | - if (($schema = $this->getSchemaName()) !== null) { |
|
| 42 | + if(($schema = $this->getSchemaName()) !== null) { |
|
| 43 | 43 | return '`' . $schema . '`.`' . $this->getTableName() . '`'; |
| 44 | 44 | } else { |
| 45 | 45 | return '`' . $this->getTableName() . '`'; |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | list($schemaName, $tableName) = $this->getSchemaTableName($table); |
| 83 | 83 | $find = $schemaName === null ? "`{$tableName}`" : "`{$schemaName}`.`{$tableName}`"; |
| 84 | 84 | $colCase = $this->getDbConnection()->getColumnCase(); |
| 85 | - if ($colCase != TDbColumnCaseMode::Preserved) { |
|
| 85 | + if($colCase != TDbColumnCaseMode::Preserved) { |
|
| 86 | 86 | $this->getDbConnection()->setColumnCase('Preserved'); |
| 87 | 87 | } |
| 88 | 88 | $this->getDbConnection()->setActive(true); |
@@ -90,14 +90,14 @@ discard block |
||
| 90 | 90 | $command = $this->getDbConnection()->createCommand($sql); |
| 91 | 91 | $tableInfo = $this->createNewTableInfo($table); |
| 92 | 92 | $index = 0; |
| 93 | - foreach ($command->query() as $col) { |
|
| 93 | + foreach($command->query() as $col) { |
|
| 94 | 94 | $col['index'] = $index++; |
| 95 | 95 | $this->processColumn($tableInfo, $col); |
| 96 | 96 | } |
| 97 | - if ($index === 0) { |
|
| 97 | + if($index === 0) { |
|
| 98 | 98 | throw new TDbException('dbmetadata_invalid_table_view', $table); |
| 99 | 99 | } |
| 100 | - if ($colCase != TDbColumnCaseMode::Preserved) { |
|
| 100 | + if($colCase != TDbColumnCaseMode::Preserved) { |
|
| 101 | 101 | $this->getDbConnection()->setColumnCase($colCase); |
| 102 | 102 | } |
| 103 | 103 | return $tableInfo; |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | */ |
| 109 | 109 | protected function getServerVersion() |
| 110 | 110 | { |
| 111 | - if (!$this->_serverVersion) { |
|
| 111 | + if(!$this->_serverVersion) { |
|
| 112 | 112 | $version = $this->getDbConnection()->getAttribute(PDO::ATTR_SERVER_VERSION); |
| 113 | 113 | $digits = []; |
| 114 | 114 | preg_match('/(\d+)\.(\d+)\.(\d+)/', $version, $digits); |
@@ -128,40 +128,40 @@ discard block |
||
| 128 | 128 | $info['ColumnName'] = "`$columnId`"; //quote the column names! |
| 129 | 129 | $info['ColumnId'] = $columnId; |
| 130 | 130 | $info['ColumnIndex'] = $col['index']; |
| 131 | - if ($col['Null'] === 'YES') { |
|
| 131 | + if($col['Null'] === 'YES') { |
|
| 132 | 132 | $info['AllowNull'] = true; |
| 133 | 133 | } |
| 134 | - if (is_int(strpos(strtolower($col['Extra']), 'auto_increment'))) { |
|
| 134 | + if(is_int(strpos(strtolower($col['Extra']), 'auto_increment'))) { |
|
| 135 | 135 | $info['AutoIncrement'] = true; |
| 136 | 136 | } |
| 137 | - if ($col['Default'] !== "") { |
|
| 137 | + if($col['Default'] !== "") { |
|
| 138 | 138 | $info['DefaultValue'] = $col['Default']; |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - if ($col['Key'] === 'PRI' || in_array($columnId, $tableInfo->getPrimaryKeys())) { |
|
| 141 | + if($col['Key'] === 'PRI' || in_array($columnId, $tableInfo->getPrimaryKeys())) { |
|
| 142 | 142 | $info['IsPrimaryKey'] = true; |
| 143 | 143 | } |
| 144 | - if ($this->isForeignKeyColumn($columnId, $tableInfo)) { |
|
| 144 | + if($this->isForeignKeyColumn($columnId, $tableInfo)) { |
|
| 145 | 145 | $info['IsForeignKey'] = true; |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | $info['DbType'] = $col['Type']; |
| 149 | 149 | $match = []; |
| 150 | 150 | //find SET/ENUM values, column size, precision, and scale |
| 151 | - if (preg_match('/\((.*)\)/', $col['Type'], $match)) { |
|
| 151 | + if(preg_match('/\((.*)\)/', $col['Type'], $match)) { |
|
| 152 | 152 | $info['DbType'] = preg_replace('/\(.*\)/', '', $col['Type']); |
| 153 | 153 | |
| 154 | 154 | //find SET/ENUM values |
| 155 | - if ($this->isEnumSetType($info['DbType'])) { |
|
| 155 | + if($this->isEnumSetType($info['DbType'])) { |
|
| 156 | 156 | $info['DbTypeValues'] = preg_split("/[',]/S", $match[1], -1, PREG_SPLIT_NO_EMPTY); |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | //find column size, precision and scale |
| 160 | 160 | $pscale = []; |
| 161 | - if (preg_match('/(\d+)(?:,(\d+))?+/', $match[1], $pscale)) { |
|
| 162 | - if ($this->isPrecisionType($info['DbType'])) { |
|
| 161 | + if(preg_match('/(\d+)(?:,(\d+))?+/', $match[1], $pscale)) { |
|
| 162 | + if($this->isPrecisionType($info['DbType'])) { |
|
| 163 | 163 | $info['NumericPrecision'] = intval($pscale[1]); |
| 164 | - if (count($pscale) > 2) { |
|
| 164 | + if(count($pscale) > 2) { |
|
| 165 | 165 | $info['NumericScale'] = intval($pscale[2]); |
| 166 | 166 | } |
| 167 | 167 | } else { |
@@ -202,8 +202,8 @@ discard block |
||
| 202 | 202 | { |
| 203 | 203 | //remove the back ticks and separate out the "database.table" |
| 204 | 204 | $result = explode('.', str_replace('`', '', $table)); |
| 205 | - foreach ($result as $name) { |
|
| 206 | - if (!$this->isValidIdentifier($name)) { |
|
| 205 | + foreach($result as $name) { |
|
| 206 | + if(!$this->isValidIdentifier($name)) { |
|
| 207 | 207 | $ref = 'http://dev.mysql.com/doc/refman/5.0/en/identifiers.html'; |
| 208 | 208 | throw new TDbException('dbcommon_invalid_identifier_name', $table, $ref); |
| 209 | 209 | } |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | list($schemaName, $tableName) = $this->getSchemaTableName($table); |
| 232 | 232 | $info['SchemaName'] = $schemaName; |
| 233 | 233 | $info['TableName'] = $tableName; |
| 234 | - if ($this->getIsView($schemaName, $tableName)) { |
|
| 234 | + if($this->getIsView($schemaName, $tableName)) { |
|
| 235 | 235 | $info['IsView'] = true; |
| 236 | 236 | } |
| 237 | 237 | list($primary, $foreign) = $this->getConstraintKeys($schemaName, $tableName); |
@@ -251,10 +251,10 @@ discard block |
||
| 251 | 251 | */ |
| 252 | 252 | protected function getIsView($schemaName, $tableName) |
| 253 | 253 | { |
| 254 | - if ($this->getServerVersion() < 5.01) { |
|
| 254 | + if($this->getServerVersion() < 5.01) { |
|
| 255 | 255 | return false; |
| 256 | 256 | } |
| 257 | - if ($schemaName !== null) { |
|
| 257 | + if($schemaName !== null) { |
|
| 258 | 258 | $sql = "SHOW FULL TABLES FROM `{$schemaName}` LIKE :table"; |
| 259 | 259 | } else { |
| 260 | 260 | $sql = "SHOW FULL TABLES LIKE :table"; |
@@ -282,19 +282,19 @@ discard block |
||
| 282 | 282 | $sql = "SHOW INDEX FROM {$table}"; |
| 283 | 283 | $command = $this->getDbConnection()->createCommand($sql); |
| 284 | 284 | $primary = []; |
| 285 | - foreach ($command->query() as $row) { |
|
| 286 | - if ($row['Key_name'] === 'PRIMARY') { |
|
| 285 | + foreach($command->query() as $row) { |
|
| 286 | + if($row['Key_name'] === 'PRIMARY') { |
|
| 287 | 287 | $primary[] = $row['Column_name']; |
| 288 | 288 | } |
| 289 | 289 | } |
| 290 | 290 | // MySQL version was increased to >=5.1.21 instead of 5.x |
| 291 | 291 | // due to a MySQL bug (http://bugs.mysql.com/bug.php?id=19588) |
| 292 | - if ($this->getServerVersion() >= 5.121) { |
|
| 292 | + if($this->getServerVersion() >= 5.121) { |
|
| 293 | 293 | $foreign = $this->getForeignConstraints($schemaName, $tableName); |
| 294 | 294 | } else { |
| 295 | 295 | $foreign = $this->findForeignConstraints($schemaName, $tableName); |
| 296 | 296 | } |
| 297 | - return [$primary,$foreign]; |
|
| 297 | + return [$primary, $foreign]; |
|
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | /** |
@@ -322,11 +322,11 @@ discard block |
||
| 322 | 322 | EOD; |
| 323 | 323 | $command = $this->getDbConnection()->createCommand($sql); |
| 324 | 324 | $command->bindValue(':table', $tableName); |
| 325 | - if ($schemaName !== null) { |
|
| 325 | + if($schemaName !== null) { |
|
| 326 | 326 | $command->bindValue(':schema', $schemaName); |
| 327 | 327 | } |
| 328 | 328 | $fkeys = []; |
| 329 | - foreach ($command->query() as $col) { |
|
| 329 | + foreach($command->query() as $col) { |
|
| 330 | 330 | $fkeys[$col['con']]['keys'][$col['col']] = $col['fkcol']; |
| 331 | 331 | $fkeys[$col['con']]['table'] = $col['fktable']; |
| 332 | 332 | } |
@@ -341,13 +341,13 @@ discard block |
||
| 341 | 341 | */ |
| 342 | 342 | protected function getShowCreateTable($schemaName, $tableName) |
| 343 | 343 | { |
| 344 | - if (version_compare(PHP_VERSION, '5.1.3', '<')) { |
|
| 344 | + if(version_compare(PHP_VERSION, '5.1.3', '<')) { |
|
| 345 | 345 | throw new TDbException('dbmetadata_requires_php_version', 'Mysql 4.1.x', '5.1.3'); |
| 346 | 346 | } |
| 347 | 347 | |
| 348 | 348 | //See http://netevil.org/node.php?nid=795&SC=1 |
| 349 | 349 | $this->getDbConnection()->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
| 350 | - if ($schemaName !== null) { |
|
| 350 | + if($schemaName !== null) { |
|
| 351 | 351 | $sql = "SHOW CREATE TABLE `{$schemaName}`.`{$tableName}`"; |
| 352 | 352 | } else { |
| 353 | 353 | $sql = "SHOW CREATE TABLE `{$tableName}`"; |
@@ -370,11 +370,11 @@ discard block |
||
| 370 | 370 | $regexp = '/FOREIGN KEY\s+\(([^\)]+)\)\s+REFERENCES\s+`?([^`]+)`?\s\(([^\)]+)\)/mi'; |
| 371 | 371 | preg_match_all($regexp, $sql, $matches, PREG_SET_ORDER); |
| 372 | 372 | $foreign = []; |
| 373 | - foreach ($matches as $match) { |
|
| 373 | + foreach($matches as $match) { |
|
| 374 | 374 | $fields = array_map('trim', explode(',', str_replace('`', '', $match[1]))); |
| 375 | 375 | $fk_fields = array_map('trim', explode(',', str_replace('`', '', $match[3]))); |
| 376 | 376 | $keys = []; |
| 377 | - foreach ($fields as $k => $v) { |
|
| 377 | + foreach($fields as $k => $v) { |
|
| 378 | 378 | $keys[$v] = $fk_fields[$k]; |
| 379 | 379 | } |
| 380 | 380 | $foreign[] = ['keys' => $keys, 'table' => trim($match[2])]; |
@@ -389,8 +389,8 @@ discard block |
||
| 389 | 389 | */ |
| 390 | 390 | protected function isForeignKeyColumn($columnId, $tableInfo) |
| 391 | 391 | { |
| 392 | - foreach ($tableInfo->getForeignKeys() as $fk) { |
|
| 393 | - if (in_array($columnId, array_keys($fk['keys']))) { |
|
| 392 | + foreach($tableInfo->getForeignKeys() as $fk) { |
|
| 393 | + if(in_array($columnId, array_keys($fk['keys']))) { |
|
| 394 | 394 | return true; |
| 395 | 395 | } |
| 396 | 396 | } |
@@ -405,11 +405,11 @@ discard block |
||
| 405 | 405 | */ |
| 406 | 406 | public function findTableNames($schema = '') |
| 407 | 407 | { |
| 408 | - if ($schema === '') { |
|
| 408 | + if($schema === '') { |
|
| 409 | 409 | return $this->getDbConnection()->createCommand('SHOW TABLES')->queryColumn(); |
| 410 | 410 | } |
| 411 | 411 | $names = $this->getDbConnection()->createCommand('SHOW TABLES FROM ' . $this->quoteTableName($schema))->queryColumn(); |
| 412 | - foreach ($names as &$name) { |
|
| 412 | + foreach($names as &$name) { |
|
| 413 | 413 | $name = $schema . '.' . $name; |
| 414 | 414 | } |
| 415 | 415 | return $names; |
@@ -319,7 +319,7 @@ |
||
| 319 | 319 | REFERENCED_TABLE_NAME IS NOT NULL |
| 320 | 320 | AND TABLE_NAME LIKE :table |
| 321 | 321 | $andSchema |
| 322 | -EOD; |
|
| 322 | +eod; |
|
| 323 | 323 | $command = $this->getDbConnection()->createCommand($sql); |
| 324 | 324 | $command->bindValue(':table', $tableName); |
| 325 | 325 | if ($schemaName !== null) { |