Skip to content

Commit

Permalink
Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
harrygulliford committed Oct 27, 2020
1 parent 7c78387 commit 86eda40
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 24 deletions.
35 changes: 12 additions & 23 deletions src/Connection.php → src/FirebirdConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,21 @@
use Firebird\Support\Version;
use Illuminate\Database\Connection as DatabaseConnection;

class Connection extends DatabaseConnection
class FirebirdConnection extends DatabaseConnection
{
/**
* Get the default query grammar instance.
*
* @return \Firebird\Query\Grammars\FirebirdGrammar
* @return \Firebird\Query\Grammars\Firebird1Grammar|\Firebird\Query\Grammars\Firebird2Grammar
*/
protected function getDefaultQueryGrammar()
{
if ($this->getFirebirdVersion() == Version::FIREBIRD_15) {
return new Firebird1QueryGrammar;
switch ($this->getDatabaseVersion()) {
case Version::FIREBIRD_15:
return new Firebird1QueryGrammar;
case Version::FIREBIRD_25:
return new Firebird2QueryGrammar;
}

return new Firebird2QueryGrammar;
}

/**
Expand All @@ -51,28 +52,16 @@ protected function getDefaultSchemaGrammar()
return $this->withTablePrefix(new FirebirdSchemaGrammar);
}

/**
* Get query builder.
*
* @return \Firebird\Query\Builder
*/
protected function getQueryBuilder()
{
return new FirebirdQueryBuilder(
$this,
$this->getQueryGrammar(),
$this->getPostProcessor()
);
}

/**
* Get a new query builder instance.
*
* @return \Firebird\Query\Builder
*/
public function query()
{
return $this->getQueryBuilder();
return new FirebirdQueryBuilder(
$this, $this->getQueryGrammar(), $this->getPostProcessor()
);
}

/**
Expand All @@ -93,15 +82,15 @@ public function executeProcedure($procedure, array $values = [])
*
* @return string
*/
protected function getFirebirdVersion()
protected function getDatabaseVersion()
{
if (! array_key_exists('version', $this->config)) {
return Version::FIREBIRD_25;
}

// Check the user has provided a supported version.
if (! in_array($this->config['version'], Version::SUPPORTED_VERSIONS)) {
throw new Exception('The Firebird version provided is not supported.');
throw new Exception('The Firebird database version provided is not supported.');
}

return $this->config['version'];
Expand Down
1 change: 0 additions & 1 deletion src/FirebirdServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Firebird;

use Firebird\Connection as FirebirdConnection;
use Illuminate\Database\Connection;
use Illuminate\Support\ServiceProvider;

Expand Down

0 comments on commit 86eda40

Please sign in to comment.