src/ORM/Connect/DBQueryBuilder.php
protected function buildInsertQuery(SQLInsert $query, array &$parameters)
    {
        $nl = $this->getSeparator();
        $into = $query->getInto();

        // Column identifiers
        $columns = $query->getColumns();
        $sql = "INSERT INTO {$into}{$nl}(" . implode(', ', $columns) . ")";

        // Values
        $sql .= "{$nl}VALUES";

        // Build all rows
        $rowParts = array();
        foreach ($query->getRows() as $row) {
            // Build all columns in this row
            $assignments = $row->getAssignments();
            // Join SET components together, considering parameters
            $parts = array();
            foreach ($columns as $column) {
                // Check if this column has a value for this row
                if (isset($assignments[$column])) {
                    // Assigment is a single item array, expand with a loop here
                    foreach ($assignments[$column] as $assignmentSQL => $assignmentParameters) {
                        $parts[] = $assignmentSQL;
                        $parameters = array_merge($parameters, $assignmentParameters);
                        break;
                    }
                } else {
                    // This row is missing a value for a column used by another row
                    $parts[] = '?';
                    $parameters[] = null;
                }
            }
            $rowParts[] = '(' . implode(', ', $parts) . ')';
        }
        $sql .= $nl . implode(",$nl", $rowParts);

        return $sql;
    }
protected function buildInsertQuery(SQLInsert $query, array &$parameters)
    {
        $nl = $this->getSeparator();
        $into = $query->getInto();

        // Column identifiers
        $columns = $query->getColumns();
        $sql = "INSERT INTO {$into}{$nl}(" . implode(', ', $columns) . ")";

        // Values
        $sql .= "{$nl}VALUES";

        // Build all rows
        $rowParts = array();
        foreach ($query->getRows() as $row) {
            // Build all columns in this row
            $assignments = $row->getAssignments();
            // Join SET components together, considering parameters
            $parts = array();
            foreach ($columns as $column) {
                // Check if this column has a value for this row
                if (isset($assignments[$column])) {
                    // Assigment is a single item array, expand with a loop here
                    foreach ($assignments[$column] as $assignmentSQL => $assignmentParameters) {
                        $parts[] = $assignmentSQL;
                        $parameters = array_merge($parameters, $assignmentParameters);
                        break;
                    }
                } else {
                    // This row is missing a value for a column used by another row
                    $parts[] = '?';
                    $parameters[] = null;
                }
            }
            $rowParts[] = '(' . implode(', ', $parts) . ')';
        }
        $sql .= $nl . implode(",$nl", $rowParts);

        return $sql;
    }
protected function buildInsertQuery ( SQLInsert $ query , array & $ parameters ) { $ nl = $ this -> getSeparator ( ) ; $ into = $ query -> getInto ( ) ; // Column identifiers $ columns = $ query -> getColumns ( ) ; $ sql = "INSERT INTO {$into}{$nl}(" . implode ( ', ' , $ columns ) . ")" ; // Values $ sql .= "{$nl}VALUES" ; // Build all rows $ rowParts = array ( ) ; foreach ( $ query -> getRows ( ) as $ row ) { // Build all columns in this row $ assignments = $ row -> getAssignments ( ) ; // Join SET components together, considering parameters $ parts = array ( ) ; foreach ( $ columns as $ column ) { // Check if this column has a value for this row if ( isset ( $ assignments [ $ column ] ) ) { // Assigment is a single item array, expand with a loop here foreach ( $ assignments [ $ column ] as $ assignmentSQL => $ assignmentParameters ) { $ parts [ ] = $ assignmentSQL ; $ parameters = array_merge ( $ parameters , $ assignmentParameters ) ; break ; } } else { // This row is missing a value for a column used by another row $ parts [ ] = '?' ; $ parameters [ ] = null ; } } $ rowParts [ ] = '(' . implode ( ', ' , $ parts ) . ')' ; } $ sql .= $ nl . implode ( ",$nl" , $ rowParts ) ; return $ sql ; }
Builds a query from a SQLInsert expression

@param SQLInsert $query The expression object to build from
@param array $parameters Out parameter for the resulting query parameters
@return string Completed SQL string
Builds a query from a SQLInsert expression