Révision 01dfd3b5
Ajouté par Assos Assos il y a plus de 3 ans
drupal7/includes/database/database.inc | ||
---|---|---|
310 | 310 |
*/ |
311 | 311 |
protected $escapedAliases = array(); |
312 | 312 |
|
313 |
/** |
|
314 |
* List of un-prefixed table names, keyed by prefixed table names. |
|
315 |
* |
|
316 |
* @var array |
|
317 |
*/ |
|
318 |
protected $unprefixedTablesMap = array(); |
|
319 |
|
|
313 | 320 |
function __construct($dsn, $username, $password, $driver_options = array()) { |
314 | 321 |
// Initialize and prepare the connection prefix. |
315 | 322 |
$this->setPrefix(isset($this->connectionOptions['prefix']) ? $this->connectionOptions['prefix'] : ''); |
... | ... | |
338 | 345 |
// Destroy all references to this connection by setting them to NULL. |
339 | 346 |
// The Statement class attribute only accepts a new value that presents a |
340 | 347 |
// proper callable, so we reset it to PDOStatement. |
341 |
$this->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('PDOStatement', array())); |
|
348 |
if (!empty($this->statementClass)) { |
|
349 |
$this->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('PDOStatement', array())); |
|
350 |
} |
|
342 | 351 |
$this->schema = NULL; |
343 | 352 |
} |
344 | 353 |
|
... | ... | |
442 | 451 |
$this->prefixReplace[] = $this->prefixes['default']; |
443 | 452 |
$this->prefixSearch[] = '}'; |
444 | 453 |
$this->prefixReplace[] = ''; |
454 |
|
|
455 |
// Set up a map of prefixed => un-prefixed tables. |
|
456 |
foreach ($this->prefixes as $table_name => $prefix) { |
|
457 |
if ($table_name !== 'default') { |
|
458 |
$this->unprefixedTablesMap[$prefix . $table_name] = $table_name; |
|
459 |
} |
|
460 |
} |
|
445 | 461 |
} |
446 | 462 |
|
447 | 463 |
/** |
... | ... | |
477 | 493 |
} |
478 | 494 |
} |
479 | 495 |
|
496 |
/** |
|
497 |
* Gets a list of individually prefixed table names. |
|
498 |
* |
|
499 |
* @return array |
|
500 |
* An array of un-prefixed table names, keyed by their fully qualified table |
|
501 |
* names (i.e. prefix + table_name). |
|
502 |
*/ |
|
503 |
public function getUnprefixedTablesMap() { |
|
504 |
return $this->unprefixedTablesMap; |
|
505 |
} |
|
506 |
|
|
480 | 507 |
/** |
481 | 508 |
* Prepares a query string and returns the prepared statement. |
482 | 509 |
* |
... | ... | |
2840 | 2867 |
* |
2841 | 2868 |
* @param $table_expression |
2842 | 2869 |
* An SQL expression, for example "simpletest%" (without the quotes). |
2843 |
* BEWARE: this is not prefixed, the caller should take care of that. |
|
2844 | 2870 |
* |
2845 | 2871 |
* @return |
2846 | 2872 |
* Array, both the keys and the values are the matching tables. |
... | ... | |
2849 | 2875 |
return Database::getConnection()->schema()->findTables($table_expression); |
2850 | 2876 |
} |
2851 | 2877 |
|
2878 |
/** |
|
2879 |
* Finds all tables that are like the specified base table name. This is a |
|
2880 |
* backport of the change made to db_find_tables in Drupal 8 to work with |
|
2881 |
* virtual, un-prefixed table names. The original function is retained for |
|
2882 |
* Backwards Compatibility. |
|
2883 |
* @see https://www.drupal.org/node/2552435 |
|
2884 |
* |
|
2885 |
* @param $table_expression |
|
2886 |
* An SQL expression, for example "simpletest%" (without the quotes). |
|
2887 |
* |
|
2888 |
* @return |
|
2889 |
* Array, both the keys and the values are the matching tables. |
|
2890 |
*/ |
|
2891 |
function db_find_tables_d8($table_expression) { |
|
2892 |
return Database::getConnection()->schema()->findTablesD8($table_expression); |
|
2893 |
} |
|
2894 |
|
|
2852 | 2895 |
function _db_create_keys_sql($spec) { |
2853 | 2896 |
return Database::getConnection()->schema()->createKeysSql($spec); |
2854 | 2897 |
} |
Formats disponibles : Unified diff
Udpate to 7.77