mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #3353 from tractorcow/pulls/3.2/fix-pdo
BUG Fix PDOConnector issues
This commit is contained in:
commit
fc1eb1cfbc
10
.travis.yml
10
.travis.yml
@ -14,20 +14,20 @@ env:
|
|||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
- php: 5.3
|
- php: 5.4
|
||||||
env: DB=PGSQL CORE_RELEASE=master
|
|
||||||
- php: 5.3
|
|
||||||
env: DB=SQLITE CORE_RELEASE=master
|
env: DB=SQLITE CORE_RELEASE=master
|
||||||
|
- php: 5.4
|
||||||
|
env: DB=PGSQL CORE_RELEASE=master
|
||||||
- php: 5.4
|
- php: 5.4
|
||||||
env: DB=MYSQL CORE_RELEASE=master
|
env: DB=MYSQL CORE_RELEASE=master
|
||||||
|
- php: 5.4
|
||||||
|
env: DB=MYSQL CORE_RELEASE=master PDO=1
|
||||||
- php: 5.5
|
- php: 5.5
|
||||||
env: DB=MYSQL CORE_RELEASE=master
|
env: DB=MYSQL CORE_RELEASE=master
|
||||||
- php: 5.6
|
- php: 5.6
|
||||||
env: DB=MYSQL CORE_RELEASE=master
|
env: DB=MYSQL CORE_RELEASE=master
|
||||||
- php: 5.4
|
- php: 5.4
|
||||||
env: DB=MYSQL CORE_RELEASE=master BEHAT_TEST=1
|
env: DB=MYSQL CORE_RELEASE=master BEHAT_TEST=1
|
||||||
- php: 5.6
|
|
||||||
env: DB=MYSQL CORE_RELEASE=master
|
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- composer self-update
|
- composer self-update
|
||||||
|
@ -112,7 +112,6 @@ class MySQLDatabase extends SS_Database {
|
|||||||
if (!class_exists('File'))
|
if (!class_exists('File'))
|
||||||
throw new Exception('MySQLDatabase->searchEngine() requires "File" class');
|
throw new Exception('MySQLDatabase->searchEngine() requires "File" class');
|
||||||
|
|
||||||
$fileFilter = '';
|
|
||||||
$keywords = $this->escapeString($keywords);
|
$keywords = $this->escapeString($keywords);
|
||||||
$htmlEntityKeywords = htmlentities($keywords, ENT_NOQUOTES, 'UTF-8');
|
$htmlEntityKeywords = htmlentities($keywords, ENT_NOQUOTES, 'UTF-8');
|
||||||
|
|
||||||
@ -233,30 +232,30 @@ class MySQLDatabase extends SS_Database {
|
|||||||
public function transactionStart($transactionMode = false, $sessionCharacteristics = false) {
|
public function transactionStart($transactionMode = false, $sessionCharacteristics = false) {
|
||||||
// This sets the isolation level for the NEXT transaction, not the current one.
|
// This sets the isolation level for the NEXT transaction, not the current one.
|
||||||
if ($transactionMode) {
|
if ($transactionMode) {
|
||||||
$this->query('SET TRANSACTION ' . $transactionMode . ';');
|
$this->query('SET TRANSACTION ' . $transactionMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->query('START TRANSACTION;');
|
$this->query('START TRANSACTION');
|
||||||
|
|
||||||
if ($sessionCharacteristics) {
|
if ($sessionCharacteristics) {
|
||||||
$this->query('SET SESSION TRANSACTION ' . $sessionCharacteristics . ';');
|
$this->query('SET SESSION TRANSACTION ' . $sessionCharacteristics);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function transactionSavepoint($savepoint) {
|
public function transactionSavepoint($savepoint) {
|
||||||
$this->query("SAVEPOINT $savepoint;");
|
$this->query("SAVEPOINT $savepoint");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function transactionRollback($savepoint = false) {
|
public function transactionRollback($savepoint = false) {
|
||||||
if ($savepoint) {
|
if ($savepoint) {
|
||||||
$this->query('ROLLBACK TO ' . $savepoint . ';');
|
$this->query('ROLLBACK TO ' . $savepoint);
|
||||||
} else {
|
} else {
|
||||||
$this->query('ROLLBACK');
|
$this->query('ROLLBACK');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function transactionEnd($chain = false) {
|
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,
|
public function comparisonClause($field, $value, $exact = false, $negate = false, $caseSensitive = null,
|
||||||
|
@ -128,17 +128,19 @@ class PDOConnector extends DBConnector {
|
|||||||
|
|
||||||
// Connection commands to be run on every re-connection
|
// Connection commands to be run on every re-connection
|
||||||
$options = array(
|
$options = array(
|
||||||
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
|
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'
|
||||||
PDO::ATTR_EMULATE_PREPARES => self::is_emulate_prepare()
|
|
||||||
);
|
);
|
||||||
|
if(self::is_emulate_prepare()) {
|
||||||
|
$options[PDO::ATTR_EMULATE_PREPARES] = true;
|
||||||
|
}
|
||||||
|
|
||||||
// May throw a PDOException if fails
|
// May throw a PDOException if fails
|
||||||
if(empty($parameters['username']) || empty($parameters['password'])) {
|
$this->pdoConnection = new PDO(
|
||||||
$this->pdoConnection = new PDO($driver.implode(';', $dsn));
|
$driver.implode(';', $dsn),
|
||||||
} else {
|
empty($parameters['username']) ? '' : $parameters['username'],
|
||||||
$this->pdoConnection = new PDO($driver.implode(';', $dsn), $parameters['username'],
|
empty($parameters['password']) ? '' : $parameters['password'],
|
||||||
$parameters['password'], $options);
|
$options
|
||||||
}
|
);
|
||||||
|
|
||||||
// Show selected DB if requested
|
// Show selected DB if requested
|
||||||
if($this->pdoConnection && $selectDB && !empty($parameters['database'])) {
|
if($this->pdoConnection && $selectDB && !empty($parameters['database'])) {
|
||||||
|
@ -27,10 +27,6 @@ class PDOQuery extends SS_Query {
|
|||||||
$statement->closeCursor();
|
$statement->closeCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __destruct() {
|
|
||||||
$this->statement->closeCursor();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function seek($row) {
|
public function seek($row) {
|
||||||
$this->rowNum = $row - 1;
|
$this->rowNum = $row - 1;
|
||||||
return $this->nextRecord();
|
return $this->nextRecord();
|
||||||
|
Loading…
Reference in New Issue
Block a user