Merge pull request #3353 from tractorcow/pulls/3.2/fix-pdo

BUG Fix PDOConnector issues
This commit is contained in:
Ingo Schommer 2014-08-02 11:35:31 +12:00
commit fc1eb1cfbc
4 changed files with 62 additions and 65 deletions

View File

@ -14,20 +14,20 @@ env:
matrix:
include:
- php: 5.3
env: DB=PGSQL CORE_RELEASE=master
- php: 5.3
- php: 5.4
env: DB=SQLITE CORE_RELEASE=master
- php: 5.4
env: DB=PGSQL CORE_RELEASE=master
- php: 5.4
env: DB=MYSQL CORE_RELEASE=master
- php: 5.4
env: DB=MYSQL CORE_RELEASE=master PDO=1
- php: 5.5
env: DB=MYSQL CORE_RELEASE=master
- php: 5.6
env: DB=MYSQL CORE_RELEASE=master
- php: 5.4
env: DB=MYSQL CORE_RELEASE=master BEHAT_TEST=1
- php: 5.6
env: DB=MYSQL CORE_RELEASE=master
before_script:
- composer self-update

View File

@ -112,7 +112,6 @@ class MySQLDatabase extends SS_Database {
if (!class_exists('File'))
throw new Exception('MySQLDatabase->searchEngine() requires "File" class');
$fileFilter = '';
$keywords = $this->escapeString($keywords);
$htmlEntityKeywords = htmlentities($keywords, ENT_NOQUOTES, 'UTF-8');
@ -233,30 +232,30 @@ class MySQLDatabase extends SS_Database {
public function transactionStart($transactionMode = false, $sessionCharacteristics = false) {
// This sets the isolation level for the NEXT transaction, not the current one.
if ($transactionMode) {
$this->query('SET TRANSACTION ' . $transactionMode . ';');
$this->query('SET TRANSACTION ' . $transactionMode);
}
$this->query('START TRANSACTION;');
$this->query('START TRANSACTION');
if ($sessionCharacteristics) {
$this->query('SET SESSION TRANSACTION ' . $sessionCharacteristics . ';');
$this->query('SET SESSION TRANSACTION ' . $sessionCharacteristics);
}
}
public function transactionSavepoint($savepoint) {
$this->query("SAVEPOINT $savepoint;");
$this->query("SAVEPOINT $savepoint");
}
public function transactionRollback($savepoint = false) {
if ($savepoint) {
$this->query('ROLLBACK TO ' . $savepoint . ';');
$this->query('ROLLBACK TO ' . $savepoint);
} else {
$this->query('ROLLBACK');
}
}
public function transactionEnd($chain = false) {
$this->query('COMMIT AND ' . ($chain ? '' : 'NO ') . 'CHAIN;');
$this->query('COMMIT AND ' . ($chain ? '' : 'NO ') . 'CHAIN');
}
public function comparisonClause($field, $value, $exact = false, $negate = false, $caseSensitive = null,

View File

@ -128,17 +128,19 @@ class PDOConnector extends DBConnector {
// Connection commands to be run on every re-connection
$options = array(
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
PDO::ATTR_EMULATE_PREPARES => self::is_emulate_prepare()
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'
);
if(self::is_emulate_prepare()) {
$options[PDO::ATTR_EMULATE_PREPARES] = true;
}
// May throw a PDOException if fails
if(empty($parameters['username']) || empty($parameters['password'])) {
$this->pdoConnection = new PDO($driver.implode(';', $dsn));
} else {
$this->pdoConnection = new PDO($driver.implode(';', $dsn), $parameters['username'],
$parameters['password'], $options);
}
$this->pdoConnection = new PDO(
$driver.implode(';', $dsn),
empty($parameters['username']) ? '' : $parameters['username'],
empty($parameters['password']) ? '' : $parameters['password'],
$options
);
// Show selected DB if requested
if($this->pdoConnection && $selectDB && !empty($parameters['database'])) {

View File

@ -27,10 +27,6 @@ class PDOQuery extends SS_Query {
$statement->closeCursor();
}
public function __destruct() {
$this->statement->closeCursor();
}
public function seek($row) {
$this->rowNum = $row - 1;
return $this->nextRecord();