with this extension you can insert,update or delete multiple rows of your tables just in one sql query.
In this way you can make insertions,updates or deletes records into the tables with best performance and secure using sql statement
Requirements ¶
No requirements but this extension includes CDbCommandBuilder.php core file of Yii version 1.1.14. if you use this version or above just remove CDbCommandBuilder.php from the EmultipleSql folder.
Usage ¶
Extract archive in your extensions folder
for multiple inserts check this
Yii::import('ext.EmultipleSql.CDBMultipleCommandBuilder');
$multipleBuilder = new CDBMultipleCommandBuilder(Yii::app()->db->schema);
//massive updates
$data = array(
array('field1' => 'value1', 'field2' => 'value1', 'field3' => 'value1'), //when column_condition = val1
array('field1' => 'value4', 'field5' => 'value2', 'field3' => 'value6'), //when column_condition = val2
array('field1' => 'value7', 'field2' => 'value8', 'field3' => 'value9'), //when column_condition = val3
);
public $keys = array(
'column_codition'
array('val1','val2','val3'), //the count of items is as the count array items of the data
);
$command = $this->multipleBuilder->createMultipleUpdateCommand('your_table_name', $data, $keys);
$result = $command->execute();
// massive deletes
$command = $multipleBuilder->createMultipleDeleteCommand('your_table_name', 'the_condition_column', array('value1', 'value2', 'value3'));
$result = $command->execute();
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.