Stash_model::insert_ignore_batch PHP Method

insert_ignore_batch() protected method

Prepare INSERT IGNORE BATCH SQL query
protected insert_ignore_batch ( string $table, array $data ) : Null
$table string The table to insert into
$data array Array in form of "Column" => "Value", ...
return Null
    protected function insert_ignore_batch($table, array $data)
    {
        $_keys = array();
        $_prepared = array();
        foreach ($data as $row) {
            $_values = array();
            foreach ($row as $col => $val) {
                // add key
                if (!in_array($col, $_keys)) {
                    $_keys[] = $col;
                }
                // add values
                $_values[] = $this->db->escape($val);
            }
            $_prepared[] = '(' . implode(',', $_values) . ')';
        }
        $this->db->query('INSERT IGNORE INTO ' . $this->db->dbprefix . $table . ' (' . implode(',', $_keys) . ') VALUES ' . implode(',', array_values($_prepared)) . ';');
    }