Permalink
Browse files

Applying second round of review comments from pull request 188.

  • Loading branch information...
posulliv committed Aug 25, 2012
1 parent 6003fae commit af23244069516d4f0cef2096966a801690774637
@@ -58,8 +58,7 @@ public function __construct($connectionString)
public function prepare($prepareString)
{
return new AkibanSrvStatement($this->connectionHandle,
- $prepareString,
- $this);
+ $prepareString);
}
/**
@@ -50,13 +50,6 @@ class AkibanSrvStatement implements IteratorAggregate, Statement
*/
private $results;
- /**
- * Akiban Server connection object.
- *
- * @var resource
- */
- private $connection;
-
/**
* An array of the parameters for this statement.
*/
@@ -80,12 +73,10 @@ class AkibanSrvStatement implements IteratorAggregate, Statement
);
public function __construct($connectionHandle,
- $statement,
- AkibanSrvConnection $connection)
+ $statement)
{
$this->statement = $this->convertPositionalToNumberedParameters($statement);
$this->connectionHandle = $connectionHandle;
- $this->connection = $connection;
$this->results = false;
$this->className = null;
$this->constructorArguments = null;
@@ -188,26 +179,24 @@ public function errorInfo()
*/
public function execute($params = null)
{
- $noExistingParameters = empty($this->parameters) ? true : false;
- $parametersPassed = null !== $params ? true : false;
- if ($noExistingParameters && ! $parametersPassed) {
- return $this->executeQuery($this->connectionHandle, $this->statement);
+ if ( ! empty($this->parameters)) {
+ return $this->executeParameterizedQuery($this->statement, $this->parameters);
}
- if ($noExistingParameters && $parametersPassed) {
- return $this->executeParameterizedQuery($this->connectionHandle, $this->statement, $params);
+ if (null !== $params) {
+ return $this->executeParameterizedQuery($this->statement, $params);
}
- return $this->executeParameterizedQuery($this->connectionHandle, $this->statement, $this->parameters);
+ return $this->executeQuery($this->statement);
}
- private function executeParameterizedQuery($connectionHandle, $statement, $parameters)
+ private function executeParameterizedQuery($statement, $parameters)
{
- $this->results = pg_query_params($connectionHandle, $statement, $parameters);
+ $this->results = pg_query_params($this->connectionHandle, $statement, $parameters);
return $this->results;
}
- private function executeQuery($connectionHandle, $statement)
+ private function executeQuery($statement)
{
- $this->results = pg_query($connectionHandle, $statement);
+ $this->results = pg_query($this->connectionHandle, $statement);
return $this->results;
}
@@ -239,7 +228,7 @@ public function getIterator()
*/
public function fetch($fetchMode = null, $rowPos = null)
{
- $fetchMode = $fetchMode ? : $this->defaultFetchMode;
+ $fetchMode = $fetchMode ?: $this->defaultFetchMode;
if (! isset(self::$fetchModeMap[$fetchMode])) {
throw new \InvalidArgumentException("Invalid fetch style: " . $fetchMode);
@@ -262,7 +251,7 @@ public function fetch($fetchMode = null, $rowPos = null)
*/
public function fetchAll($fetchMode = null)
{
- $fetchMode = $fetchMode ? : $this->defaultFetchMode;
+ $fetchMode = $fetchMode ?: $this->defaultFetchMode;
if (! isset(self::$fetchModeMap[$fetchMode])) {
throw new \InvalidArgumentException("Invalid fetch mode: " . $fetchMode);
@@ -19,6 +19,7 @@
namespace Doctrine\DBAL\Driver\AkibanSrv;
+use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Platforms\AkibanServerPlatform;
use Doctrine\DBAL\Schema\AkibanServerSchemaManager;
@@ -48,19 +49,19 @@ public function connect(array $params, $username = null, $password = null, array
private function constructConnectionString(array $params, $username, $password)
{
$connString = '';
- if (isset($params['host']) && $params['host'] !== '') {
+ if (! empty($params['host'])) {
$connString .= 'host=' . $params['host'] . ' ';
}
- if (isset($params['port']) && $params['port'] !== '') {
+ if (! empty($params['port'])) {
$connString .= 'port=' . $params['port'] . ' ';
}
- if (isset($params['dbname'])) {
+ if (! empty($params['dbname'])) {
$connString .= 'dbname=' . $params['dbname'] . ' ';
}
- if (isset($username)) {
+ if (! empty($username)) {
$connString .= 'user=' . $username . ' ';
}
- if (isset($password)) {
+ if (! empty($password)) {
$connString .= 'user=' . $username . ' ';
}
@@ -78,7 +79,7 @@ public function getDatabasePlatform()
/**
* {@inheritDoc}
*/
- public function getSchemaManager(\Doctrine\DBAL\Connection $conn)
+ public function getSchemaManager(Connection $conn)
{
return new AkibanServerSchemaManager($conn);
}
@@ -94,7 +95,7 @@ public function getName()
/**
* {@inheritDoc}
*/
- public function getDatabase(\Doctrine\DBAL\Connection $conn)
+ public function getDatabase(Connection $conn)
{
$params = $conn->getParams();
return $params['dbname'];
@@ -187,7 +187,7 @@ public function supportsForeignKeyConstraints()
*/
public function supportsForeignKeyOnUpdate()
{
- return ($this->supportsForeignKeyConstraints() && true);
+ return $this->supportsForeignKeyConstraints();
}
@@ -19,6 +19,9 @@
namespace Doctrine\DBAL\Schema;
+use Doctrine\DBAL\DriverManager;
+use Doctrine\DBAL\Types\Type;
+
/**
* Akiban Server Schema Manager
*
@@ -53,7 +56,7 @@ public function dropDatabase($database = null)
$tmpPlatform = $this->_platform;
$tmpConn = $this->_conn;
- $this->_conn = \Doctrine\DBAL\DriverManager::getConnection($params);
+ $this->_conn = DriverManager::getConnection($params);
$this->_platform = $this->_conn->getDatabasePlatform();
parent::dropDatabase($database);
@@ -205,12 +208,12 @@ protected function _getPortableTableColumnDefinition($tableColumn)
$tableColumn['default'] = $match[1];
}
- $tableColumn['nullable'] == 'NO' ? $notnull = true : $notnull = false;
- $tableColumn['index_type'] == 'PRIMARY' ? $primaryKey = true : $primaryKey = false;
+ $notNull = $tableColumn['nullable'] === 'NO';
+ $primaryKey = $tableColumn['index_type'] === 'PRIMARY';
$options = array(
'length' => $length,
- 'notnull' => $notnull,
+ 'notnull' => $notNull,
'default' => $tableColumn['default'],
'primary' => $primaryKey,
'precision' => $precision,
@@ -221,7 +224,7 @@ protected function _getPortableTableColumnDefinition($tableColumn)
'comment' => NULL,
);
- return new Column($tableColumn['column_name'], \Doctrine\DBAL\Types\Type::getType($type), $options);
+ return new Column($tableColumn['column_name'], Type::getType($type), $options);
}
}
@@ -5,8 +5,6 @@
use Doctrine\DBAL\Platforms\AkibanServerPlatform;
use Doctrine\DBAL\Types\Type;
-require_once __DIR__ . '/../../TestInit.php';
-
class AkibanSrvPlatformTest extends AbstractPlatformTestCase
{
public function createPlatform()

0 comments on commit af23244

Please sign in to comment.