Inserts record
@param array $fieldsValues
@return mixed $primaryKeyValue id of new record (if query builder insert operation returns it) or false
492091
public function insert($fieldsValues)
    {
        $this->connectToDB();
        $this->queryBuilder->table($this->table());
        return $this->queryBuilder->insert($fieldsValues);
    }
422914
public function addFields(array $fields)
    {
        foreach ($fields as $field)
        {
            $name = $field->getName();
            $addFields[$name] = $field; # we key by name to prevent duplicates!
        }
        
        $keysString = "";
        $fieldStrings = array();
        
        foreach ($addFields as $fieldName => $field)
        {
            $fieldStrings[] = $field->getFieldString();
                
            /* @var $field DatabaseField */
            if ($field->isPrimaryKey())
            {
                $errMsg = 'Do not set field to be primary key when adding fields. ' .
                          'Instead, use the changePrimaryKey method';
                throw new \Exception($errMsg);
            }
            elseif ($field->isKey())
            {
                if ($keysString !== "")
                {
                    $keysString .= ", ";
                }
                
                if ($field->isUnique())
                {
                    $keysString .= "UNIQUE ";
                }
                
                $keysString .= "KEY (`" . $fieldName . "`) ";
            }
        }
        
        $fieldsString = implode(", ", $fieldStrings);
        
        $fieldsString .= $keysString;
        
        $query = 
            "ALTER TABLE " . 
            "`" . $this->m_name . "` " . 
            "ADD " .
            "(" . $fieldsString . ") ";
        
        $result = $this->m_mysqliConn->query($query);
        
        if ($result !== TRUE)
        {
            throw new \Exception('Error creating table with query: ' . $query);
        }
    }
515010
protected function insertWithValues(array $values): string
	{
		$sql  = 'INSERT INTO ';
		$sql .= $this->escapeTable($this->query->getTable());
		$sql .= ' (' . implode(', ', $this->escapeIdentifiers(array_keys($values))) . ')';
		$sql .= ' VALUES';
		$sql .= ' (' . $this->params($values) . ')';

		return $sql;
	}
263178
public function insert($fields)
    {
        // Set fields
        $this->fields($fields);

        // Define fields
        $fields = $this->getInsertFieldsString();

        // Build query
        $this->query = 'INSERT INTO ' . $this->table . $fields;

        // Prepare statement
        $this->statement = $this->pdo->prepare($this->query);

        // Bind fields values
        $this->bindFields();

        // Execute statement
        $result = $this->statement->execute();

        // Reset values
        $this->reset();

        // Return result
        return $result;
    }
448343
public function createInsertIgnore(string $tableName, array $fields, array $values): string
    {
        // 构造插入语句,如果已经存在(约束),则忽略
        return "INSERT " . "IGNORE INTO " . $tableName . '(' . implode(',', $fields) . ') VALUES(' . implode(',', $values) . ')';
    }
212200
public function insert($table, array $values = null)
    {
        $builder         = new Insert($this->driver);
        $this->lastQuery = $builder;

        if ($values) {
            $builder->values($values);
        }

        return $builder->into($table);
    }
198006
public function insert(array $values = []): bool
	{
		$query = $this->compiler->insert($values);

		return $this->connection->query($query['sql'], $query['params']);
	}
49399
public function insert(...$field_values)
    {
        if ($this->is_done) {
            throw new RuntimeException('This batch insert is already done');
        }

        if (count($field_values) == $this->fields_num) {
            $this->rows[] = $this->connection->prepare($this->row_prepare_pattern, ...$field_values);

            if (count($this->rows) == $this->rows_per_batch) {
                $this->flush();
            }
        } else {
            throw new BadMethodCallException('Number of arguments does not match number of fields');
        }
    }
369902
protected function _insert_batch($table, $keys, $values)
	{
		// Multiple-value inserts are only supported as of SQL Server 2008
		if (version_compare($this->version(), '10', '>='))
		{
			return parent::_insert_batch($table, $keys, $values);
		}

		return ($this->db->db_debug) ? $this->db->display_error('db_unsupported_feature') : FALSE;
	}
1208941
public function delete($fieldsValues)
    {
        $this->connectToDB();
        $this->queryBuilder->table($this->table());
        $this->queryBuilder->delete($fieldsValues);
    }
124385
public function insert(array $values)
    {
        // Since every insert gets treated like a batch insert, we will make sure the
        // bindings are structured in a way that is convenient when building these
        // inserts statements by verifying these elements are actually an array.
        if (empty($values)) {
            return true;
        }

        if (! is_array(reset($values))) {
            $values = [$values];
        }

        // Here, we will sort the insert keys for every record so that each insert is
        // in the same order for the record. We need to make sure this is the case
        // so there are not any errors or problems when inserting these records.
        else {
            foreach ($values as $key => $value) {
                ksort($value);

                $values[$key] = $value;
            }
        }

        // Finally, we will run this query against the database connection and return
        // the results. We will need to also flatten these bindings before running
        // the query so they are all in one huge, flattened array for execution.
        $compiledInsert = $this->grammar->compileInsert($this, $values);

        return $this->connection->insert(
            $compiledInsert,
            $this->cleanBindings(Arr::flatten($values, 1))
        );
    }
1094084
public function insert(array $values)
    {
        $result = $this->getBuilder()->insert($values);

        // Reset query builder
        $this->resetBuilder();

        return $result;
    }
16956
public function insert(array $values) {
        if (!$this->checkExists()) return false;

        $this->current = self::OP_INSERT;
        $this->query = 'INSERT INTO `' . $this->name . '` (';
        $columns = array();
        $noOfColumns = 0;
        foreach (array_values($values) as $ky => $row) {
            $rowArray = $this->checkModel($row, true);
            if ($ky === 0) $noOfColumns = count($rowArray);

            if (count($rowArray) !== $noOfColumns) {
                throw new Exception('All rows must have the same number of columns in table "' . $this->name .
                '". Set others as null');
            }

            if (count($rowArray) === 0)
                    throw new Exception('You cannot insert an empty row into table "' . $this->name . '"');

            foreach ($rowArray as $column => &$value) {
                if (empty($value) && $value != 0) continue;

                $column = Util::camelTo_($column);

                if (!in_array($column, $columns)) $columns[] = $column;
                $this->values[$ky][':' . $column] = $value;
            }
        }

        $this->query .= '`' . join('`, `', $columns) . '`';
        $this->query .= ') VALUES (';
        $this->query .= ':' . join(', :', $columns);
        $this->query .= ')';

        $this->multiple = true;
        $this->doPost = self::OP_INSERT;
        if ($this->delayExecute) {
            return $this;
        }

        return $this->execute();
    }
957074
protected function addValuesToFields(array $fields)
    {
        foreach ($fields as $name => &$field) {
            if (!empty($field['fields'])) {
                $field['fields'] = $this->addValuesToFields($field['fields']);
            } elseif ($field['type'] === 'checkbox') {
                // Value is a list of checked options.
                $value = array();
                foreach ($field['options'] as $optionName => $optionLabel) {
                    if ($this->getFormValue($optionName)) {
                        $value[] = $optionName;
                    }
                }
                $field['value'] = $value;
            } elseif (!isset($field['value'])) {
                // Explicitly set values (in the 'value' key) take precedence
                // over submitted values, which in turn take precedence over
                // default values (gathered via getDefaultFormValues()).
                $field['value'] = $this->getFormValue($name);
            }
        }
        return $fields;
    }
639825
final public function insertGetId(array $datas) {
      $this->connection();
      $this->last_id = NULL;
      if ( $this->driver=='pgsql' ) {
         $this->insert( $datas, TRUE );
         if ( @$this->data[0] ) {
            $this->last_id = @$this->data[0]->{$this->primaryKey};
         }
      }
      else {
         $this->insert( $datas );
         $this->last_id = $this->id_conn->lastInsertId();
      }
      return (int) $this->last_id;
   }
316477
public function insert(array $rowValue)
    {
        $insertData = [];
        foreach ($rowValue as $key => $row) {
            $insertKey = "`{$key}`";
            $insertData[$insertKey] = $row;
        }
        return $this->connection->insert($this->getFrom(), $insertData);
    }
933348
protected function values(array $values)
    {
        if (is_numeric(key($values))) {
            $this->insertValues[] = $values;
        } else {
            // Reorder the submitted values to match the fields array.
            foreach ($this->insertFields as $key) {
                $insert_values[$key] = $values[$key];
            }
            $this->insertValues[] = array_values($insert_values);
        }
        return $this;
    }