PHP Classes

File: src/query/BatchSeparatelyNamedInsertQuery.php

Recommend this page to a friend!
  Classes of Vitaly   Queasy DB   src/query/BatchSeparatelyNamedInsertQuery.php   Download  
File: src/query/BatchSeparatelyNamedInsertQuery.php
Role: Class source
Content type: text/plain
Description: Class source
Class: Queasy DB
Execute queries by accessing class variables
Author: By
Last change:
Date: 3 years ago
Size: 798 bytes
 

Contents

Class file image Download
<?php

namespace queasy\db\query;

class
BatchSeparatelyNamedInsertQuery extends BatchNamedInsertQuery
{
   
/**
     * Execute INSERT query with column names array as the first $params item and rows as the second.
     *
     * @param array $params Query parameters (1st item is array with column names and 2nd is array of arrays)
     *
     * @return int Number of inserted records
     *
     * @throws DbException On error
     */
   
public function run(array $params = array(), array $options = array())
    {
       
$keys = array_shift($params);
       
$rows = array_shift($params);

       
$paramsPrepared = array();
        foreach (
$rows as $row) {
           
$paramsPrepared[] = array_combine($keys, $row);
        }

        return
parent::run($paramsPrepared, $options);
    }
}