示例#1
0
 /**
  * {@inheritdoc}
  */
 public function insertAndGetId(Query $query, array $values, $primaryKey = null)
 {
     if ($query->insert($values) === false) {
         return false;
     }
     return $query->getConnection()->getPDO()->lastInsertId();
 }
示例#2
0
 /**
  * {@inheritdoc}
  */
 public function insertAndGetId(Query $query, array $values, $primaryKey = null)
 {
     if ($query->insert($values) === false) {
         return false;
     }
     $sequence = $query->getTable() . '_' . $primaryKey . '_seq';
     return $query->getConnection()->getPDO()->lastInsertId($sequence);
 }
示例#3
0
 /**
  * Returns the compiled query.
  *
  * @access  public
  * @return  array
  */
 public function get()
 {
     $query = $this->query->getCompiler()->select();
     $query['sql'] = '(' . $query['sql'] . ')';
     if ($this->alias !== null) {
         $query['sql'] .= ' AS ' . $this->query->getCompiler()->wrap($this->alias);
     }
     return $query;
 }
示例#4
0
 /**
  * Compiles a DELETE query.
  *
  * @access  public
  * @return  array
  */
 public function delete()
 {
     $sql = 'DELETE FROM ';
     $sql .= $this->wrap($this->query->getTable());
     $sql .= $this->wheres($this->query->getWheres());
     return ['sql' => $sql, 'params' => $this->params];
 }
示例#5
0
 /**
  * {@inheritdoc}
  */
 public function register()
 {
     $this->container->registerSingleton([ConnectionManager::class, 'database'], function ($container) {
         if ($container->has('pagination')) {
             Query::setPaginationFactory(function () use($container) {
                 return $container->get('pagination');
             });
         }
         $config = $container->get('config')->get('database');
         return new ConnectionManager($config['default'], $config['configurations']);
     });
 }
示例#6
0
 /**
  * {@inheritdoc}
  */
 public function batch(Closure $processor, $batchSize = 1000, $offsetStart = 0, $offsetEnd = null)
 {
     if (empty($this->orderings)) {
         $this->ascending($this->model->getPrimaryKey());
     }
     parent::batch($processor, $batchSize, $offsetStart, $offsetEnd);
 }