CI_DB_query_builder::set_insert_batch PHP Method

set_insert_batch() public method

The "set_insert_batch" function. Allows key/value pairs to be set for batch inserts
public set_insert_batch ( $key, $value = '', $escape = NULL ) : CI_DB_query_builder
return CI_DB_query_builder
    public function set_insert_batch($key, $value = '', $escape = NULL)
    {
        $key = $this->_object_to_array_batch($key);
        if (!is_array($key)) {
            $key = array($key => $value);
        }
        is_bool($escape) or $escape = $this->_protect_identifiers;
        $keys = array_keys($this->_object_to_array(current($key)));
        sort($keys);
        foreach ($key as $row) {
            $row = $this->_object_to_array($row);
            if (count(array_diff($keys, array_keys($row))) > 0 or count(array_diff(array_keys($row), $keys)) > 0) {
                // batch function above returns an error on an empty array
                $this->qb_set[] = array();
                return;
            }
            ksort($row);
            // puts $row in the same order as our keys
            if ($escape !== FALSE) {
                $clean = array();
                foreach ($row as $value) {
                    $clean[] = $this->escape($value);
                }
                $row = $clean;
            }
            $this->qb_set[] = '(' . implode(',', $row) . ')';
        }
        foreach ($keys as $k) {
            $this->qb_keys[] = $this->protect_identifiers($k, FALSE, $escape);
        }
        return $this;
    }