Insert row(s) into table

@param string $table
@param array $rows
@param mixed $keys
@return array
188650
public function insert($table, $rows, $keys = null, $options = []) {
		return $this->object->insert($table, $rows, $keys, $options);
	}
435778
public function into($table, array $columns = [])
    {
        if (count($columns)) {
            $this->setColumns($columns);
        }

        return $this->addRootTable($table);
    }
1278169
public function insertRows($table, array $settings, $bind = true)
    {
        //argument test
        Argument::i()
            //Argument 1 must be a string
            ->test(1, 'string')
            //Argument 3 must be an array or bool
            ->test(3, 'array', 'bool');
        
        //this is an array of arrays
        foreach ($settings as $index => $setting) {
            //SQLite no available multi insert
            //there's work arounds, but no performance gain
            $this->insertRow($table, $setting, $bind);
        }
        
        return $this;
    }
1162153
public function rowsFrom(string $table, string ...$tables)
    {
        $instance = $this->deleteQueryInstance();

        $instance->deleteQuery()->rowsFrom($table, ...$tables);

        return $instance;
    }
1049843
public function compileInsert(string $table, array $columns, array $rowsets): string
    {
        //@todo possibly different statement for versions higher than 3.7.11
        if (count($rowsets) == 1) {
            return parent::compileInsert($table, $columns, $rowsets);
        }

        //SQLite uses alternative syntax
        $statement = [];
        $statement[] = "INSERT INTO {$this->quote($table, true)} ({$this->prepareColumns($columns)})";

        foreach ($rowsets as $rowset) {
            if (count($statement) == 1) {
                $selectColumns = [];
                foreach ($columns as $column) {
                    $selectColumns[] = "? AS {$this->quote($column)}";
                }

                $statement[] = 'SELECT ' . implode(', ', $selectColumns);
            } else {
                //It is crityially important to use UNION ALL, UNION will try to merge values together
                //which will cause non predictable insert order
                $statement[] = 'UNION ALL SELECT ' . trim(str_repeat('?, ', count($columns)), ', ');
            }
        }

        return implode("\n", $statement);
    }
18761
public function insert($table, $columns, array $params = [])
    {
        $request = $this->db->getQueryBuilder()->insert($table, $columns, $params);

        return $this->setRequest($request);
    }
940216
protected function insertDefault( $table, $rows ) {

        $columns = $this->getColumns( $rows );
        if ( empty( $columns ) ) return;

        $query = $this->insertHead( $table, $columns );
        $lists = $this->valueLists( $rows, $columns );

        foreach ( $lists as $list ) {

            $singleQuery = $query . $list;

            $this->onQuery( $singleQuery );

            $statement = $this->prepare( $singleQuery );
            $statement->execute();

        }

        return $statement; // last statement is returned

    }
818924
public function setRows(array $rows)
    {
        $this->rows = $rows;
        $this->setKeys(array_keys($this->rows[0]));
        return $this;
    }
1226611
protected function insertPrepared( $table, $rows ) {

        $columns = $this->getColumns( $rows );
        if ( empty( $columns ) ) return;

        $query = $this->insertHead( $table, $columns );
        $query .= "( ?" . str_repeat( ", ?", count( $columns ) - 1 ) . " )";

        $statement = $this->prepare( $query );

        foreach ( $rows as $row ) {

            $values = array();

            foreach ( $columns as $column ) {

                $value = (string) $this->format( @$row[ $column ] );
                $values[] = $value;

            }

            $this->onQuery( $query, $values );

            $statement->execute( $values );

        }

        return $statement;

    }
448966
public function buildInsertQuery($table, $data)
    {
        $sql = "INSERT INTO " . $this->quoteSpecialName($table) . " ";

        if (!empty($data['ON DUPLICATE'])) {
            $onDuplicate = $data['ON DUPLICATE'];
            unset($data['ON DUPLICATE']);
        }

        $keys = $values = '';

        foreach ($data as $key => $value) {
            if (!empty($keys)) $keys .= ', ';
            if (!empty($values)) $values .= ', ';

            $keys .= '`' . $key . '`';
            $values .= $this->escapeItem($value);
        }

        $keys = '(' . $keys . ')';
        $values = '(' . $values . ')';

        $sql .= $keys . ' VALUES ' . $values;

        if (!empty($onDuplicate)) {
            $sql .= " ON DUPLICATE KEY UPDATE " . $onDuplicate;
        }

        $sql .= ';';

        return $sql;
    }
618423
public function bulkInsert($table, $records)
    {
        if (!$records) {
            throw new InvalidArgumentException(['Unable to insert into :table table without data', 'table' => $table]);
        }

        $fields = array_keys($records[0]);
        $insertedFields = '[' . implode('],[', $fields) . ']';

        $pdo = $this->_getPdo();

        $rows = [];
        foreach ($records as $record) {
            $row = [];
            foreach ($record as $field => $value) {
                $row[] = is_string($value) ? $pdo->quote($value) : $value;
            }

            $rows[] = '(' . implode(',', $row) . ')';
        }

        $sql = 'INSERT' . ' INTO ' . $this->_escapeIdentifier($table) . " ($insertedFields) VALUES " . implode(', ', $rows);

        return $this->execute($sql);
    }
1076534
public function insert($table, $columns) 
    {
        $this->sql = 'INSERT INTO ' . $this->quoteTableName($table) . ' ';
        
        $columnNames = '(';
        $columnValues = '(';
        foreach($columns as $k => $v) {
            $columnNames .= $this->quoteColumnName($k) . ', ';
            $columnValues .= $this->quoteValue($v) . ', ';
        }
        
        $this->sql .= trim($columnNames, ', ') . ')';
        $this->sql .= ' VALUES ';
        $this->sql .= trim($columnValues, ', ') . ')';
        
        return $this;        
    }
1252436
public function save(string $table, array $data): array
    {
        try {
            $this->db->beginTransaction();

            $query = "INSERT INTO $table (" .
                implode(', ', array_keys($data)) .
                ") VALUES (" .
                substr(str_repeat(', ?', count($data)), 1) .
                ")" .
                " ON DUPLICATE KEY UPDATE " .
                implode('=?, ', array_keys($data)) . "=?";

            $duplicateDate = array_merge(array_values($data), array_values($data));
            /** @var PDOStatement $stmt */
            $stmt = $this->db->prepare(
                $query
            );
            $stmt->execute(array_values($duplicateDate));
            $this->db->commit();

            return $data;
        } catch (PDOException $e) {
            $this->db->rollBack();
            throw new PDOException($e);
        }
    }
1067308
function addRows($rows)
	{
		for($i=0; $i < count($rows); $i++) $this->addRow($rows[$i]);
	}
833781
public function insertMany(array $rows, array $update=[], array $constraint=[]) {
		$sql = $this->buildInsertSQL($rows, $update, $constraint);
		$params = $this->getParameters();
		$this->db->query($sql, $params);
		return $this;
	}
1331553
public function insert($table, array $row, $pkval=false)
    {
    	return Sql::assistant( $this->ds )->insert($table, $row, $pkval);
	}
409822
public function generate(array $rows): array
    {
        $generatedRows = [];
        foreach ($rows as $identifier => $row) {
            $generatedRows = $this->generateRowsIfNeeded($identifier, $row, $generatedRows);
        }
        return $generatedRows;
    }