@ -119,25 +119,28 @@ class QueryBuilder extends \yii\db\QueryBuilder
/**
* Builds a SQL statement for renaming a DB table.
* @param string $tabl e the table to be renamed. The name will be properly quoted by the method.
* @param string $oldNam e the table to be renamed. The name will be properly quoted by the method.
* @param string $newName the new table name. The name will be properly quoted by the method.
* @return string the SQL statement for renaming a DB table.
*/
public function renameTable($tabl e, $newName)
public function renameTable($oldNam e, $newName)
{
return "sp_rename '$table', '$newName'" ;
return 'sp_rename ' . $this->db->quoteTableName($oldName) . ', ' . $this->db->quoteTableName($newName) ;
}
/**
* Builds a SQL statement for renaming a column.
* @param string $table the table whose column is to be renamed. The name will be properly quoted by the method.
* @param string $n ame the old name of the column. The name will be properly quoted by the method.
* @param string $oldN ame the old name of the column. The name will be properly quoted by the method.
* @param string $newName the new name of the column. The name will be properly quoted by the method.
* @return string the SQL statement for renaming a DB column.
*/
public function renameColumn($table, $n ame, $newName)
public function renameColumn($table, $oldN ame, $newName)
{
return "sp_rename '$table.$name', '$newName', 'COLUMN'";
$table = $this->db->quoteTableName($table);
$oldName = $this->db->quoteColumnName($oldName);
$newName = $this->db->quoteColumnName($newName);
return "sp_rename '{$table}.{$oldName}', {$newName}, 'COLUMN'";
}
/**