|
|
@ -278,10 +278,14 @@ 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). ' )'; |
|
|
|