Source for file TSqlMultiInsert.php
Documentation is available at TSqlMultiInsert.php
namespace
Adianti \
Database ;
* Provides an Interface to create an MULTI INSERT statement
* @author Pablo Dall'Oglio
* @copyright Copyright (c) 2006 Adianti Solutions Ltd. (http://www.adianti.com.br)
* @license http://www.adianti.com.br/framework-license
* Transform the value according to its PHP type before send it to the database
* @param $value Value to be transformed
* @return Transformed Value
private function transform ( $value )
// store just scalar values (string, integer, ...)
$result =
$conn -> quote ( $value ) ;
else if ( is_bool ( $value )) // if is a boolean
$result =
$value ?
'TRUE' :
'FALSE' ;
else if ( $value !==
'' ) // if its another data type
* this method doesn't exist in this class context
* @param $criteria A TCriteria object, specifiyng the filters
* @exception Exception in any case
throw
new Exception ( "Cannot call setCriteria from " . __CLASS__
) ;
* Returns the INSERT plain statement
* @param $prepared Return a prepared Statement
foreach ( $this -> rows as $row )
foreach ( $row as $key =>
$value )
$row [ $key ] =
$this -> transform ( $value ) ;
$buffer [ ] =
" ($values_list ) " ;
$this -> sql =
" INSERT INTO {$this -> entity } (
$target_columns ) VALUES
" . implode ( ',' , $buffer ) ;