Commit cc0fe1b0 by Alexander Makarov

code style fixes

parent 17b1e5d2
...@@ -318,7 +318,7 @@ class Migration extends \yii\base\Component ...@@ -318,7 +318,7 @@ class Migration extends \yii\base\Component
*/ */
public function addPrimaryKey($name, $table, $columns) public function addPrimaryKey($name, $table, $columns)
{ {
echo " > add primary key $name on $table (".(is_array($columns) ? implode(',',$columns) : $columns).") ..."; echo " > add primary key $name on $table (".(is_array($columns) ? implode(',', $columns) : $columns).") ...";
$time = microtime(true); $time = microtime(true);
$this->db->createCommand()->addPrimaryKey($name, $table, $columns)->execute(); $this->db->createCommand()->addPrimaryKey($name, $table, $columns)->execute();
echo " done (time: " . sprintf('%.3f', microtime(true) - $time) . "s)\n"; echo " done (time: " . sprintf('%.3f', microtime(true) - $time) . "s)\n";
......
...@@ -279,17 +279,17 @@ class QueryBuilder extends \yii\base\Object ...@@ -279,17 +279,17 @@ class QueryBuilder extends \yii\base\Object
public function addPrimaryKey($name, $table, $columns) public function addPrimaryKey($name, $table, $columns)
{ {
if (is_string($columns)) { if (is_string($columns)) {
$columns=preg_split('/\s*,\s*/',$columns,-1,PREG_SPLIT_NO_EMPTY); $columns = preg_split('/\s*,\s*/', $columns, -1, PREG_SPLIT_NO_EMPTY);
} }
foreach ($columns as $i=>$col) { foreach ($columns as $i => $col) {
$columns[$i]=$this->db->quoteColumnName($col); $columns[$i] = $this->db->quoteColumnName($col);
} }
return 'ALTER TABLE ' . $this->db->quoteTableName($table) . ' ADD CONSTRAINT ' return 'ALTER TABLE ' . $this->db->quoteTableName($table) . ' ADD CONSTRAINT '
. $this->db->quoteColumnName($name) . ' PRIMARY KEY (' . $this->db->quoteColumnName($name) . ' PRIMARY KEY ('
. implode(', ', $columns). ' )'; . implode(', ', $columns). ' )';
} }
/** /**
* Builds a SQL statement for removing a primary key constraint to an existing table. * Builds a SQL statement for removing a primary key constraint to an existing table.
...@@ -301,8 +301,7 @@ class QueryBuilder extends \yii\base\Object ...@@ -301,8 +301,7 @@ class QueryBuilder extends \yii\base\Object
{ {
return 'ALTER TABLE ' . $this->db->quoteTableName($table) return 'ALTER TABLE ' . $this->db->quoteTableName($table)
. ' DROP CONSTRAINT ' . $this->db->quoteColumnName($name); . ' DROP CONSTRAINT ' . $this->db->quoteColumnName($name);
}
}
/** /**
* Builds a SQL statement for truncating a DB table. * Builds a SQL statement for truncating a DB table.
......
...@@ -191,8 +191,8 @@ class QueryBuilder extends \yii\db\QueryBuilder ...@@ -191,8 +191,8 @@ class QueryBuilder extends \yii\db\QueryBuilder
public function addPrimaryKey($name, $table, $columns) public function addPrimaryKey($name, $table, $columns)
{ {
throw new NotSupportedException(__METHOD__ . ' is not supported by SQLite.'); throw new NotSupportedException(__METHOD__ . ' is not supported by SQLite.');
} }
/** /**
* Builds a SQL statement for removing a primary key constraint to an existing table. * Builds a SQL statement for removing a primary key constraint to an existing table.
* @param string $name the name of the primary key constraint to be removed. * @param string $name the name of the primary key constraint to be removed.
...@@ -202,7 +202,6 @@ class QueryBuilder extends \yii\db\QueryBuilder ...@@ -202,7 +202,6 @@ class QueryBuilder extends \yii\db\QueryBuilder
*/ */
public function dropPrimaryKey($name, $table) public function dropPrimaryKey($name, $table)
{ {
throw new NotSupportedException(__METHOD__ . ' is not supported by SQLite.'); throw new NotSupportedException(__METHOD__ . ' is not supported by SQLite.');
} }
} }
...@@ -356,8 +356,7 @@ class PhpManager extends Manager ...@@ -356,8 +356,7 @@ class PhpManager extends Manager
*/ */
public function saveItem($item, $oldName = null) public function saveItem($item, $oldName = null)
{ {
if ($oldName !== null && ($newName = $item->getName()) !== $oldName) // name changed if ($oldName !== null && ($newName = $item->getName()) !== $oldName) { // name changed
{
if (isset($this->_items[$newName])) { if (isset($this->_items[$newName])) {
throw new InvalidParamException("Unable to change the item name. The name '$newName' is already used by another item."); throw new InvalidParamException("Unable to change the item name. The name '$newName' is already used by another item.");
} }
......
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