emultiplesql insert,update or delete multiple rows in one sql query

  1. Requirements
  2. Usage

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();

1 0
8 followers
287 downloads
Yii Version: Unknown
License: BSD-2-Clause
Category: Database
Created on: Oct 11, 2013
Last updated: 10 years ago

Downloads

show all

Related Extensions