diff options
Diffstat (limited to 'includes/database/database.inc')
-rw-r--r-- | includes/database/database.inc | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/includes/database/database.inc b/includes/database/database.inc index 22bd8fe2e..24ac3c42c 100644 --- a/includes/database/database.inc +++ b/includes/database/database.inc @@ -316,6 +316,13 @@ abstract class DatabaseConnection extends PDO { */ protected $schema = NULL; + /** + * A unique number used for dynamic placeholders. + * + * It gets reset after every executed query. + */ + protected $nextPlaceholder = 1; + function __construct($dsn, $username, $password, $driver_options = array()) { // Because the other methods don't seem to work right. $driver_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION; @@ -330,6 +337,20 @@ abstract class DatabaseConnection extends PDO { } /** + * Reset the next placeholder number back to 1. + */ + public function resetPlaceholder() { + $this->nextPlaceholder = 1; + } + + /** + * Get the current unique placeholder number and increment it. + */ + public function getNextPlaceholder() { + return $this->nextPlaceholder++; + } + + /** * Return the default query options for any given query. * * A given query can be customized with a number of option flags in an @@ -567,6 +588,9 @@ abstract class DatabaseConnection extends PDO { $stmt->execute($args, $options); } + // Reset the placeholder numbering. + $this->resetPlaceholder(); + // Depending on the type of query we may need to return a different value. // See DatabaseConnection::defaultOptions() for a description of each value. switch ($options['return']) { |