/** * {@inheritdoc} */ public function insertAndGetId(Query $query, array $values, $primaryKey = null) { if ($query->insert($values) === false) { return false; } return $query->getConnection()->getPDO()->lastInsertId(); }
/** * {@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); }
/** * 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; }
/** * 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]; }
/** * {@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']); }); }
/** * {@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); }