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());
 }
Ejemplo n.º 2
0
 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;
     }
 }
Ejemplo n.º 3
0
 /**
  * @return TableQuery
  */
 private function createQuery()
 {
     return DB::table($this->schema->getName());
 }
Ejemplo n.º 4
0
 public function getTableName()
 {
     return $this->schema->getName();
 }