diff options
Diffstat (limited to 'src/FirebirdConnection.php')
| -rwxr-xr-x | src/FirebirdConnection.php | 171 |
1 files changed, 0 insertions, 171 deletions
diff --git a/src/FirebirdConnection.php b/src/FirebirdConnection.php deleted file mode 100755 index 67df19d..0000000 --- a/src/FirebirdConnection.php +++ /dev/null @@ -1,171 +0,0 @@ -<?php - -namespace Xgrz\Firebird; - -use Illuminate\Database\Connection as DatabaseConnection; -use Illuminate\Support\Collection; -use Xgrz\Firebird\Query\FirebirdBuilder as FirebirdQueryBuilder; -use Xgrz\Firebird\Query\Grammars\FirebirdGrammar as FirebirdQueryGrammar; -use Xgrz\Firebird\Query\Processors\FirebirdProcessor as FirebirdQueryProcessor; -use Xgrz\Firebird\Schema\FirebirdBuilder as FirebirdSchemaBuilder; -use Xgrz\Firebird\Schema\Grammars\FirebirdGrammar as FirebirdSchemaGrammar; - -class FirebirdConnection extends DatabaseConnection -{ - /** - * The last inserted ID generated by the server. - * RETURNED by the insert statement - * - * @var string|int|null - */ - protected $lastInsertId; - - /** - * Get the default query grammar instance. - * - * @return \Illuminate\Database\Query\Grammars\Grammar - */ - protected function getDefaultQueryGrammar(): FirebirdQueryGrammar - { - return new FirebirdQueryGrammar($this); - } - - /** - * Get the default post processor instance. - * - * @return \Illuminate\Database\Query\Processors\Processor - */ - protected function getDefaultPostProcessor(): FirebirdQueryProcessor - { - return new FirebirdQueryProcessor; - } - - /** - * Get a schema builder instance for this connection. - * - * @return \Xgrz\Firebird\Schema\Builder - */ - public function getSchemaBuilder(): FirebirdSchemaBuilder - { - if (is_null($this->schemaGrammar)) { - $this->useDefaultSchemaGrammar(); - } - - return new FirebirdSchemaBuilder($this); - } - - /** - * Get the default schema grammar instance. - * - * @return \Xgrz\Firebird\Schema\Grammars\FirebirdGrammar - */ - protected function getDefaultSchemaGrammar() - { - return new FirebirdSchemaGrammar($this); // $this->withTablePrefix() - } - - /** - * Get the connection's last insert ID. - * - * @return string|int|null - */ - public function getLastInsertId() - { - return $this->lastInsertId; - } - - /** - * Get a new query builder instance. - * - * @return \Xgrz\Firebird\Query\FirebirdBuilder - */ - public function query() - { - return new FirebirdQueryBuilder( - $this, $this->getQueryGrammar(), $this->getPostProcessor() - ); - } - - /** - * Run an insert statement against the database. - * - * @param string $query - * @param array $bindings - * @param string|null $sequence - * @return array - */ - public function insert($query, $bindings = [], $sequence = null) - { - return $this->run($query, $bindings, function ($query, $bindings) use ($sequence) { - if ($this->pretending()) { - return true; - } - - $statement = $this->getPdo()->prepare($query); - - $this->bindValues($statement, $this->prepareBindings($bindings)); - - $this->recordsHaveBeenModified(); - - $result = $statement->execute(); - - // Fetch the RETURNING clause result to get the actual ID used - if ($result) { - $row = $statement->fetch(\PDO::FETCH_ASSOC); - if ($row) { - // Get the first (and typically only) returned value - $this->lastInsertId = reset($row); - } - } - - return $result; - }); - } - - /** - * Run a select statement against the database. - * - * @param string $query - * @param array $bindings - * @param bool $useReadPdo - * @return array - */ - public function select($query, $bindings = [], $useReadPdo = true) - { - return $this->run($query, $bindings, function ($query, $bindings) use ($useReadPdo) { - if ($this->pretending()) { - return []; - } - - // For select statements, we'll simply execute the query and return an array - // of the database result set. Each element in the array will be a single - // row from the database table, and will either be an array or objects. - $statement = $this->prepared( - $this->getPdoForSelect($useReadPdo)->prepare($query) - ); - - $this->bindValues($statement, $this->prepareBindings($bindings)); - - $statement->execute(); - - $result = []; - while ($row = $statement->fetch(\PDO::FETCH_ASSOC)) { - $lowerCaseRow = array_change_key_case((array) $row, CASE_LOWER); - $result[] = (object) $lowerCaseRow; - } - return count($result) > 0 ? $result : []; - }); - } - - /** - * Execute a stored procedure. - * - * @param string $procedure - * @param array $values - * @return Collection - */ - public function executeProcedure($procedure, array $values = []): Collection - { - return $this->query()->fromProcedure($procedure, $values)->get(); - } -} |
