protected function public__insertMultiple($table_name, array $data_to_insert)
    {
        $pdo = $this->getPDOInstance();
        $fieldNames = \implode('`, `', \array_values($data_to_insert['field_names']));
        $sqlQuery = "INSERT INTO " . $this->quoteTableName($this->getPrefixedTableName($table_name)) . " (`$fieldNames`) VALUES ";

        $i = 0;
        $fieldValues = '';
        foreach ($data_to_insert['values'] as $rec_value)
        {
            $fieldValues .= '(';
            foreach ($rec_value as $value)
            {
                $fieldValues .= ":v$i,";
                $i++;
            }
            $fieldValues .= \rtrim($fieldValues, ',') . '),';
        }
        $sqlQuery .= \rtrim($fieldValues, ',') . ";";
        $sth = $pdo->prepare($sqlQuery);

        $i = 0;
        foreach ($data_to_insert['values'] as $rec_value)
        {
            foreach ($rec_value as $value)
            {
                $sth->bindValue(':v' . $i++, $value, $this->getPdoType(\gettype($value)));
            }
        }

        try
        {
            $pdo->beginTransaction();
            $sth->execute();
            $pdo->commit();
        }
        catch (Exception $exc)
        {
            $pdo->rollback();
            return FALSE;
        }

        return TRUE;
    }
protected function public__insertMultiple($table_name, array $data_to_insert)
    {
        $pdo = $this->getPDOInstance();
        $fieldNames = \implode('`, `', \array_values($data_to_insert['field_names']));
        $sqlQuery = "INSERT INTO " . $this->quoteTableName($this->getPrefixedTableName($table_name)) . " (`$fieldNames`) VALUES ";

        $i = 0;
        $fieldValues = '';
        foreach ($data_to_insert['values'] as $rec_value)
        {
            $fieldValues .= '(';
            foreach ($rec_value as $value)
            {
                $fieldValues .= ":v$i,";
                $i++;
            }
            $fieldValues .= \rtrim($fieldValues, ',') . '),';
        }
        $sqlQuery .= \rtrim($fieldValues, ',') . ";";
        $sth = $pdo->prepare($sqlQuery);

        $i = 0;
        foreach ($data_to_insert['values'] as $rec_value)
        {
            foreach ($rec_value as $value)
            {
                $sth->bindValue(':v' . $i++, $value, $this->getPdoType(\gettype($value)));
            }
        }

        try
        {
            $pdo->beginTransaction();
            $sth->execute();
            $pdo->commit();
        }
        catch (Exception $exc)
        {
            $pdo->rollback();
            return FALSE;
        }

        return TRUE;
    }
protected function public__insertMultiple ( $ table_name , array $ data_to_insert ) { $ pdo = $ this -> getPDOInstance ( ) ; $ fieldNames = \ implode ( '`, `' , \ array_values ( $ data_to_insert [ 'field_names' ] ) ) ; $ sqlQuery = "INSERT INTO " . $ this -> quoteTableName ( $ this -> getPrefixedTableName ( $ table_name ) ) . " (`$fieldNames`) VALUES " ; $ i = 0 ; $ fieldValues = '' ; foreach ( $ data_to_insert [ 'values' ] as $ rec_value ) { $ fieldValues .= '(' ; foreach ( $ rec_value as $ value ) { $ fieldValues .= ":v$i," ; $ i ++ ; } $ fieldValues .= \ rtrim ( $ fieldValues , ',' ) . '),' ; } $ sqlQuery .= \ rtrim ( $ fieldValues , ',' ) . ";" ; $ sth = $ pdo -> prepare ( $ sqlQuery ) ; $ i = 0 ; foreach ( $ data_to_insert [ 'values' ] as $ rec_value ) { foreach ( $ rec_value as $ value ) { $ sth -> bindValue ( ':v' . $ i ++ , $ value , $ this -> getPdoType ( \ gettype ( $ value ) ) ) ; } } try { $ pdo -> beginTransaction ( ) ; $ sth -> execute ( ) ; $ pdo -> commit ( ) ; } catch ( Exception $ exc ) { $ pdo -> rollback ( ) ; return FALSE ; } return TRUE ; }
insert multiple records into a table

@param string $table_name A name of table to insert into
@param array $data_to_insert An associative array:
[
'field_names' => ['', '', '', '', '', ],
'values' => [
['', '', '', '', '', ],
['', '', '', '', '', ],
['', '', '', '', '', ],
['', '', '', '', '', ],
],
]
@return boolean Returns TRUE on success or FALSE on failure
@see http://stackoverflow.com/questions/1176352/pdo-prepared-inserts-multiple-rows-in-single-query
@see http://stackoverflow.com/questions/19680494/insert-multiple-rows-with-pdo-prepared-statements
@see http://stackoverflow.com/questions/10060721/pdo-mysql-insert-multiple-rows-in-one-query
@see http://dev.mysql.com/doc/refman/5.7/en/load-data.html
insert multiple records into a table