Commit c338d4b7 by gevik

Updated code styling and added braces.

parent f667b578
......@@ -661,7 +661,7 @@ class Command extends \yii\base\Component
* @param string|array $columns comma separated string or array of columns that the primary key will consist of.
* @return Command the command object itself.
*/
public function addPrimaryKey($name,$table,$columns)
public function addPrimaryKey($name, $table, $columns)
{
$sql = $this->db->getQueryBuilder()->addPrimaryKey($name, $table, $columns);
return $this->setSql($sql);
......@@ -673,7 +673,7 @@ class Command extends \yii\base\Component
* @param string $table the table that the primary key constraint will be removed from.
* @return Command the command object itself
*/
public function dropPrimarykey($name,$table)
public function dropPrimarykey($name, $table)
{
$sql = $this->db->getQueryBuilder()->dropPrimarykey($name, $table);
return $this->setSql($sql);
......
......@@ -276,12 +276,16 @@ class QueryBuilder extends \yii\base\Object
* @param string|array $columns comma separated string or array of columns that the primary key will consist of.
* @return string the SQL statement for adding a primary key constraint to an existing table.
*/
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);
foreach($columns as $i=>$col)
}
foreach ($columns as $i=>$col) {
$columns[$i]=$this->db->quoteColumnName($col);
}
return 'ALTER TABLE ' . $this->db->quoteTableName($table) . ' ADD CONSTRAINT '
. $this->db->quoteColumnName($name) . ' PRIMARY KEY ('
. implode(', ', $columns). ' )';
......@@ -293,7 +297,7 @@ class QueryBuilder extends \yii\base\Object
* @param string $table the table that the primary key constraint will be removed from.
* @return string the SQL statement for removing a primary key constraint from an existing table. *
*/
public function dropPrimarykey($name,$table)
public function dropPrimarykey($name, $table)
{
return 'ALTER TABLE ' . $this->db->quoteTableName($table)
. ' DROP CONSTRAINT ' . $this->db->quoteColumnName($name);
......
......@@ -94,7 +94,7 @@ class QueryBuilder extends \yii\db\QueryBuilder
* @param string $table the table that the primary key constraint will be removed from.
* @return string the SQL statement for removing a primary key constraint from an existing table. *
*/
public function dropPrimarykey($name,$table)
public function dropPrimarykey($name, $table)
{
return 'ALTER TABLE ' . $this->db->quoteTableName($table) . ' DROP PRIMARY KEY';
}
......
......@@ -188,7 +188,7 @@ class QueryBuilder extends \yii\db\QueryBuilder
* @return string the SQL statement for adding a primary key constraint to an existing table.
* @throws NotSupportedException this is not supported by SQLite
*/
public function addPrimaryKey($name,$table,$columns)
public function addPrimaryKey($name, $table, $columns)
{
throw new NotSupportedException(__METHOD__ . ' is not supported by SQLite.');
}
......@@ -200,7 +200,7 @@ class QueryBuilder extends \yii\db\QueryBuilder
* @return string the SQL statement for removing a primary key constraint from an existing table.
* @throws NotSupportedException this is not supported by SQLite *
*/
public function dropPrimarykey($name,$table)
public function dropPrimarykey($name, $table)
{
throw new NotSupportedException(__METHOD__ . ' is not supported by SQLite.');
}
......
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