Exemplo n.º 1
0
 /**
  * @param \Notadd\Foundation\Database\Query\Builder $query
  * @param string $sql
  * @param array $values
  * @param string $sequence
  * @return int
  */
 public function processInsertGetId(Builder $query, $sql, $values, $sequence = null)
 {
     $results = $query->getConnection()->selectFromWriteConnection($sql, $values);
     $sequence = $sequence ?: 'id';
     $result = (array) $results[0];
     $id = $result[$sequence];
     return is_numeric($id) ? (int) $id : $id;
 }
 /**
  * @param  \Notadd\Foundation\Database\Query\Builder $query
  * @param  string $key
  * @param  string $extraValue
  * @return void
  */
 protected function addWhere($query, $key, $extraValue)
 {
     if ($extraValue === 'NULL') {
         $query->whereNull($key);
     } elseif ($extraValue === 'NOT_NULL') {
         $query->whereNotNull($key);
     } else {
         $query->where($key, $extraValue);
     }
 }
Exemplo n.º 3
0
 /**
  * @param \Notadd\Foundation\Database\Query\Builder|static $query
  * @param string $boolean
  * @return $this
  */
 public function addNestedWhereQuery($query, $boolean = 'and')
 {
     if (count($query->wheres)) {
         $type = 'Nested';
         $this->wheres[] = compact('type', 'query', 'boolean');
         $this->addBinding($query->getBindings(), 'where');
     }
     return $this;
 }
Exemplo n.º 4
0
 /**
  * @param \Notadd\Foundation\Database\Query\Builder $query
  * @param string $sql
  * @param array $values
  * @param string $sequence
  * @return int
  */
 public function processInsertGetId(Builder $query, $sql, $values, $sequence = null)
 {
     $query->getConnection()->insert($sql, $values);
     $id = $query->getConnection()->getPdo()->lastInsertId($sequence);
     return is_numeric($id) ? (int) $id : $id;
 }
Exemplo n.º 5
0
 /**
  * @param \Notadd\Foundation\Database\Eloquent\Model $model
  * @return $this
  */
 public function setModel(Model $model)
 {
     $this->model = $model;
     $this->query->from($model->getTable());
     return $this;
 }