@param array $columns
@param array $values

@throws DatabaseException
@return bool
978418
protected function verifyColumns(array $columns, array $values): bool {
		
		// to verify our columns, we need to be sure that our array of $values to
		// insert both (a) contains the same number of columns, (b) is always
		// the same list of columns.  for (b) this means that one row can't insert
		// and ID and email address while another row tries to insert an ID and
		// phone number.
		
		// TODO: test to see if skipping $values[0] would save time.
		
		$columnCount = sizeof($columns);
		
		foreach ($values as $value) {
			
			// our first test is to see if the count of columns in our $value
			// matches the count we expect to find.  if not, we'll throw an
			// Exception to help the calling scope know what went wrong here.
			
			if (sizeof($value) !== $columnCount) {
				throw new DatabaseException("insertMultiple failed: mismatched column counts");
			}
			
			// if we're still testing columns, then we'll want to see that there's
			// no difference between the names of our $columns and the keys of this
			// specific $value.
			
			$theseColumns = array_keys($value);
			$difference = array_diff($columns, $theseColumns);
			if (sizeof($difference) !== 0) {
				throw new DatabaseException("insertMultiple failed: mismatched columns");
			}
		}
		
		// if we looped through the entire list of $values and didn't throw an Exception,
		// then we've verified that our columns will allow us to insert these multiple
		// rows.  so, we return true.
		
		return true;
	}
1005642
public function whereRowValues($columns, $operator, $values, $boolean = 'and')
    {
        if (count($columns) !== count($values)) {
            throw new InvalidArgumentException('The number of columns must match the number of values');
        }

        $type = 'RowValues';

        $this->wheres[] = compact('type', 'columns', 'operator', 'values', 'boolean');

        $this->addBinding($this->cleanBindings($values));

        return $this;
    }
463612
public function columns(array $fields) : self
    {
        foreach ($fields as $k => $v) {
            if (strpos($v, '*') !== false) {
                $temp = explode('.', $v);
                if (count($temp) === 1) {
                    $table = $this->definition->getName();
                    $cols = $this->definition->getColumns();
                } else if (count($temp) === 2) {
                    $table = $temp[0];
                    if ($this->definition->hasRelation($table)) {
                        $cols = $this->definition->getRelation($table)->table->getColumns();
                    } else if (isset($this->joins[$table])) {
                        $cols = $this->joins[$table]->table->getColumns();
                    } else {
                        throw new DBException('Invalid foreign table name');
                    }
                } else {
                    array_pop($temp);
                    $this->with(implode('.', $temp));
                    $table = array_reduce(
                        $temp,
                        function ($carry, $item) use (&$table) {
                            return $table->getRelation($item)->table;
                        }
                    );
                    $cols = $table->getColumns();
                    $table = implode(static::SEP, $temp);
                }
                unset($fields[$k]);
                foreach ($cols as $col) {
                    $fields[] = $table . '.' . $col;
                }
            }
        }
        $primary = $this->definition->getPrimaryKey();
        foreach ($fields as $k => $v) {
            try {
                $fields[$k] = $this->getColumn($v)['name'];
            } catch (DBException $e) {
                $fields[$k] = $v;
            }
        }
        foreach ($primary as $field) {
            $field = $this->getColumn($field)['name'];
            if (!in_array($field, $fields)) {
                $fields[] = $field;
            }
        }
        $this->fields = $fields;
        return $this;
    }
741519
protected function _first($columns = '*')
    {
        $data = $this->db->get($this->table, $columns, $this->where);

        if (empty($data)) {
            return false;
        }

        return $this->setProperties($data);
    }
297038
public function query($sql, &$values=array())
	{
		if ($this->logging)
		{
			if ($values) {
				$this->logger->addInfo($sql, $values);
			} else {
				$this->logger->addInfo($sql);
			}
		}

		$this->lastQuery = $sql;
		try {
			if (!($sth = $this->connection->prepare($sql)))
				throw new DatabaseException($this);
		} catch (PDOException $e) {
			throw new DatabaseException($this);
		}

		$sth->setFetchMode(PDO::FETCH_ASSOC);

		try {
			if (!$sth->execute($values))
				throw new DatabaseException($this);
		} catch (PDOException $e) {
			throw new DatabaseException($e);
		}
		return $sth;
	}
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))
        );
    }
1157508
function fromNumericResultArray($values, &$startcol) {
		foreach (static::$_columns as $column_name => &$type) {
			$this->{$column_name} = $values[$startcol++];
		}
		if (static::$_primaryKeys && !$this->hasPrimaryKeyValues()) {
			return false;
		}
		$this->castInts();
		$this->setNew(false);
		return true;
	}
359641
public function andWhereIn($column, array $values)
    {
        $this->where[] = [self::AND_WHERE_IN, $column, $values];

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

		return $this->connection->query($query['sql'], $query['params']);
	}
1011485
public function fields(array $fields)
    {
        $fields = self::filter($fields);
        $diff   = array_diff($fields, Config::table($this->name)->fields());

        if (empty($diff))
        {
            return true;
        }
        throw new dbException('Field(s) "' . implode(', ', $diff) . '" does not exists in table "' . $this->name . '"');
    }
1029937
public function insert(array $values)
    {
        $this->compileWheres();
        $result = $this->query->insert($values);

        return 0 == (int) $result['errors'];
    }
309307
public function select($columns = [])
    {
        $expr = new ColumnExpression($this->sql);

        if ($columns instanceof Closure) {
            $columns($expr);
        } else {
            if (!is_array($columns)) {
                $columns = [$columns];
            }
            $expr->columns($columns);
        }
    }
1116470
public function addColumns(array $columns)
    {
        /*
         * Build a final collection of list column objects
         */
        foreach ($columns as $columnName => $config) {
            $this->allColumns[$columnName] = $this->makeListColumn($columnName, $config);
        }
    }
769049
public function setColumns(array $columns): self
    {
        foreach ($columns as $column => list($type, $size)) {
            list($type, $size) = $this->validateColumn($type, $size);
            $columns[$column] = [$type, $size];
        }
        $this->columns = $columns;
        return $this;
    }
618927
private function prepareRowLogic(array &$columns, ?string &$operator, array &$values)
    {
        $values = array_values($values);

        foreach ($values as $key => &$value) {
            $value = $this->prepareRow($value);

            $operator = $this->prepareRowOperator($operator, $value, $key);

            if ($operator === 'IN' and count($value) !== count($columns)) {
                throw new SqlException('Wrong row value count in condition on key #' . $key . '.');
            }
        }
        unset($value);

        return $this;
    }
1026864
public static function upsert(array $values, array $updateColumns = null)
    {

        if (empty($values))
            return true;

        if (! is_array(reset($values))) {

            $values = [$values];

        } else {

            foreach ($values as $key => $value) {

                ksort($value);
                $values[$key] = $value;
            }
        }

        $model = self::getModel();

        $sql = static::compileUpsert(
            $model->getConnection()->getQueryGrammar(), $values, $updateColumns);

        $values = static::inLineArray($values);

        return $model->getConnection()->affectingStatement($sql, $values);
    }
630674
public function values(array $values)
    {
        $this->sqlParts['values'] = is_array(current($values)) ? $values : [$values];

        return $this;
    }