Commit 87049d69 authored by Steve Müller's avatar Steve Müller

fix CS

parent 0083774f
...@@ -33,7 +33,7 @@ class SQLAnywhereConnection implements Connection ...@@ -33,7 +33,7 @@ class SQLAnywhereConnection implements Connection
/** /**
* @var resource The SQL Anywhere connection resource. * @var resource The SQL Anywhere connection resource.
*/ */
private $conn; private $connection;
/** /**
* Constructor. * Constructor.
...@@ -47,31 +47,25 @@ class SQLAnywhereConnection implements Connection ...@@ -47,31 +47,25 @@ class SQLAnywhereConnection implements Connection
*/ */
public function __construct($dsn, $persistent = false) public function __construct($dsn, $persistent = false)
{ {
$this->conn = $persistent ? @sasql_pconnect($dsn) : @sasql_connect($dsn); $this->connection = $persistent ? @sasql_pconnect($dsn) : @sasql_connect($dsn);
if ( ! is_resource($this->conn) || get_resource_type($this->conn) != 'SQLAnywhere connection') { if ( ! is_resource($this->connection) || get_resource_type($this->connection) !== 'SQLAnywhere connection') {
throw SQLAnywhereException::fromSQLAnywhereError(); throw SQLAnywhereException::fromSQLAnywhereError();
} }
/** // Disable PHP warnings on error.
* Disable PHP warnings on error if ( ! sasql_set_option($this->connection, 'verbose_errors', false)) {
*/ throw SQLAnywhereException::fromSQLAnywhereError($this->connection);
if ( ! sasql_set_option($this->conn, 'verbose_errors', false)) {
throw SQLAnywhereException::fromSQLAnywhereError($this->conn);
} }
/** // Enable auto committing by default.
* Enable auto committing by default if ( ! sasql_set_option($this->connection, 'auto_commit', 'on')) {
*/ throw SQLAnywhereException::fromSQLAnywhereError($this->connection);
if ( ! sasql_set_option($this->conn, 'auto_commit', 'on')) {
throw SQLAnywhereException::fromSQLAnywhereError($this->conn);
} }
/** // Enable exact, non-approximated row count retrieval.
* Enable exact, non-approximated row count retrieval if ( ! sasql_set_option($this->connection, 'row_counts', true)) {
*/ throw SQLAnywhereException::fromSQLAnywhereError($this->connection);
if ( ! sasql_set_option($this->conn, 'row_counts', true)) {
throw SQLAnywhereException::fromSQLAnywhereError($this->conn);
} }
} }
...@@ -82,8 +76,8 @@ class SQLAnywhereConnection implements Connection ...@@ -82,8 +76,8 @@ class SQLAnywhereConnection implements Connection
*/ */
public function beginTransaction() public function beginTransaction()
{ {
if ( ! sasql_set_option($this->conn, 'auto_commit', 'off')) { if ( ! sasql_set_option($this->connection, 'auto_commit', 'off')) {
throw SQLAnywhereException::fromSQLAnywhereError($this->conn); throw SQLAnywhereException::fromSQLAnywhereError($this->connection);
} }
return true; return true;
...@@ -96,8 +90,8 @@ class SQLAnywhereConnection implements Connection ...@@ -96,8 +90,8 @@ class SQLAnywhereConnection implements Connection
*/ */
public function commit() public function commit()
{ {
if ( ! sasql_commit($this->conn)) { if ( ! sasql_commit($this->connection)) {
throw SQLAnywhereException::fromSQLAnywhereError($this->conn); throw SQLAnywhereException::fromSQLAnywhereError($this->connection);
} }
$this->endTransaction(); $this->endTransaction();
...@@ -110,7 +104,7 @@ class SQLAnywhereConnection implements Connection ...@@ -110,7 +104,7 @@ class SQLAnywhereConnection implements Connection
*/ */
public function errorCode() public function errorCode()
{ {
return sasql_errorcode($this->conn); return sasql_errorcode($this->connection);
} }
/** /**
...@@ -118,7 +112,7 @@ class SQLAnywhereConnection implements Connection ...@@ -118,7 +112,7 @@ class SQLAnywhereConnection implements Connection
*/ */
public function errorInfo() public function errorInfo()
{ {
return sasql_error($this->conn); return sasql_error($this->connection);
} }
/** /**
...@@ -127,6 +121,7 @@ class SQLAnywhereConnection implements Connection ...@@ -127,6 +121,7 @@ class SQLAnywhereConnection implements Connection
public function exec($statement) public function exec($statement)
{ {
$stmt = $this->prepare($statement); $stmt = $this->prepare($statement);
$stmt->execute(); $stmt->execute();
return $stmt->rowCount(); return $stmt->rowCount();
...@@ -137,8 +132,8 @@ class SQLAnywhereConnection implements Connection ...@@ -137,8 +132,8 @@ class SQLAnywhereConnection implements Connection
*/ */
public function lastInsertId($name = null) public function lastInsertId($name = null)
{ {
if ($name === null) { if (null === $name) {
return sasql_insert_id($this->conn); return sasql_insert_id($this->connection);
} }
return $this->query('SELECT ' . $name . '.CURRVAL')->fetchColumn(); return $this->query('SELECT ' . $name . '.CURRVAL')->fetchColumn();
...@@ -149,7 +144,7 @@ class SQLAnywhereConnection implements Connection ...@@ -149,7 +144,7 @@ class SQLAnywhereConnection implements Connection
*/ */
public function prepare($prepareString) public function prepare($prepareString)
{ {
return new SQLAnywhereStatement($this->conn, $prepareString); return new SQLAnywhereStatement($this->connection, $prepareString);
} }
/** /**
...@@ -159,6 +154,7 @@ class SQLAnywhereConnection implements Connection ...@@ -159,6 +154,7 @@ class SQLAnywhereConnection implements Connection
{ {
$args = func_get_args(); $args = func_get_args();
$stmt = $this->prepare($args[0]); $stmt = $this->prepare($args[0]);
$stmt->execute(); $stmt->execute();
return $stmt; return $stmt;
...@@ -173,7 +169,7 @@ class SQLAnywhereConnection implements Connection ...@@ -173,7 +169,7 @@ class SQLAnywhereConnection implements Connection
return $input; return $input;
} }
return "'" . sasql_escape_string($this->conn, $input) . "'"; return "'" . sasql_escape_string($this->connection, $input) . "'";
} }
/** /**
...@@ -183,8 +179,8 @@ class SQLAnywhereConnection implements Connection ...@@ -183,8 +179,8 @@ class SQLAnywhereConnection implements Connection
*/ */
public function rollBack() public function rollBack()
{ {
if ( ! sasql_rollback($this->conn)) { if ( ! sasql_rollback($this->connection)) {
throw SQLAnywhereException::fromSQLAnywhereError($this->conn); throw SQLAnywhereException::fromSQLAnywhereError($this->connection);
} }
$this->endTransaction(); $this->endTransaction();
...@@ -201,8 +197,8 @@ class SQLAnywhereConnection implements Connection ...@@ -201,8 +197,8 @@ class SQLAnywhereConnection implements Connection
*/ */
private function endTransaction() private function endTransaction()
{ {
if ( ! sasql_set_option($this->conn, 'auto_commit', 'on')) { if ( ! sasql_set_option($this->connection, 'auto_commit', 'on')) {
throw SQLAnywhereException::fromSQLAnywhereError($this->conn); throw SQLAnywhereException::fromSQLAnywhereError($this->connection);
} }
return true; return true;
......
...@@ -42,16 +42,15 @@ class SQLAnywhereException extends DBALException ...@@ -42,16 +42,15 @@ class SQLAnywhereException extends DBALException
*/ */
public static function fromSQLAnywhereError($conn = null, $stmt = null) public static function fromSQLAnywhereError($conn = null, $stmt = null)
{ {
if ($conn !== null && ! (is_resource($conn) && get_resource_type($conn) == 'SQLAnywhere connection')) { if (null !== $conn && ! (is_resource($conn) && get_resource_type($conn) === 'SQLAnywhere connection')) {
throw new \InvalidArgumentException('Invalid SQL Anywhere connection resource given: ' . $conn); throw new \InvalidArgumentException('Invalid SQL Anywhere connection resource given: ' . $conn);
} }
if ($stmt !== null && ! (is_resource($stmt) && get_resource_type($stmt) == 'SQLAnywhere statement')) { if (null !== $stmt && ! (is_resource($stmt) && get_resource_type($stmt) === 'SQLAnywhere statement')) {
throw new \InvalidArgumentException('Invalid SQL Anywhere statement resource given: ' . $stmt); throw new \InvalidArgumentException('Invalid SQL Anywhere statement resource given: ' . $stmt);
} }
$state = $conn ? sasql_sqlstate($conn) : sasql_sqlstate(); $state = $conn ? sasql_sqlstate($conn) : sasql_sqlstate();
$code = null; $code = null;
$message = null; $message = null;
...@@ -87,12 +86,10 @@ class SQLAnywhereException extends DBALException ...@@ -87,12 +86,10 @@ class SQLAnywhereException extends DBALException
} }
if ($message) { if ($message) {
$message = 'SQLSTATE [' . $state . '] [' . $code . '] ' . $message; return new self('SQLSTATE [' . $state . '] [' . $code . '] ' . $message, $code);
} else {
$message = 'SQL Anywhere error occurred but no error message was retrieved from driver.';
} }
return new self($message, $code); return new self('SQL Anywhere error occurred but no error message was retrieved from driver.', $code);
} }
} }
...@@ -36,22 +36,27 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement ...@@ -36,22 +36,27 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
* @var resource The connection resource. * @var resource The connection resource.
*/ */
private $conn; private $conn;
/** /**
* @var string Name of the default class to instantiate when fetch mode is \PDO::FETCH_CLASS. * @var string Name of the default class to instantiate when fetch mode is \PDO::FETCH_CLASS.
*/ */
private $defaultFetchClass = '\stdClass'; private $defaultFetchClass = '\stdClass';
/** /**
* @var string Constructor arguments for the default class to instantiate when fetch mode is \PDO::FETCH_CLASS. * @var string Constructor arguments for the default class to instantiate when fetch mode is \PDO::FETCH_CLASS.
*/ */
private $defaultFetchClassCtorArgs = array(); private $defaultFetchClassCtorArgs = array();
/** /**
* @var int Default fetch mode to use. * @var int Default fetch mode to use.
*/ */
private $defaultFetchMode = PDO::FETCH_BOTH; private $defaultFetchMode = PDO::FETCH_BOTH;
/** /**
* @var resource The result set resource to fetch. * @var resource The result set resource to fetch.
*/ */
private $result; private $result;
/** /**
* @var resource The prepared SQL statement to execute. * @var resource The prepared SQL statement to execute.
*/ */
...@@ -69,14 +74,14 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement ...@@ -69,14 +74,14 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
*/ */
public function __construct($conn, $sql) public function __construct($conn, $sql)
{ {
if ( ! is_resource($conn) || get_resource_type($conn) != 'SQLAnywhere connection') { if ( ! is_resource($conn) || get_resource_type($conn) !== 'SQLAnywhere connection') {
throw new SQLAnywhereException('Invalid SQL Anywhere connection resource: ' . $conn); throw new SQLAnywhereException('Invalid SQL Anywhere connection resource: ' . $conn);
} }
$this->conn = $conn; $this->conn = $conn;
$this->stmt = sasql_prepare($conn, $sql); $this->stmt = sasql_prepare($conn, $sql);
if ( ! is_resource($this->stmt) || get_resource_type($this->stmt) != 'SQLAnywhere statement') { if ( ! is_resource($this->stmt) || get_resource_type($this->stmt) !== 'SQLAnywhere statement') {
throw SQLAnywhereException::fromSQLAnywhereError($conn); throw SQLAnywhereException::fromSQLAnywhereError($conn);
} }
} }
...@@ -164,10 +169,12 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement ...@@ -164,10 +169,12 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
*/ */
public function execute($params = null) public function execute($params = null)
{ {
if ($params) { if (is_array($params)) {
$hasZeroIndex = array_key_exists(0, $params); $hasZeroIndex = array_key_exists(0, $params);
foreach ($params as $key => $val) { foreach ($params as $key => $val) {
$key = ($hasZeroIndex && is_numeric($key)) ? $key + 1 : $key; $key = ($hasZeroIndex && is_numeric($key)) ? $key + 1 : $key;
$this->bindValue($key, $val); $this->bindValue($key, $val);
} }
} }
...@@ -188,7 +195,7 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement ...@@ -188,7 +195,7 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
*/ */
public function fetch($fetchMode = null) public function fetch($fetchMode = null)
{ {
if ( ! is_resource($this->result) || get_resource_type($this->result) != 'SQLAnywhere result') { if ( ! is_resource($this->result) || get_resource_type($this->result) !== 'SQLAnywhere result') {
return false; return false;
} }
...@@ -321,11 +328,13 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement ...@@ -321,11 +328,13 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
foreach ($sourceReflection->getProperties() as $sourceProperty) { foreach ($sourceReflection->getProperties() as $sourceProperty) {
$sourceProperty->setAccessible(true); $sourceProperty->setAccessible(true);
$name = $sourceProperty->getName(); $name = $sourceProperty->getName();
$value = $sourceProperty->getValue($sourceObject); $value = $sourceProperty->getValue($sourceObject);
if ($destinationClassReflection->hasProperty($name)) { if ($destinationClassReflection->hasProperty($name)) {
$destinationProperty = $destinationClassReflection->getProperty($name); $destinationProperty = $destinationClassReflection->getProperty($name);
$destinationProperty->setAccessible(true); $destinationProperty->setAccessible(true);
$destinationProperty->setValue($destinationClass, $value); $destinationProperty->setValue($destinationClass, $value);
} else { } else {
...@@ -336,4 +345,3 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement ...@@ -336,4 +345,3 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
return $destinationClass; return $destinationClass;
} }
} }
...@@ -49,7 +49,7 @@ final class DriverManager ...@@ -49,7 +49,7 @@ final class DriverManager
'mysqli' => 'Doctrine\DBAL\Driver\Mysqli\Driver', 'mysqli' => 'Doctrine\DBAL\Driver\Mysqli\Driver',
'drizzle_pdo_mysql' => 'Doctrine\DBAL\Driver\DrizzlePDOMySql\Driver', 'drizzle_pdo_mysql' => 'Doctrine\DBAL\Driver\DrizzlePDOMySql\Driver',
'sqlanywhere' => 'Doctrine\DBAL\Driver\SQLAnywhere\Driver', 'sqlanywhere' => 'Doctrine\DBAL\Driver\SQLAnywhere\Driver',
'sqlsrv' => 'Doctrine\DBAL\Driver\SQLSrv\Driver' 'sqlsrv' => 'Doctrine\DBAL\Driver\SQLSrv\Driver',
); );
/** /**
......
...@@ -41,9 +41,15 @@ class SQLAnywhere11Keywords extends SQLAnywhereKeywords ...@@ -41,9 +41,15 @@ class SQLAnywhere11Keywords extends SQLAnywhereKeywords
*/ */
protected function getKeywords() protected function getKeywords()
{ {
return array_merge(array_diff(parent::getKeywords(), array('IQ')), array( return array_merge(
array_diff(
parent::getKeywords(),
array('IQ')
),
array(
'MERGE', 'MERGE',
'OPENSTRING' 'OPENSTRING'
)); )
);
} }
} }
...@@ -41,18 +41,24 @@ class SQLAnywhere12Keywords extends SQLAnywhere11Keywords ...@@ -41,18 +41,24 @@ class SQLAnywhere12Keywords extends SQLAnywhere11Keywords
*/ */
protected function getKeywords() protected function getKeywords()
{ {
return array_merge(array_diff(parent::getKeywords(), array( return array_merge(
array_diff(
parent::getKeywords(),
array(
'INDEX_LPAREN', 'INDEX_LPAREN',
'SYNTAX_ERROR', 'SYNTAX_ERROR',
'WITH_CUBE', 'WITH_CUBE',
'WITH_LPAREN', 'WITH_LPAREN',
'WITH_ROLLUP' 'WITH_ROLLUP'
)), array( )
),
array(
'DATETIMEOFFSET', 'DATETIMEOFFSET',
'LIMIT', 'LIMIT',
'OPENXML', 'OPENXML',
'SPATIAL', 'SPATIAL',
'TREAT' 'TREAT'
)); )
);
} }
} }
...@@ -41,13 +41,16 @@ class SQLAnywhere16Keywords extends SQLAnywhere12Keywords ...@@ -41,13 +41,16 @@ class SQLAnywhere16Keywords extends SQLAnywhere12Keywords
*/ */
protected function getKeywords() protected function getKeywords()
{ {
return array_merge(parent::getKeywords(), array( return array_merge(
parent::getKeywords(),
array(
'ARRAY', 'ARRAY',
'JSON', 'JSON',
'ROW', 'ROW',
'ROWTYPE', 'ROWTYPE',
'UNNEST', 'UNNEST',
'VARRAY' 'VARRAY'
)); )
);
} }
} }
...@@ -77,8 +77,6 @@ class SQLAnywhere12Platform extends SQLAnywhere11Platform ...@@ -77,8 +77,6 @@ class SQLAnywhere12Platform extends SQLAnywhere11Platform
$sequence = $sequence->getQuotedName($this); $sequence = $sequence->getQuotedName($this);
} }
/** @var string $sequence */
return 'DROP SEQUENCE ' . $sequence; return 'DROP SEQUENCE ' . $sequence;
} }
...@@ -111,13 +109,11 @@ class SQLAnywhere12Platform extends SQLAnywhere11Platform ...@@ -111,13 +109,11 @@ class SQLAnywhere12Platform extends SQLAnywhere11Platform
*/ */
protected function getAdvancedIndexOptionsSQL(Index $index) protected function getAdvancedIndexOptionsSQL(Index $index)
{ {
$sql = '';
if (!$index->isPrimary() && $index->isUnique() && $index->hasFlag('with_nulls_not_distinct')) { if (!$index->isPrimary() && $index->isUnique() && $index->hasFlag('with_nulls_not_distinct')) {
$sql .= ' WITH NULLS NOT DISTINCT'; return ' WITH NULLS NOT DISTINCT' . parent::getAdvancedIndexOptionsSQL($index);
} }
return $sql . parent::getAdvancedIndexOptionsSQL($index); return parent::getAdvancedIndexOptionsSQL($index);
} }
/** /**
......
...@@ -43,13 +43,11 @@ class SQLAnywhere16Platform extends SQLAnywhere12Platform ...@@ -43,13 +43,11 @@ class SQLAnywhere16Platform extends SQLAnywhere12Platform
); );
} }
$sql = '';
if (!$index->isPrimary() && $index->isUnique() && $index->hasFlag('with_nulls_distinct')) { if (!$index->isPrimary() && $index->isUnique() && $index->hasFlag('with_nulls_distinct')) {
$sql .= ' WITH NULLS DISTINCT'; return ' WITH NULLS DISTINCT' . parent::getAdvancedIndexOptionsSQL($index);
} }
return $sql . parent::getAdvancedIndexOptionsSQL($index); return parent::getAdvancedIndexOptionsSQL($index);
} }
/** /**
......
...@@ -262,7 +262,7 @@ class SQLAnywherePlatform extends AbstractPlatform ...@@ -262,7 +262,7 @@ class SQLAnywherePlatform extends AbstractPlatform
*/ */
public function getConcatExpression() public function getConcatExpression()
{ {
return 'STRING(' . join(', ', (array) func_get_args()) . ')'; return 'STRING(' . implode(', ', (array) func_get_args()) . ')';
} }
/** /**
...@@ -278,25 +278,24 @@ class SQLAnywherePlatform extends AbstractPlatform ...@@ -278,25 +278,24 @@ class SQLAnywherePlatform extends AbstractPlatform
$table = $table->getQuotedName($this); $table = $table->getQuotedName($this);
} }
/** @var string $table */
$query = 'ALTER TABLE ' . $table . ' ADD '; $query = 'ALTER TABLE ' . $table . ' ADD ';
if ($constraint instanceof Index) { if ($constraint instanceof Index) {
if ($constraint->isPrimary()) { if ($constraint->isPrimary()) {
$query .= $this->getPrimaryKeyDeclarationSQL($constraint, $constraint->getQuotedName($this)); return $query . $this->getPrimaryKeyDeclarationSQL($constraint, $constraint->getQuotedName($this));
} elseif ($constraint->isUnique()) { }
$query .= $this->getUniqueConstraintDeclarationSQL($constraint->getQuotedName($this), $constraint);
} else { if ($constraint->isUnique()) {
return $query .
$this->getUniqueConstraintDeclarationSQL($constraint->getQuotedName($this), $constraint);
}
throw new \InvalidArgumentException( throw new \InvalidArgumentException(
'Can only create primary or unique constraints, no common indexes with getCreateConstraintSQL().' 'Can only create primary or unique constraints, no common indexes with getCreateConstraintSQL().'
); );
} }
} else {
throw new \InvalidArgumentException('Unsupported constraint type: ' . get_class($constraint));
}
return $query; throw new \InvalidArgumentException('Unsupported constraint type: ' . get_class($constraint));
} }
/** /**
...@@ -326,8 +325,6 @@ class SQLAnywherePlatform extends AbstractPlatform ...@@ -326,8 +325,6 @@ class SQLAnywherePlatform extends AbstractPlatform
$table = $table->getQuotedName($this); $table = $table->getQuotedName($this);
} }
/** @var string $table */
return 'ALTER TABLE ' . $table . ' ADD ' . $this->getPrimaryKeyDeclarationSQL($index); return 'ALTER TABLE ' . $table . ' ADD ' . $this->getPrimaryKeyDeclarationSQL($index);
} }
...@@ -490,7 +487,9 @@ class SQLAnywherePlatform extends AbstractPlatform ...@@ -490,7 +487,9 @@ class SQLAnywherePlatform extends AbstractPlatform
{ {
if ($index instanceof Index) { if ($index instanceof Index) {
$index = $index->getQuotedName($this); $index = $index->getQuotedName($this);
} elseif ( ! is_string($index)) { }
if ( ! is_string($index)) {
throw new \InvalidArgumentException( throw new \InvalidArgumentException(
'SQLAnywherePlatform::getDropIndexSQL() expects $index parameter to be string or ' . 'SQLAnywherePlatform::getDropIndexSQL() expects $index parameter to be string or ' .
'\Doctrine\DBAL\Schema\Index.' '\Doctrine\DBAL\Schema\Index.'
...@@ -503,7 +502,9 @@ class SQLAnywherePlatform extends AbstractPlatform ...@@ -503,7 +502,9 @@ class SQLAnywherePlatform extends AbstractPlatform
if ($table instanceof Table) { if ($table instanceof Table) {
$table = $table->getQuotedName($this); $table = $table->getQuotedName($this);
} elseif ( ! is_string($table)) { }
if ( ! is_string($table)) {
throw new \InvalidArgumentException( throw new \InvalidArgumentException(
'SQLAnywherePlatform::getDropIndexSQL() expects $table parameter to be string or ' . 'SQLAnywherePlatform::getDropIndexSQL() expects $table parameter to be string or ' .
'\Doctrine\DBAL\Schema\Table.' '\Doctrine\DBAL\Schema\Table.'
...@@ -633,9 +634,7 @@ class SQLAnywherePlatform extends AbstractPlatform ...@@ -633,9 +634,7 @@ class SQLAnywherePlatform extends AbstractPlatform
*/ */
public function getIndexDeclarationSQL($name, Index $index) public function getIndexDeclarationSQL($name, Index $index)
{ {
/** // Index declaration in statements like CREATE TABLE is not supported.
* Index declaration in statements like CREATE TABLE is not supported
*/
throw DBALException::notSupported(__METHOD__); throw DBALException::notSupported(__METHOD__);
} }
...@@ -974,7 +973,7 @@ class SQLAnywherePlatform extends AbstractPlatform ...@@ -974,7 +973,7 @@ class SQLAnywherePlatform extends AbstractPlatform
*/ */
public function getSubstringExpression($value, $from, $length = null) public function getSubstringExpression($value, $from, $length = null)
{ {
if ($length === null) { if (null === $length) {
return 'SUBSTRING(' . $value . ', ' . $from . ')'; return 'SUBSTRING(' . $value . ', ' . $from . ')';
} }
...@@ -1231,11 +1230,12 @@ class SQLAnywherePlatform extends AbstractPlatform ...@@ -1231,11 +1230,12 @@ class SQLAnywherePlatform extends AbstractPlatform
if ($limit == 0) { if ($limit == 0) {
$limitOffsetClause = 'TOP ALL '; $limitOffsetClause = 'TOP ALL ';
} }
$limitOffsetClause .= 'START AT ' . ($offset + 1) . ' '; $limitOffsetClause .= 'START AT ' . ($offset + 1) . ' ';
} }
if ($limitOffsetClause) { if ($limitOffsetClause) {
$query = preg_replace('/^\s*(SELECT\s+(DISTINCT\s+)?)/i', '\1' . $limitOffsetClause, $query); return preg_replace('/^\s*(SELECT\s+(DISTINCT\s+)?)/i', '\1' . $limitOffsetClause, $query);
} }
return $query; return $query;
......
...@@ -110,9 +110,7 @@ class SQLAnywhereSchemaManager extends AbstractSchemaManager ...@@ -110,9 +110,7 @@ class SQLAnywhereSchemaManager extends AbstractSchemaManager
$default = null; $default = null;
if ($tableColumn['default']) { if ($tableColumn['default']) {
/** // Strip quotes from default value.
* Strip quotes from default value
*/
$default = preg_replace(array("/^'(.*)'$/", "/''/"), array("$1", "'"), $tableColumn['default']); $default = preg_replace(array("/^'(.*)'$/", "/''/"), array("$1", "'"), $tableColumn['default']);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment