diff --git a/lib/Doctrine/Export/Mssql.php b/lib/Doctrine/Export/Mssql.php index b0afb73e0..9b014b098 100644 --- a/lib/Doctrine/Export/Mssql.php +++ b/lib/Doctrine/Export/Mssql.php @@ -20,7 +20,7 @@ */ Doctrine::autoload('Doctrine_Export'); /** - * Doctrine_Export_Oracle + * Doctrine_Export_Mssql * * @package Doctrine * @author Konsta Vesterinen @@ -60,7 +60,7 @@ class Doctrine_Export_Mssql extends Doctrine_Export public function dropDatabase($name) { $name = $this->conn->quoteIdentifier($name, true); - return $this->conn->standaloneQuery("DROP DATABASE $name", null, true); + return $this->conn->standaloneQuery('DROP DATABASE ' . $name, null, true); } /** * alter an existing table @@ -152,8 +152,8 @@ class Doctrine_Export_Mssql extends Doctrine_Export */ public function alterTable($name, $changes, $check) { - foreach ($changes as $change_name => $change) { - switch ($change_name) { + foreach ($changes as $changeName => $change) { + switch ($changeName) { case 'add': break; case 'remove': @@ -162,50 +162,50 @@ class Doctrine_Export_Mssql extends Doctrine_Export case 'rename': case 'change': default: - throw new Doctrine_Export_Exception('alterTable: change type "' . $change_name . '" not yet supported'); + throw new Doctrine_Export_Exception('alterTable: change type "' . $changeName . '" not yet supported'); } } $query = ''; - if (!empty($changes['add']) && is_array($changes['add'])) { - foreach ($changes['add'] as $field_name => $field) { + if ( ! empty($changes['add']) && is_array($changes['add'])) { + foreach ($changes['add'] as $fieldName => $field) { if ($query) { - $query.= ', '; + $query .= ', '; } - $query.= 'ADD ' . $this->conn->getDeclaration($field['type'], $field_name, $field); + $query .= 'ADD ' . $this->conn->getDeclaration($field['type'], $fieldName, $field); } } - if (!empty($changes['remove']) && is_array($changes['remove'])) { - foreach ($changes['remove'] as $field_name => $field) { + if ( ! empty($changes['remove']) && is_array($changes['remove'])) { + foreach ($changes['remove'] as $fieldName => $field) { if ($query) { - $query.= ', '; + $query .= ', '; } - $field_name = $this->conn->quoteIdentifier($field_name, true); - $query.= 'DROP COLUMN ' . $field_name; + $field_name = $this->conn->quoteIdentifier($fieldName, true); + $query .= 'DROP COLUMN ' . $fieldName; } } - if (!$query) { + if ( ! $query) { return false; } $name = $this->conn->quoteIdentifier($name, true); - return $this->conn->exec("ALTER TABLE $name $query"); + return $this->conn->exec('ALTER TABLE ' . $name . ' ' . $query); } /** * create sequence * - * @param string $seq_name name of the sequence to be created + * @param string $seqName name of the sequence to be created * @param string $start start value of the sequence; default is 1 * @return void */ - public function createSequence($seq_name, $start = 1) + public function createSequence($seqName, $start = 1) { - $sequence_name = $this->conn->quoteIdentifier($this->conn->getSequenceName($seq_name), true); - $seqcol_name = $this->conn->quoteIdentifier($this->conn->options['seqcol_name'], true); - $query = "CREATE TABLE $sequence_name ($seqcol_name " . - "INT PRIMARY KEY CLUSTERED IDENTITY($start,1) NOT NULL)"; + $sequenceName = $this->conn->quoteIdentifier($this->conn->getSequenceName($seqName), true); + $seqcolName = $this->conn->quoteIdentifier($this->conn->options['seqcol_name'], true); + $query = 'CREATE TABLE ' . $sequenceName . ' (' . $seqcolName . + ' INT PRIMARY KEY CLUSTERED IDENTITY(' . $start . ',1) NOT NULL)'; $res = $this->conn->exec($query); @@ -214,11 +214,11 @@ class Doctrine_Export_Mssql extends Doctrine_Export } try { - $query = 'SET IDENTITY_INSERT $sequence_name ON ' . - 'INSERT INTO $sequence_name (' . $seqcol_name . ') VALUES ( ' . $start . ')'; + $query = 'SET IDENTITY_INSERT ' . $sequenceName . ' ON ' . + 'INSERT INTO ' . $sequenceName . ' (' . $seqcolName . ') VALUES ( ' . $start . ')'; $res = $this->conn->exec($query); } catch (Exception $e) { - $result = $this->conn->exec("DROP TABLE $sequence_name"); + $result = $this->conn->exec('DROP TABLE ' . $sequenceName); } return true; }