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

fix CS

parent 0083774f
......@@ -131,4 +131,4 @@ class Driver implements \Doctrine\DBAL\Driver
{
return new SQLAnywhereSchemaManager($conn);
}
}
\ No newline at end of file
}
......@@ -33,7 +33,7 @@ class SQLAnywhereConnection implements Connection
/**
* @var resource The SQL Anywhere connection resource.
*/
private $conn;
private $connection;
/**
* Constructor.
......@@ -47,31 +47,25 @@ class SQLAnywhereConnection implements Connection
*/
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();
}
/**
* Disable PHP warnings on error
*/
if ( ! sasql_set_option($this->conn, 'verbose_errors', false)) {
throw SQLAnywhereException::fromSQLAnywhereError($this->conn);
// Disable PHP warnings on error.
if ( ! sasql_set_option($this->connection, 'verbose_errors', false)) {
throw SQLAnywhereException::fromSQLAnywhereError($this->connection);
}
/**
* Enable auto committing by default
*/
if ( ! sasql_set_option($this->conn, 'auto_commit', 'on')) {
throw SQLAnywhereException::fromSQLAnywhereError($this->conn);
// Enable auto committing by default.
if ( ! sasql_set_option($this->connection, 'auto_commit', 'on')) {
throw SQLAnywhereException::fromSQLAnywhereError($this->connection);
}
/**
* Enable exact, non-approximated row count retrieval
*/
if ( ! sasql_set_option($this->conn, 'row_counts', true)) {
throw SQLAnywhereException::fromSQLAnywhereError($this->conn);
// Enable exact, non-approximated row count retrieval.
if ( ! sasql_set_option($this->connection, 'row_counts', true)) {
throw SQLAnywhereException::fromSQLAnywhereError($this->connection);
}
}
......@@ -82,8 +76,8 @@ class SQLAnywhereConnection implements Connection
*/
public function beginTransaction()
{
if ( ! sasql_set_option($this->conn, 'auto_commit', 'off')) {
throw SQLAnywhereException::fromSQLAnywhereError($this->conn);
if ( ! sasql_set_option($this->connection, 'auto_commit', 'off')) {
throw SQLAnywhereException::fromSQLAnywhereError($this->connection);
}
return true;
......@@ -96,8 +90,8 @@ class SQLAnywhereConnection implements Connection
*/
public function commit()
{
if ( ! sasql_commit($this->conn)) {
throw SQLAnywhereException::fromSQLAnywhereError($this->conn);
if ( ! sasql_commit($this->connection)) {
throw SQLAnywhereException::fromSQLAnywhereError($this->connection);
}
$this->endTransaction();
......@@ -110,7 +104,7 @@ class SQLAnywhereConnection implements Connection
*/
public function errorCode()
{
return sasql_errorcode($this->conn);
return sasql_errorcode($this->connection);
}
/**
......@@ -118,7 +112,7 @@ class SQLAnywhereConnection implements Connection
*/
public function errorInfo()
{
return sasql_error($this->conn);
return sasql_error($this->connection);
}
/**
......@@ -127,6 +121,7 @@ class SQLAnywhereConnection implements Connection
public function exec($statement)
{
$stmt = $this->prepare($statement);
$stmt->execute();
return $stmt->rowCount();
......@@ -137,8 +132,8 @@ class SQLAnywhereConnection implements Connection
*/
public function lastInsertId($name = null)
{
if ($name === null) {
return sasql_insert_id($this->conn);
if (null === $name) {
return sasql_insert_id($this->connection);
}
return $this->query('SELECT ' . $name . '.CURRVAL')->fetchColumn();
......@@ -149,7 +144,7 @@ class SQLAnywhereConnection implements Connection
*/
public function prepare($prepareString)
{
return new SQLAnywhereStatement($this->conn, $prepareString);
return new SQLAnywhereStatement($this->connection, $prepareString);
}
/**
......@@ -159,6 +154,7 @@ class SQLAnywhereConnection implements Connection
{
$args = func_get_args();
$stmt = $this->prepare($args[0]);
$stmt->execute();
return $stmt;
......@@ -173,7 +169,7 @@ class SQLAnywhereConnection implements Connection
return $input;
}
return "'" . sasql_escape_string($this->conn, $input) . "'";
return "'" . sasql_escape_string($this->connection, $input) . "'";
}
/**
......@@ -183,8 +179,8 @@ class SQLAnywhereConnection implements Connection
*/
public function rollBack()
{
if ( ! sasql_rollback($this->conn)) {
throw SQLAnywhereException::fromSQLAnywhereError($this->conn);
if ( ! sasql_rollback($this->connection)) {
throw SQLAnywhereException::fromSQLAnywhereError($this->connection);
}
$this->endTransaction();
......@@ -201,10 +197,10 @@ class SQLAnywhereConnection implements Connection
*/
private function endTransaction()
{
if ( ! sasql_set_option($this->conn, 'auto_commit', 'on')) {
throw SQLAnywhereException::fromSQLAnywhereError($this->conn);
if ( ! sasql_set_option($this->connection, 'auto_commit', 'on')) {
throw SQLAnywhereException::fromSQLAnywhereError($this->connection);
}
return true;
}
}
\ No newline at end of file
}
......@@ -42,24 +42,23 @@ class SQLAnywhereException extends DBALException
*/
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);
}
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);
}
$state = $conn ? sasql_sqlstate($conn) : sasql_sqlstate();
$code = null;
$state = $conn ? sasql_sqlstate($conn) : sasql_sqlstate();
$code = null;
$message = null;
/**
* Try retrieving the last error from statement resource if given
*/
if ($stmt) {
$code = sasql_stmt_errno($stmt);
$code = sasql_stmt_errno($stmt);
$message = sasql_stmt_error($stmt);
}
......@@ -72,7 +71,7 @@ class SQLAnywhereException extends DBALException
* a prepared statement.
*/
if ($conn && ! $code) {
$code = sasql_errorcode($conn);
$code = sasql_errorcode($conn);
$message = sasql_error($conn);
}
......@@ -82,17 +81,15 @@ class SQLAnywhereException extends DBALException
* connection / statement resource.
*/
if ( ! $conn || ! $code) {
$code = sasql_errorcode();
$code = sasql_errorcode();
$message = sasql_error();
}
if ($message) {
$message = 'SQLSTATE [' . $state . '] [' . $code . '] ' . $message;
} else {
$message = 'SQL Anywhere error occurred but no error message was retrieved from driver.';
return new self('SQLSTATE [' . $state . '] [' . $code . '] ' . $message, $code);
}
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
* @var resource The connection resource.
*/
private $conn;
/**
* @var string Name of the default class to instantiate when fetch mode is \PDO::FETCH_CLASS.
*/
private $defaultFetchClass = '\stdClass';
/**
* @var string Constructor arguments for the default class to instantiate when fetch mode is \PDO::FETCH_CLASS.
*/
private $defaultFetchClassCtorArgs = array();
/**
* @var int Default fetch mode to use.
*/
private $defaultFetchMode = PDO::FETCH_BOTH;
/**
* @var resource The result set resource to fetch.
*/
private $result;
/**
* @var resource The prepared SQL statement to execute.
*/
......@@ -69,14 +74,14 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
*/
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);
}
$this->conn = $conn;
$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);
}
}
......@@ -164,10 +169,12 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
*/
public function execute($params = null)
{
if ($params) {
if (is_array($params)) {
$hasZeroIndex = array_key_exists(0, $params);
foreach ($params as $key => $val) {
$key = ($hasZeroIndex && is_numeric($key)) ? $key + 1 : $key;
$this->bindValue($key, $val);
}
}
......@@ -188,7 +195,7 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
*/
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;
}
......@@ -201,12 +208,12 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
return sasql_fetch_array($this->result, SASQL_BOTH);
case PDO::FETCH_CLASS:
$className = $this->defaultFetchClass;
$ctorArgs = $this->defaultFetchClassCtorArgs;
$ctorArgs = $this->defaultFetchClassCtorArgs;
if (func_num_args() >= 2) {
$args = func_get_args();
$args = func_get_args();
$className = $args[1];
$ctorArgs = isset($args[2]) ? $args[2] : array();
$ctorArgs = isset($args[2]) ? $args[2] : array();
}
$result = sasql_fetch_object($this->result);
......@@ -287,8 +294,8 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
*/
public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null)
{
$this->defaultFetchMode = $fetchMode;
$this->defaultFetchClass = $arg2 ? $arg2 : $this->defaultFetchClass;
$this->defaultFetchMode = $fetchMode;
$this->defaultFetchClass = $arg2 ? $arg2 : $this->defaultFetchClass;
$this->defaultFetchClassCtorArgs = $arg3 ? (array) $arg3 : $this->defaultFetchClassCtorArgs;
}
......@@ -316,16 +323,18 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
$destinationClass = $destinationClass->newInstanceArgs($ctorArgs);
}
$sourceReflection = new \ReflectionObject($sourceObject);
$sourceReflection = new \ReflectionObject($sourceObject);
$destinationClassReflection = new \ReflectionObject($destinationClass);
foreach ($sourceReflection->getProperties() as $sourceProperty) {
$sourceProperty->setAccessible(true);
$name = $sourceProperty->getName();
$name = $sourceProperty->getName();
$value = $sourceProperty->getValue($sourceObject);
if ($destinationClassReflection->hasProperty($name)) {
$destinationProperty = $destinationClassReflection->getProperty($name);
$destinationProperty->setAccessible(true);
$destinationProperty->setValue($destinationClass, $value);
} else {
......@@ -336,4 +345,3 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement
return $destinationClass;
}
}
......@@ -38,18 +38,18 @@ final class DriverManager
* @var array
*/
private static $_driverMap = array(
'pdo_mysql' => 'Doctrine\DBAL\Driver\PDOMySql\Driver',
'pdo_sqlite' => 'Doctrine\DBAL\Driver\PDOSqlite\Driver',
'pdo_pgsql' => 'Doctrine\DBAL\Driver\PDOPgSql\Driver',
'pdo_oci' => 'Doctrine\DBAL\Driver\PDOOracle\Driver',
'oci8' => 'Doctrine\DBAL\Driver\OCI8\Driver',
'ibm_db2' => 'Doctrine\DBAL\Driver\IBMDB2\DB2Driver',
'pdo_ibm' => 'Doctrine\DBAL\Driver\PDOIbm\Driver',
'pdo_sqlsrv' => 'Doctrine\DBAL\Driver\PDOSqlsrv\Driver',
'mysqli' => 'Doctrine\DBAL\Driver\Mysqli\Driver',
'pdo_mysql' => 'Doctrine\DBAL\Driver\PDOMySql\Driver',
'pdo_sqlite' => 'Doctrine\DBAL\Driver\PDOSqlite\Driver',
'pdo_pgsql' => 'Doctrine\DBAL\Driver\PDOPgSql\Driver',
'pdo_oci' => 'Doctrine\DBAL\Driver\PDOOracle\Driver',
'oci8' => 'Doctrine\DBAL\Driver\OCI8\Driver',
'ibm_db2' => 'Doctrine\DBAL\Driver\IBMDB2\DB2Driver',
'pdo_ibm' => 'Doctrine\DBAL\Driver\PDOIbm\Driver',
'pdo_sqlsrv' => 'Doctrine\DBAL\Driver\PDOSqlsrv\Driver',
'mysqli' => 'Doctrine\DBAL\Driver\Mysqli\Driver',
'drizzle_pdo_mysql' => 'Doctrine\DBAL\Driver\DrizzlePDOMySql\Driver',
'sqlanywhere' => 'Doctrine\DBAL\Driver\SQLAnywhere\Driver',
'sqlsrv' => 'Doctrine\DBAL\Driver\SQLSrv\Driver'
'sqlanywhere' => 'Doctrine\DBAL\Driver\SQLAnywhere\Driver',
'sqlsrv' => 'Doctrine\DBAL\Driver\SQLSrv\Driver',
);
/**
......
......@@ -41,9 +41,15 @@ class SQLAnywhere11Keywords extends SQLAnywhereKeywords
*/
protected function getKeywords()
{
return array_merge(array_diff(parent::getKeywords(), array('IQ')), array(
'MERGE',
'OPENSTRING'
));
return array_merge(
array_diff(
parent::getKeywords(),
array('IQ')
),
array(
'MERGE',
'OPENSTRING'
)
);
}
}
\ No newline at end of file
}
......@@ -41,18 +41,24 @@ class SQLAnywhere12Keywords extends SQLAnywhere11Keywords
*/
protected function getKeywords()
{
return array_merge(array_diff(parent::getKeywords(), array(
'INDEX_LPAREN',
'SYNTAX_ERROR',
'WITH_CUBE',
'WITH_LPAREN',
'WITH_ROLLUP'
)), array(
'DATETIMEOFFSET',
'LIMIT',
'OPENXML',
'SPATIAL',
'TREAT'
));
return array_merge(
array_diff(
parent::getKeywords(),
array(
'INDEX_LPAREN',
'SYNTAX_ERROR',
'WITH_CUBE',
'WITH_LPAREN',
'WITH_ROLLUP'
)
),
array(
'DATETIMEOFFSET',
'LIMIT',
'OPENXML',
'SPATIAL',
'TREAT'
)
);
}
}
\ No newline at end of file
}
......@@ -41,13 +41,16 @@ class SQLAnywhere16Keywords extends SQLAnywhere12Keywords
*/
protected function getKeywords()
{
return array_merge(parent::getKeywords(), array(
'ARRAY',
'JSON',
'ROW',
'ROWTYPE',
'UNNEST',
'VARRAY'
));
return array_merge(
parent::getKeywords(),
array(
'ARRAY',
'JSON',
'ROW',
'ROWTYPE',
'UNNEST',
'VARRAY'
)
);
}
}
\ No newline at end of file
}
......@@ -278,4 +278,4 @@ class SQLAnywhereKeywords extends KeywordList
'XML'
);
}
}
\ No newline at end of file
}
......@@ -77,8 +77,6 @@ class SQLAnywhere12Platform extends SQLAnywhere11Platform
$sequence = $sequence->getQuotedName($this);
}
/** @var string $sequence */
return 'DROP SEQUENCE ' . $sequence;
}
......@@ -111,13 +109,11 @@ class SQLAnywhere12Platform extends SQLAnywhere11Platform
*/
protected function getAdvancedIndexOptionsSQL(Index $index)
{
$sql = '';
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
);
}
$sql = '';
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);
}
/**
......
......@@ -129,11 +129,11 @@ class SQLAnywherePlatform extends AbstractPlatform
*/
public function getAlterTableSQL(TableDiff $diff)
{
$sql = array();
$columnSql = array();
$sql = array();
$columnSql = array();
$commentsSQL = array();
$tableSql = array();
$queryParts = array();
$tableSql = array();
$queryParts = array();
/** @var \Doctrine\DBAL\Schema\Column $column */
foreach ($diff->addedColumns as $column) {
......@@ -262,7 +262,7 @@ class SQLAnywherePlatform extends AbstractPlatform
*/
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
$table = $table->getQuotedName($this);
}
/** @var string $table */
$query = 'ALTER TABLE ' . $table . ' ADD ';
if ($constraint instanceof Index) {
if ($constraint->isPrimary()) {
$query .= $this->getPrimaryKeyDeclarationSQL($constraint, $constraint->getQuotedName($this));
} elseif ($constraint->isUnique()) {
$query .= $this->getUniqueConstraintDeclarationSQL($constraint->getQuotedName($this), $constraint);
} else {
throw new \InvalidArgumentException(
'Can only create primary or unique constraints, no common indexes with getCreateConstraintSQL().'
);
return $query . $this->getPrimaryKeyDeclarationSQL($constraint, $constraint->getQuotedName($this));
}
} else {
throw new \InvalidArgumentException('Unsupported constraint type: ' . get_class($constraint));
if ($constraint->isUnique()) {
return $query .
$this->getUniqueConstraintDeclarationSQL($constraint->getQuotedName($this), $constraint);
}
throw new \InvalidArgumentException(
'Can only create primary or unique constraints, no common indexes with getCreateConstraintSQL().'
);
}
return $query;
throw new \InvalidArgumentException('Unsupported constraint type: ' . get_class($constraint));
}
/**
......@@ -326,8 +325,6 @@ class SQLAnywherePlatform extends AbstractPlatform
$table = $table->getQuotedName($this);
}
/** @var string $table */
return 'ALTER TABLE ' . $table . ' ADD ' . $this->getPrimaryKeyDeclarationSQL($index);
}
......@@ -490,7 +487,9 @@ class SQLAnywherePlatform extends AbstractPlatform
{
if ($index instanceof Index) {
$index = $index->getQuotedName($this);
} elseif ( ! is_string($index)) {
}
if ( ! is_string($index)) {
throw new \InvalidArgumentException(
'SQLAnywherePlatform::getDropIndexSQL() expects $index parameter to be string or ' .
'\Doctrine\DBAL\Schema\Index.'
......@@ -503,7 +502,9 @@ class SQLAnywherePlatform extends AbstractPlatform
if ($table instanceof Table) {
$table = $table->getQuotedName($this);
} elseif ( ! is_string($table)) {
}
if ( ! is_string($table)) {
throw new \InvalidArgumentException(
'SQLAnywherePlatform::getDropIndexSQL() expects $table parameter to be string or ' .
'\Doctrine\DBAL\Schema\Table.'
......@@ -526,10 +527,10 @@ class SQLAnywherePlatform extends AbstractPlatform
*/
public function getForeignKeyBaseDeclarationSQL(ForeignKeyConstraint $foreignKey)
{
$sql = '';
$foreignKeyName = $foreignKey->getName();
$localColumns = $foreignKey->getQuotedLocalColumns($this);
$foreignColumns = $foreignKey->getQuotedForeignColumns($this);
$sql = '';
$foreignKeyName = $foreignKey->getName();
$localColumns = $foreignKey->getQuotedLocalColumns($this);
$foreignColumns = $foreignKey->getQuotedForeignColumns($this);
$foreignTableName = $foreignKey->getQuotedForeignTableName($this);
if ( ! empty($foreignKeyName)) {
......@@ -633,9 +634,7 @@ class SQLAnywherePlatform extends AbstractPlatform
*/
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__);
}
......@@ -902,7 +901,7 @@ class SQLAnywherePlatform extends AbstractPlatform
throw new \InvalidArgumentException("Incomplete definition. 'columns' required.");
}
$sql = '';
$sql = '';
$flags = '';
if ( ! empty($name)) {
......@@ -974,7 +973,7 @@ class SQLAnywherePlatform extends AbstractPlatform
*/
public function getSubstringExpression($value, $from, $length = null)
{
if ($length === null) {
if (null === $length) {
return 'SUBSTRING(' . $value . ', ' . $from . ')';
}
......@@ -1054,7 +1053,7 @@ class SQLAnywherePlatform extends AbstractPlatform
throw new \InvalidArgumentException("Incomplete definition. 'columns' required.");
}
$sql = '';
$sql = '';
$flags = '';
if ( ! empty($name)) {
......@@ -1138,7 +1137,7 @@ class SQLAnywherePlatform extends AbstractPlatform
*/
protected function _getCommonIntegerTypeDeclarationSQL(array $columnDef)
{
$unsigned = ! empty($columnDef['unsigned']) ? 'UNSIGNED ' : '';
$unsigned = ! empty($columnDef['unsigned']) ? 'UNSIGNED ' : '';
$autoincrement = ! empty($columnDef['autoincrement']) ? ' IDENTITY' : '';
return $unsigned . $columnDef['integer_type'] . $autoincrement;
......@@ -1231,11 +1230,12 @@ class SQLAnywherePlatform extends AbstractPlatform
if ($limit == 0) {
$limitOffsetClause = 'TOP ALL ';
}
$limitOffsetClause .= 'START AT ' . ($offset + 1) . ' ';
}
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;
......
......@@ -101,18 +101,16 @@ class SQLAnywhereSchemaManager extends AbstractSchemaManager
*/
protected function _getPortableTableColumnDefinition($tableColumn)
{
$type = $this->_platform->getDoctrineTypeMapping($tableColumn['type']);
$type = $this->extractDoctrineTypeFromComment($tableColumn['comment'], $type);
$type = $this->_platform->getDoctrineTypeMapping($tableColumn['type']);
$type = $this->extractDoctrineTypeFromComment($tableColumn['comment'], $type);
$tableColumn['comment'] = $this->removeDoctrineTypeFromComment($tableColumn['comment'], $type);
$precision = null;
$scale = null;
$fixed = false;
$default = null;
$precision = null;
$scale = null;
$fixed = false;
$default = null;
if ($tableColumn['default']) {
/**
* Strip quotes from default value
*/
// Strip quotes from default value.
$default = preg_replace(array("/^'(.*)'$/", "/''/"), array("$1", "'"), $tableColumn['default']);
}
......@@ -134,15 +132,15 @@ class SQLAnywhereSchemaManager extends AbstractSchemaManager
$tableColumn['column_name'],
Type::getType($type),
array(
'length' => $type == 'string' ? $tableColumn['length'] : null,
'precision' => $precision,
'scale' => $scale,
'unsigned' => (bool) $tableColumn['unsigned'],
'fixed' => $fixed,
'notnull' => (bool) $tableColumn['notnull'],
'default' => $default,
'length' => $type == 'string' ? $tableColumn['length'] : null,
'precision' => $precision,
'scale' => $scale,
'unsigned' => (bool) $tableColumn['unsigned'],
'fixed' => $fixed,
'notnull' => (bool) $tableColumn['notnull'],
'default' => $default,
'autoincrement' => (bool) $tableColumn['autoincrement'],
'comment' => $tableColumn['comment']
'comment' => $tableColumn['comment']
));
}
......@@ -178,17 +176,17 @@ class SQLAnywhereSchemaManager extends AbstractSchemaManager
foreach ($tableForeignKeys as $tableForeignKey) {
if (!isset($foreignKeys[$tableForeignKey['index_name']])) {
$foreignKeys[$tableForeignKey['index_name']] = array(
'local_columns' => array($tableForeignKey['local_column']),
'foreign_table' => $tableForeignKey['foreign_table'],
'local_columns' => array($tableForeignKey['local_column']),
'foreign_table' => $tableForeignKey['foreign_table'],
'foreign_columns' => array($tableForeignKey['foreign_column']),
'name' => $tableForeignKey['index_name'],
'options' => array(
'notnull' => $tableForeignKey['notnull'],
'match' => $tableForeignKey['match'],
'onUpdate' => $tableForeignKey['on_update'],
'onDelete' => $tableForeignKey['on_delete'],
'check_on_commit' => $tableForeignKey['check_on_commit'],
'clustered' => $tableForeignKey['clustered'],
'name' => $tableForeignKey['index_name'],
'options' => array(
'notnull' => $tableForeignKey['notnull'],
'match' => $tableForeignKey['match'],
'onUpdate' => $tableForeignKey['on_update'],
'onDelete' => $tableForeignKey['on_delete'],
'check_on_commit' => $tableForeignKey['check_on_commit'],
'clustered' => $tableForeignKey['clustered'],
'for_olap_workload' => $tableForeignKey['for_olap_workload']
)
);
......
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