具体执行Insert Ignore 并返回 数据行的编号
@param array $row 要插入的行
@return int
328219
private function processInsertIgnore2(array $row): int
    {
        self::execute2();

        // 获取新记录的主键
        $id = $this->getInsertedId();
        if ($id) {
            //已经有ID了,什么都不做
            return intval($id);
        }

        if (isset($row['id'])) {
            // 取记录中的ID
            return intval($row['id']);
        }

        //已经存在时返回0
        return 0;
    }
991382
private function processReplace(array $row): int
    {
        // 执行具体插入操作
        $this->statement->replace($row);

        //检查是否需要记录数据库日志
        $operationLog = self::logEnabled();

        $before = '';
        //如果需要记录日志,记录操作前数据
        if ($operationLog) {
            $old = clone $this->statement;
            $before = self::select2('*', $row);
            $this->statement = clone $old;
        }

        //执行操作
        self::execute2();

        // 取插入后的记录的ID
        $id = $this->getInsertedId();
        if (!$id) {
            $id = $row['id'];
        }

        //如果需要记录日志,记录操作后数据
        if ($operationLog) {
            $after = self::select2('*', $row);
            call_user_func($operationLog, $this->tableName, 'replace', ['data' => $row, 'before' => $before, 'after' => $after]);
        }

        // 后置钩子
        return $this->after('Insert', 'Replace', $id);
    }
122149
public function update(array $data): int
    {
        $this->builder->setUpdateData($data);
        $sql = $this->builder->buildSql();
        $this->builder = new QueryBuilder($this->pdo);
        return $this->execSql($sql);
    }
1068026
protected function put(array $row)
    {
        if (defined('HHVM_VERSION') === true) {
            $result = fputcsv(
                $this->csv,
                $row,
                $this->getConfig('delimiter'),
                $this->getConfig('quote')
            );
        } else {
            $result = fputcsv(
                $this->csv,
                $row,
                $this->getConfig('delimiter'),
                $this->getConfig('quote'),
                $this->getConfig('escape')
            );
        }
        // It's not trivial to measure how many bytes we should have written,
        // so we'll just ensure we have at least one per element.
        if ($result === false || $result < count($row)) {
            throw new \RuntimeException('Unable to write to output file.');
        }
        return $result;
    }
1020558
public function numRows(): ?int
	{
		$regex = '/^SELECT\s+(?:ALL\s+|DISTINCT\s+)?(?:.*?)\s+FROM\s+(.*)$/i';
		$output = [];

		if (preg_match($regex, $this->lastQuery, $output) > 0)
		{
			$stmt = $this->query("SELECT COUNT(*) FROM {$output[1]}");
			return (int) $stmt->fetchColumn();
		}

		return NULL;
	}
128975
public function count(): int
    {
        try {
            return $this->pdoStatement->rowCount();
        } catch (PDOException $pdoe) {
            throw new DatabaseException($pdoe->getMessage(), $pdoe);
        }
    }
1252287
protected function validateRowInRange($row)
    {
        $row = static::validateRow($row);
        if ($row > $this->rows) {
            throw new Exception('Requested Row exceeds matrix size');
        }

        return $row;
    }
718667
function insertRow($row, $row_id = 0) {
        array_splice($this->_data, $row_id, 0, array($row));

        $this->_updateRowsCols($row);
    }
759877
public function castRow($row)
    {
        $outRow = [];
        $validationErrors = [];
        foreach ($this->fields() as $fieldName => $field) {
            $value = array_key_exists($fieldName, $row) ? $row[$fieldName] : null;
            if (in_array($value, $this->missingValues())) {
                $value = null;
            }
            try {
                $outRow[$fieldName] = $field->castValue($value);
            } catch (Exceptions\FieldValidationException $e) {
                $validationErrors = array_merge($validationErrors, $e->validationErrors);
            }
        }
        if (count($validationErrors) > 0) {
            throw new Exceptions\FieldValidationException($validationErrors);
        }

        return $outRow;
    }
1155624
public static function isRowActions($row)
    {
        return (count($row) == count(static::makeEmptyActionRow())) && isset($row[Metrics::INDEX_NB_ACTIONS]);
    }
1167512
public function insertRow($row): void {
        if ($this->connection === null) {
            throw new \RuntimeException('Copying already ended. Create a new object');
        }
        if (is_array($row)) {
            $row = $this->escape($row);
        }
        $wynik = @pg_put_line($this->connection, $row);
        if ($wynik === false) {
            throw new \RuntimeException('Failed to insert the row');
        }
    }
1208397
protected function guessHeader(array $row)
    {
        $containsOnlyColumnNames = $this->containsOnlyColumnNames($row);
        $columnsAreUnique = $this->columnsAreUnique($row);

        if ($containsOnlyColumnNames && $columnsAreUnique) {
            return $row;
        }

        if (!$this->getOption(self::FORCE_HEADER_LINE)) {
            return range(0, count($row)-1);
        }

        if (!$containsOnlyColumnNames) {
            $hint = implode(', ', $this->collectInvalidColumns($row));
            throw new DetectionFailedException("No header found because the following columns do not like a column name: [$hint]");
        }

        // !$columnsAreUnique)
        $hint = implode(', ', $this->collectDoubledColumns($row));
        throw new DetectionFailedException("No header found because the following columns occurs more than once: [$hint]");

    }
870856
public function insertUpdateRow ($row, $filterColumns = true)
		{
			if ($filterColumns) {
				$row = $this->filterColumns($row, false);
			}

			$this->database->createQuery()
				->insertUpdate()
				->into($this->table)
				->set($row)
				->execute();

			return $this->database->insertId();
		}
1334389
protected function onInput($row)
    {
        if (!isset($this->sortedColumns)) {
            $columns = array_keys($row);
            $columnsToSort = array();
            $fixedColumns = isset($this->fixedColumns) ? $this->fixedColumns : array();
            foreach ($columns as $i => $colName) {
                if (!array_key_exists($i, $fixedColumns) 
                    && !array_key_exists($colName, $fixedColumns)
                ) {
                    $columnsToSort[$i] = $colName;
                }
            }

            if (isset($this->nameSort)) {
                $sort = $this->nameSort;
                uasort(
                    $columnsToSort,
                    function ($a, $b) use ($sort) {
                        $cmp = 0;
                        if (is_string($sort)) {
                            $cmp = is_numeric($a) && is_numeric($b) ?
                            $a - $b : strcmp($a, $b);
                            $cmp = $sort === 'asc' ? $cmp : -$cmp;
                        } else if (is_callable($sort)) {
                            $cmp = $sort($a, $b);
                        }

                        return $cmp;
                    }
                );
            }
            if (isset($this->labelSort)) {
                $sort = $this->nameSort;
                $meta = $this->meta;
                uasort(
                    $columnsToSort,
                    function ($a, $b) use ($sort, $meta) {
                        $cmp = 0;
                        $a = isset($meta[$a]['label']) ? $meta[$a]['label'] : '';
                        $b = isset($meta[$b]['label']) ? $meta[$a]['label'] : '';
                        if (is_string($sort)) {
                            $cmp = is_numeric($a) && is_numeric($b) ?
                            $a - $b : strcmp($a, $b);
                            $cmp = $sort === 'asc' ? $cmp : -$cmp;
                        } else if (is_callable($sort)) {
                            $cmp = $sort($a, $b);
                        }

                        return $cmp;
                    }
                );
            }
            $sortedColumns = array();
            foreach ($fixedColumns as $i => $pos) {
                if (is_numeric($i)) {
                    $sortedColumns[$pos] = $columns[$i];
                } else {
                    $sortedColumns[$pos] = $i;
                }
            }

            $i = 0;
            foreach ($columnsToSort as $column) {
                while (isset($sortedColumns[$i])) {
                    $i++;
                }

                $sortedColumns[$i] = $column;
                $i++;
            }
            ksort($sortedColumns);
            $this->sortedColumns = $sortedColumns;
        }
        $newRow = array();
        foreach ($this->sortedColumns as $column) {
            $newRow[$column] = $row[$column];
        }

        $this->next($newRow);
    }
352871
public function insertBatch(array $row) {
		$this->batch[] = $row;
		if(count($this->batch) >= $this->batch_size) {
			$this->flushBatch();
			return true;
		}
		return false;
	}
1263511
public function insertRow ($row, $filterColumns = true)
		{
			if ($filterColumns) {
				$row = $this->filterColumns($row);
			}

			return $this->database->createQuery()
				->insert()
				->into($this->table)
				->set($row)
				->execute();
		}
830054
public function insertRows(array $rows, $table, $fieldArr = [], $isReplace = false)
    {
        $type = $isReplace ? 'REPLACE' : 'INSERT';

        // 数据中允许插入的字段
        $allowFields = $fieldArr ? $fieldArr : array_keys(current($rows));
        $allowFields = QueryBuilder::quoteFieldNames(implode(',', $allowFields));

        //
        $valueArr = [];
        foreach ($rows as $row) {
            $rowStr = '';
            foreach ($row as $key => $val) {
                // 去掉不允许写入的属性
                if ($fieldArr && !in_array($key, $fieldArr)) {
                    unset($row[$key]);
                }
            }

            $rowStr = implode(',', array_map('\wf\db\QueryBuilder::quoteInputVar', $row));
            $valueArr[] = "({$rowStr})";
        }
        $values = $rowStr = implode(',', $valueArr);

        return $this->exec("%x INTO %t (%x) VALUES %x", array($type, $table, $allowFields, $values));
    }