Skip to content

Commit

Permalink
Code style
Browse files Browse the repository at this point in the history
  • Loading branch information
frankmayer committed Jun 26, 2017
1 parent 8d81da2 commit 9265441
Showing 1 changed file with 31 additions and 25 deletions.
56 changes: 31 additions & 25 deletions src/Pdo/PdoDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public function connect()
$format = 'cubrid:host=#HOST#;port=#PORT#;dbname=#DBNAME#';

$replace = array('#HOST#', '#PORT#', '#DBNAME#');
$with = array($this->options['host'], $this->options['port'], $this->options['database']);
$with = array($this->options['host'], $this->options['port'], $this->options['database']);

break;

Expand All @@ -141,7 +141,7 @@ public function connect()
$format = 'dblib:host=#HOST#;port=#PORT#;dbname=#DBNAME#';

$replace = array('#HOST#', '#PORT#', '#DBNAME#');
$with = array($this->options['host'], $this->options['port'], $this->options['database']);
$with = array($this->options['host'], $this->options['port'], $this->options['database']);

break;

Expand All @@ -151,7 +151,7 @@ public function connect()
$format = 'firebird:dbname=#DBNAME#';

$replace = array('#DBNAME#');
$with = array($this->options['database']);
$with = array($this->options['database']);

break;

Expand All @@ -163,35 +163,41 @@ public function connect()
$format = 'ibm:DSN=#DSN#';

$replace = array('#DSN#');
$with = array($this->options['dsn']);
$with = array($this->options['dsn']);
}
else
{
$format = 'ibm:hostname=#HOST#;port=#PORT#;database=#DBNAME#';

$replace = array('#HOST#', '#PORT#', '#DBNAME#');
$with = array($this->options['host'], $this->options['port'], $this->options['database']);
$with = array($this->options['host'], $this->options['port'], $this->options['database']);
}

break;

case 'informix':
$this->options['port'] = isset($this->options['port']) ? $this->options['port'] : 1526;
$this->options['port'] = isset($this->options['port']) ? $this->options['port'] : 1526;
$this->options['protocol'] = isset($this->options['protocol']) ? $this->options['protocol'] : 'onsoctcp';

if (!empty($this->options['dsn']))
{
$format = 'informix:DSN=#DSN#';

$replace = array('#DSN#');
$with = array($this->options['dsn']);
$with = array($this->options['dsn']);
}
else
{
$format = 'informix:host=#HOST#;service=#PORT#;database=#DBNAME#;server=#SERVER#;protocol=#PROTOCOL#';

$replace = array('#HOST#', '#PORT#', '#DBNAME#', '#SERVER#', '#PROTOCOL#');
$with = array($this->options['host'], $this->options['port'], $this->options['database'], $this->options['server'], $this->options['protocol']);
$with = array(
$this->options['host'],
$this->options['port'],
$this->options['database'],
$this->options['server'],
$this->options['protocol']
);
}

break;
Expand All @@ -202,7 +208,7 @@ public function connect()
$format = 'mssql:host=#HOST#;port=#PORT#;dbname=#DBNAME#';

$replace = array('#HOST#', '#PORT#', '#DBNAME#');
$with = array($this->options['host'], $this->options['port'], $this->options['database']);
$with = array($this->options['host'], $this->options['port'], $this->options['database']);

break;

Expand All @@ -212,27 +218,27 @@ public function connect()
$format = 'mysql:host=#HOST#;port=#PORT#;dbname=#DBNAME#;charset=#CHARSET#';

$replace = array('#HOST#', '#PORT#', '#DBNAME#', '#CHARSET#');
$with = array($this->options['host'], $this->options['port'], $this->options['database'], $this->options['charset']);
$with = array($this->options['host'], $this->options['port'], $this->options['database'], $this->options['charset']);

break;

case 'oci':
$this->options['port'] = isset($this->options['port']) ? $this->options['port'] : 1521;
$this->options['port'] = isset($this->options['port']) ? $this->options['port'] : 1521;
$this->options['charset'] = isset($this->options['charset']) ? $this->options['charset'] : 'AL32UTF8';

if (!empty($this->options['dsn']))
{
$format = 'oci:dbname=#DSN#';

$replace = array('#DSN#');
$with = array($this->options['dsn']);
$with = array($this->options['dsn']);
}
else
{
$format = 'oci:dbname=//#HOST#:#PORT#/#DBNAME#';

$replace = array('#HOST#', '#PORT#', '#DBNAME#');
$with = array($this->options['host'], $this->options['port'], $this->options['database']);
$with = array($this->options['host'], $this->options['port'], $this->options['database']);
}

$format .= ';charset=' . $this->options['charset'];
Expand All @@ -243,7 +249,7 @@ public function connect()
$format = 'odbc:DSN=#DSN#;UID:#USER#;PWD=#PASSWORD#';

$replace = array('#DSN#', '#USER#', '#PASSWORD#');
$with = array($this->options['dsn'], $this->options['user'], $this->options['password']);
$with = array($this->options['dsn'], $this->options['user'], $this->options['password']);

break;

Expand All @@ -253,7 +259,7 @@ public function connect()
$format = 'pgsql:host=#HOST#;port=#PORT#;dbname=#DBNAME#';

$replace = array('#HOST#', '#PORT#', '#DBNAME#');
$with = array($this->options['host'], $this->options['port'], $this->options['database']);
$with = array($this->options['host'], $this->options['port'], $this->options['database']);

break;

Expand All @@ -268,7 +274,7 @@ public function connect()
}

$replace = array('#DBNAME#');
$with = array($this->options['database']);
$with = array($this->options['database']);

break;

Expand All @@ -278,7 +284,7 @@ public function connect()
$format = 'mssql:host=#HOST#;port=#PORT#;dbname=#DBNAME#';

$replace = array('#HOST#', '#PORT#', '#DBNAME#');
$with = array($this->options['host'], $this->options['port'], $this->options['database']);
$with = array($this->options['host'], $this->options['port'], $this->options['database']);

break;

Expand Down Expand Up @@ -564,9 +570,9 @@ public function connected()
}

// Backup the query state.
$sql = $this->sql;
$limit = $this->limit;
$offset = $this->offset;
$sql = $this->sql;
$limit = $this->limit;
$offset = $this->offset;
$prepared = $this->prepared;

try
Expand All @@ -579,16 +585,16 @@ public function connected()
$status = (bool) $this->loadResult();
}
catch (\Exception $e)
// If we catch an exception here, we must not be connected.
// If we catch an exception here, we must not be connected.
{
$status = false;
}

// Restore the query state.
$this->sql = $sql;
$this->limit = $limit;
$this->offset = $offset;
$this->prepared = $prepared;
$this->sql = $sql;
$this->limit = $limit;
$this->offset = $offset;
$this->prepared = $prepared;
$checkingConnected = false;

return $status;
Expand Down

0 comments on commit 9265441

Please sign in to comment.