@@ -137,18 +137,18 @@ |
||
| 137 | 137 | * Metadata from the data stored |
| 138 | 138 | */ |
| 139 | 139 | $query = sprintf("SELECT COUNT(*) AS COUNT FROM (SELECT %s FROM %s.%s GROUP BY %s) distinctvalues", |
| 140 | - $this->connection->quoteIdentifier($this->name), |
|
| 141 | - $this->connection->quoteIdentifier($this->database), |
|
| 142 | - $this->connection->quoteIdentifier($this->table), |
|
| 143 | - $this->connection->quoteIdentifier($this->name)); |
|
| 140 | + $this->connection->quoteIdentifier($this->name), |
|
| 141 | + $this->connection->quoteIdentifier($this->database), |
|
| 142 | + $this->connection->quoteIdentifier($this->table), |
|
| 143 | + $this->connection->quoteIdentifier($this->name)); |
|
| 144 | 144 | $this->distinctValues = $this->connection->query($query)->fetchAssoc(false)['COUNT']; |
| 145 | 145 | |
| 146 | 146 | $query = sprintf("SELECT MIN(%s) AS ROWMIN, MAX(%s) AS ROWMAX FROM %s.%s WHERE %s IS NOT NULL", |
| 147 | - $this->connection->quoteIdentifier($this->name), |
|
| 148 | - $this->connection->quoteIdentifier($this->name), |
|
| 149 | - $this->connection->quoteIdentifier($this->database), |
|
| 150 | - $this->connection->quoteIdentifier($this->table), |
|
| 151 | - $this->connection->quoteIdentifier($this->name)); |
|
| 147 | + $this->connection->quoteIdentifier($this->name), |
|
| 148 | + $this->connection->quoteIdentifier($this->name), |
|
| 149 | + $this->connection->quoteIdentifier($this->database), |
|
| 150 | + $this->connection->quoteIdentifier($this->table), |
|
| 151 | + $this->connection->quoteIdentifier($this->name)); |
|
| 152 | 152 | $data = $this->connection->query($query)->fetchAssoc(false); |
| 153 | 153 | $this->maxValue = $data['ROWMAX']; |
| 154 | 154 | $this->minValue = $data['ROWMIN']; |
@@ -97,11 +97,11 @@ discard block |
||
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | /** |
| 100 | - * Primary key column(s) |
|
| 101 | - * @param string $aDatabase database/schema name |
|
| 102 | - * @param string $aTable table name |
|
| 103 | - * @return array |
|
| 104 | - */ |
|
| 100 | + * Primary key column(s) |
|
| 101 | + * @param string $aDatabase database/schema name |
|
| 102 | + * @param string $aTable table name |
|
| 103 | + * @return array |
|
| 104 | + */ |
|
| 105 | 105 | public function getPrimaryKey($aDatabase, $aTable) { |
| 106 | 106 | $columns = array(); |
| 107 | 107 | $SQL = "SELECT ind.name AS INDEX_NAME, |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | * @param string $aDatabase database/schema name |
| 151 | 151 | * @param string $aTable table name |
| 152 | 152 | * @return array |
| 153 | - */ |
|
| 153 | + */ |
|
| 154 | 154 | public function getIndexes($aDatabase, $aTable) { |
| 155 | 155 | |
| 156 | 156 | $indexes = array(); |
@@ -133,20 +133,20 @@ discard block |
||
| 133 | 133 | */ |
| 134 | 134 | if (!in_array($this->type, array('TEXT', 'NTEXT', 'IMAGE'))) { |
| 135 | 135 | $query = sprintf("SELECT COUNT(*) AS COUNT FROM (SELECT %s FROM %s.%s GROUP BY %s) distinctvalues", |
| 136 | - $this->connection->quoteIdentifier($this->name), |
|
| 137 | - $this->connection->quoteIdentifier($this->database), |
|
| 138 | - $this->connection->quoteIdentifier($this->table), |
|
| 139 | - $this->connection->quoteIdentifier($this->name)); |
|
| 136 | + $this->connection->quoteIdentifier($this->name), |
|
| 137 | + $this->connection->quoteIdentifier($this->database), |
|
| 138 | + $this->connection->quoteIdentifier($this->table), |
|
| 139 | + $this->connection->quoteIdentifier($this->name)); |
|
| 140 | 140 | $this->distinctValues = $this->connection->query($query)->fetchAssoc(false)['COUNT']; |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | if (!in_array($this->type, array('BIT', 'TEXT', 'NTEXT', 'IMAGE', 'UNIQUEIDENTIFIER'))) { |
| 144 | 144 | $query = sprintf("SELECT MIN(%s) AS ROWMIN, MAX(%s) AS ROWMAX FROM %s.%s WHERE %s IS NOT NULL", |
| 145 | - $this->connection->quoteIdentifier($this->name), |
|
| 146 | - $this->connection->quoteIdentifier($this->name), |
|
| 147 | - $this->connection->quoteIdentifier($this->database), |
|
| 148 | - $this->connection->quoteIdentifier($this->table), |
|
| 149 | - $this->connection->quoteIdentifier($this->name)); |
|
| 145 | + $this->connection->quoteIdentifier($this->name), |
|
| 146 | + $this->connection->quoteIdentifier($this->name), |
|
| 147 | + $this->connection->quoteIdentifier($this->database), |
|
| 148 | + $this->connection->quoteIdentifier($this->table), |
|
| 149 | + $this->connection->quoteIdentifier($this->name)); |
|
| 150 | 150 | $data = $this->connection->query($query)->fetchAssoc(false); |
| 151 | 151 | $this->maxValue = $data['ROWMAX']; |
| 152 | 152 | $this->minValue = $data['ROWMIN']; |
@@ -221,10 +221,10 @@ discard block |
||
| 221 | 221 | * Work out whether date or datetime |
| 222 | 222 | */ |
| 223 | 223 | $query = sprintf("SELECT COUNT(*) AS COUNT FROM %s.%s WHERE %s IS NOT NULL AND CONVERT(VARCHAR(8), %s, 108) != '00:00:00'", |
| 224 | - $this->connection->quoteIdentifier($this->database), |
|
| 225 | - $this->connection->quoteIdentifier($this->table), |
|
| 226 | - $this->connection->quoteIdentifier($this->name), |
|
| 227 | - $this->connection->quoteIdentifier($this->name)); |
|
| 224 | + $this->connection->quoteIdentifier($this->database), |
|
| 225 | + $this->connection->quoteIdentifier($this->table), |
|
| 226 | + $this->connection->quoteIdentifier($this->name), |
|
| 227 | + $this->connection->quoteIdentifier($this->name)); |
|
| 228 | 228 | $rows = $this->connection->query($query)->fetchAssoc(false); |
| 229 | 229 | |
| 230 | 230 | if ($rows['COUNT'] > 0) { |
@@ -340,7 +340,7 @@ discard block |
||
| 340 | 340 | case 'SMALLDATETIME': |
| 341 | 341 | case 'DATETIMEOFFSET': |
| 342 | 342 | if ($this->precision) { |
| 343 | - return 'TIMESTAMP'; |
|
| 343 | + return 'TIMESTAMP'; |
|
| 344 | 344 | } |
| 345 | 345 | else { |
| 346 | 346 | return 'DATE'; |
@@ -311,74 +311,74 @@ discard block |
||
| 311 | 311 | public function getOracleType() { |
| 312 | 312 | switch ($this->type) { |
| 313 | 313 | |
| 314 | - case 'BIT': |
|
| 315 | - case 'TINYINT': |
|
| 316 | - case 'SMALLINT': |
|
| 317 | - case 'INT': |
|
| 318 | - case 'BIGINT': |
|
| 319 | - case 'DECIMAL': |
|
| 320 | - case 'NUMERIC': |
|
| 321 | - case 'MONEY': |
|
| 322 | - case 'SMALLMONEY': |
|
| 323 | - return 'NUMBER'; |
|
| 324 | - break; |
|
| 325 | - |
|
| 326 | - case 'FLOAT': |
|
| 327 | - return 'BINARY_FLOAT'; |
|
| 328 | - break; |
|
| 314 | + case 'BIT': |
|
| 315 | + case 'TINYINT': |
|
| 316 | + case 'SMALLINT': |
|
| 317 | + case 'INT': |
|
| 318 | + case 'BIGINT': |
|
| 319 | + case 'DECIMAL': |
|
| 320 | + case 'NUMERIC': |
|
| 321 | + case 'MONEY': |
|
| 322 | + case 'SMALLMONEY': |
|
| 323 | + return 'NUMBER'; |
|
| 324 | + break; |
|
| 329 | 325 | |
| 330 | - case 'REAL': |
|
| 331 | - return 'BINARY_DOUBLE'; |
|
| 332 | - break; |
|
| 326 | + case 'FLOAT': |
|
| 327 | + return 'BINARY_FLOAT'; |
|
| 328 | + break; |
|
| 333 | 329 | |
| 334 | - case 'DATE': |
|
| 335 | - return 'DATE'; |
|
| 336 | - break; |
|
| 330 | + case 'REAL': |
|
| 331 | + return 'BINARY_DOUBLE'; |
|
| 332 | + break; |
|
| 337 | 333 | |
| 338 | - case 'DATETIME': |
|
| 339 | - case 'DATETIME2': |
|
| 340 | - case 'SMALLDATETIME': |
|
| 341 | - case 'DATETIMEOFFSET': |
|
| 342 | - if ($this->precision) { |
|
| 343 | - return 'TIMESTAMP'; |
|
| 344 | - } |
|
| 345 | - else { |
|
| 334 | + case 'DATE': |
|
| 346 | 335 | return 'DATE'; |
| 347 | - } |
|
| 348 | - break; |
|
| 336 | + break; |
|
| 349 | 337 | |
| 350 | - case 'TIME': |
|
| 351 | - return 'TIME'; |
|
| 352 | - break; |
|
| 338 | + case 'DATETIME': |
|
| 339 | + case 'DATETIME2': |
|
| 340 | + case 'SMALLDATETIME': |
|
| 341 | + case 'DATETIMEOFFSET': |
|
| 342 | + if ($this->precision) { |
|
| 343 | + return 'TIMESTAMP'; |
|
| 344 | + } |
|
| 345 | + else { |
|
| 346 | + return 'DATE'; |
|
| 347 | + } |
|
| 348 | + break; |
|
| 353 | 349 | |
| 354 | - case 'CHAR': |
|
| 355 | - case 'NCHAR': |
|
| 356 | - return 'NCHAR'; |
|
| 357 | - break; |
|
| 350 | + case 'TIME': |
|
| 351 | + return 'TIME'; |
|
| 352 | + break; |
|
| 358 | 353 | |
| 359 | - case 'VARCHAR': |
|
| 360 | - case 'NVARCHAR': |
|
| 361 | - case 'TEXT': |
|
| 362 | - case 'NTEXT': |
|
| 363 | - return 'NVARCHAR'; |
|
| 364 | - break; |
|
| 354 | + case 'CHAR': |
|
| 355 | + case 'NCHAR': |
|
| 356 | + return 'NCHAR'; |
|
| 357 | + break; |
|
| 365 | 358 | |
| 366 | - case 'BINARY': |
|
| 367 | - case 'VARBINARY': |
|
| 368 | - case 'IMAGE': |
|
| 369 | - return 'BLOB'; |
|
| 370 | - break; |
|
| 359 | + case 'VARCHAR': |
|
| 360 | + case 'NVARCHAR': |
|
| 361 | + case 'TEXT': |
|
| 362 | + case 'NTEXT': |
|
| 363 | + return 'NVARCHAR'; |
|
| 364 | + break; |
|
| 371 | 365 | |
| 372 | - case 'ROWVERSION': |
|
| 373 | - case 'TIMESTAMP': //XXX rowversion, not a time |
|
| 374 | - case 'HIERARCHYID': |
|
| 375 | - case 'XML': |
|
| 376 | - return 'NVARCHAR'; |
|
| 377 | - break; |
|
| 366 | + case 'BINARY': |
|
| 367 | + case 'VARBINARY': |
|
| 368 | + case 'IMAGE': |
|
| 369 | + return 'BLOB'; |
|
| 370 | + break; |
|
| 378 | 371 | |
| 379 | - case 'UNIQUEIDENTIFIER': |
|
| 380 | - return 'CHAR'; |
|
| 381 | - break; |
|
| 372 | + case 'ROWVERSION': |
|
| 373 | + case 'TIMESTAMP': //XXX rowversion, not a time |
|
| 374 | + case 'HIERARCHYID': |
|
| 375 | + case 'XML': |
|
| 376 | + return 'NVARCHAR'; |
|
| 377 | + break; |
|
| 378 | + |
|
| 379 | + case 'UNIQUEIDENTIFIER': |
|
| 380 | + return 'CHAR'; |
|
| 381 | + break; |
|
| 382 | 382 | |
| 383 | 383 | default: |
| 384 | 384 | throw new \Exception("Unknown conversion for column type {$this->type}"); |
@@ -418,8 +418,8 @@ discard block |
||
| 418 | 418 | return 36; |
| 419 | 419 | break; |
| 420 | 420 | |
| 421 | - default: |
|
| 422 | - return 0; |
|
| 421 | + default: |
|
| 422 | + return 0; |
|
| 423 | 423 | } |
| 424 | 424 | } |
| 425 | 425 | |
@@ -29,9 +29,9 @@ discard block |
||
| 29 | 29 | |
| 30 | 30 | if (in_array($MySQLType, array('ENUM', 'SET'))) { |
| 31 | 31 | $query = sprintf("SHOW COLUMNS FROM %s.%s LIKE %s", |
| 32 | - $this->connection->quoteIdentifier($this->database), |
|
| 33 | - $this->connection->quoteIdentifier($this->table), |
|
| 34 | - $this->connection->escape($this->name)); |
|
| 32 | + $this->connection->quoteIdentifier($this->database), |
|
| 33 | + $this->connection->quoteIdentifier($this->table), |
|
| 34 | + $this->connection->escape($this->name)); |
|
| 35 | 35 | |
| 36 | 36 | $statement = $this->connection->query($query); |
| 37 | 37 | $values = $statement->fetchAssoc(false)['Type']; |
@@ -44,11 +44,11 @@ discard block |
||
| 44 | 44 | } |
| 45 | 45 | else if (in_array($MySQLType, array('CHAR', 'VARCHAR')) && $this->getLength() < 64 && $this->getDistinctValueCount() <= 16) { |
| 46 | 46 | $query = sprintf("SELECT DISTINCT %s FROM %s.%s WHERE %s IS NOT NULL ORDER BY %s ASC", |
| 47 | - $this->connection->quoteIdentifier($this->name), |
|
| 48 | - $this->connection->quoteIdentifier($this->database), |
|
| 49 | - $this->connection->quoteIdentifier($this->table), |
|
| 50 | - $this->connection->quoteIdentifier($this->name), |
|
| 51 | - $this->connection->quoteIdentifier($this->name)); |
|
| 47 | + $this->connection->quoteIdentifier($this->name), |
|
| 48 | + $this->connection->quoteIdentifier($this->database), |
|
| 49 | + $this->connection->quoteIdentifier($this->table), |
|
| 50 | + $this->connection->quoteIdentifier($this->name), |
|
| 51 | + $this->connection->quoteIdentifier($this->name)); |
|
| 52 | 52 | $values = array(); |
| 53 | 53 | foreach ($this->connection->query($query) as $value) { |
| 54 | 54 | $values[] = trim($value[$this->name]); |
@@ -107,7 +107,7 @@ |
||
| 107 | 107 | * @param string $aDatabase database/schema name |
| 108 | 108 | * @param string $aTable table name |
| 109 | 109 | * @return array |
| 110 | - */ |
|
| 110 | + */ |
|
| 111 | 111 | public function getIndexes($aDatabase, $aTable) { |
| 112 | 112 | |
| 113 | 113 | $indexes = array(); |
@@ -134,18 +134,18 @@ discard block |
||
| 134 | 134 | */ |
| 135 | 135 | try { |
| 136 | 136 | $query = sprintf("SELECT COUNT(*) AS COUNT FROM (SELECT %s FROM %s.%s GROUP BY %s) distinctvalues", |
| 137 | - $this->connection->quoteIdentifier($this->name), |
|
| 138 | - $this->connection->quoteIdentifier($this->database), |
|
| 139 | - $this->connection->quoteIdentifier($this->table), |
|
| 140 | - $this->connection->quoteIdentifier($this->name)); |
|
| 137 | + $this->connection->quoteIdentifier($this->name), |
|
| 138 | + $this->connection->quoteIdentifier($this->database), |
|
| 139 | + $this->connection->quoteIdentifier($this->table), |
|
| 140 | + $this->connection->quoteIdentifier($this->name)); |
|
| 141 | 141 | $this->distinctValues = $this->connection->query($query)->fetchAssoc(false)['COUNT']; |
| 142 | 142 | |
| 143 | 143 | $query = sprintf("SELECT MIN(%s) AS ROWMIN, MAX(%s) AS ROWMAX FROM %s.%s WHERE %s IS NOT NULL", |
| 144 | - $this->connection->quoteIdentifier($this->name), |
|
| 145 | - $this->connection->quoteIdentifier($this->name), |
|
| 146 | - $this->connection->quoteIdentifier($this->database), |
|
| 147 | - $this->connection->quoteIdentifier($this->table), |
|
| 148 | - $this->connection->quoteIdentifier($this->name)); |
|
| 144 | + $this->connection->quoteIdentifier($this->name), |
|
| 145 | + $this->connection->quoteIdentifier($this->name), |
|
| 146 | + $this->connection->quoteIdentifier($this->database), |
|
| 147 | + $this->connection->quoteIdentifier($this->table), |
|
| 148 | + $this->connection->quoteIdentifier($this->name)); |
|
| 149 | 149 | $data = $this->connection->query($query)->fetchAssoc(false); |
| 150 | 150 | $this->maxValue = $data['ROWMAX']; |
| 151 | 151 | $this->minValue = $data['ROWMIN']; |
@@ -154,9 +154,9 @@ discard block |
||
| 154 | 154 | catch (\Exception $e) { //LONG column has restrictions on querying, so just get total value count |
| 155 | 155 | if (strpos($e->getMessage(), 'ORA-00997: illegal use of LONG datatype') !== false) { |
| 156 | 156 | $query = sprintf("SELECT COUNT(*) AS COUNT FROM %s.%s WHERE %s IS NOT NULL", |
| 157 | - $this->connection->quoteIdentifier($this->database), |
|
| 158 | - $this->connection->quoteIdentifier($this->table), |
|
| 159 | - $this->connection->quoteIdentifier($this->name)); |
|
| 157 | + $this->connection->quoteIdentifier($this->database), |
|
| 158 | + $this->connection->quoteIdentifier($this->table), |
|
| 159 | + $this->connection->quoteIdentifier($this->name)); |
|
| 160 | 160 | $this->distinctValues = $this->connection->query($query)->fetchAssoc(false)['COUNT'] ?: 1; |
| 161 | 161 | } |
| 162 | 162 | } |
@@ -263,10 +263,10 @@ discard block |
||
| 263 | 263 | * Work out whether date or datetime |
| 264 | 264 | */ |
| 265 | 265 | $query = sprintf("SELECT COUNT(*) AS COUNT FROM %s.%s WHERE %s IS NOT NULL AND TO_CHAR(%s, 'SSSSS') > 0", |
| 266 | - $this->connection->quoteIdentifier($this->database), |
|
| 267 | - $this->connection->quoteIdentifier($this->table), |
|
| 268 | - $this->connection->quoteIdentifier($this->name), |
|
| 269 | - $this->connection->quoteIdentifier($this->name)); |
|
| 266 | + $this->connection->quoteIdentifier($this->database), |
|
| 267 | + $this->connection->quoteIdentifier($this->table), |
|
| 268 | + $this->connection->quoteIdentifier($this->name), |
|
| 269 | + $this->connection->quoteIdentifier($this->name)); |
|
| 270 | 270 | $rows = $this->connection->query($query)->fetchAssoc(false); |
| 271 | 271 | |
| 272 | 272 | if ($rows['COUNT'] > 0) { |
@@ -103,11 +103,11 @@ discard block |
||
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | /** |
| 106 | - * Primary key column(s) |
|
| 107 | - * @param string $aDatabase database/schema name |
|
| 108 | - * @param string $aTable table name |
|
| 109 | - * @return array |
|
| 110 | - */ |
|
| 106 | + * Primary key column(s) |
|
| 107 | + * @param string $aDatabase database/schema name |
|
| 108 | + * @param string $aTable table name |
|
| 109 | + * @return array |
|
| 110 | + */ |
|
| 111 | 111 | public function getPrimaryKey($aDatabase, $aTable) { |
| 112 | 112 | $columns = array(); |
| 113 | 113 | $SQL = "SELECT ORDINAL_POSITION, COLUMN_NAME |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | * @param string $aDatabase database/schema name |
| 134 | 134 | * @param string $aTable table name |
| 135 | 135 | * @return array |
| 136 | - */ |
|
| 136 | + */ |
|
| 137 | 137 | public function getIndexes($aDatabase, $aTable) { |
| 138 | 138 | |
| 139 | 139 | $indexes = array(); |