public function execute(QueryContext $context) { $query = $this->toQueryString($context); if (true === $this->insertGetId) { if (true === DB::insert($query, $context->getParams())) { return DB::table($this->schema->getName())->orderBy($this->schema->getAutoIncrementField(), 'DESC')->pluck($this->schema->getAutoIncrementField())->execute(); } } return DB::insert($query, $context->getParams()); }
private function setField($field, $value) { if (!$this->schema->existsField($field)) { throw new EntityException("Can't find field [{$field}] in table [" . $this->schema->getName()); } if ($value != $this->shadows[$field]) { if ($this->autoIncrementField === $field) { if (!$this->exists) { if (DB::table($this->schema->getName())->where($field, $value)->count()->execute() > 0) { $this->exists = true; } $this->query = DB::table($this->schema->getName())->where($field, $value); } } $this->fields[$field] = $value; if ($this->autoIncrementField !== $field) { $this->updates[$field] = $value; } $this->shadows[$field] = $value; } }
/** * @return TableQuery */ private function createQuery() { return DB::table($this->schema->getName()); }
public function getTableName() { return $this->schema->getName(); }