diff --git a/Tests/Mock/Driver.php b/Tests/Mock/Driver.php index 965cf4e9..7018c1eb 100644 --- a/Tests/Mock/Driver.php +++ b/Tests/Mock/Driver.php @@ -113,11 +113,11 @@ public static function create(\PHPUnit_Framework_TestCase $test, $nullDate = '00 $mockObject, $test, array( - 'escape' => array((is_callable(array($test, 'mockEscape')) ? $test : __CLASS__), 'mockEscape'), - 'getQuery' => array((is_callable(array($test, 'mockGetQuery')) ? $test : __CLASS__), 'mockGetQuery'), - 'quote' => array((is_callable(array($test, 'mockQuote')) ? $test : __CLASS__), 'mockQuote'), - 'quoteName' => array((is_callable(array($test, 'mockQuoteName')) ? $test : __CLASS__), 'mockQuoteName'), - 'setQuery' => array((is_callable(array($test, 'mockSetQuery')) ? $test : __CLASS__), 'mockSetQuery'), + 'escape' => array(is_callable(array($test, 'mockEscape')) ? $test : __CLASS__, 'mockEscape'), + 'getQuery' => array(is_callable(array($test, 'mockGetQuery')) ? $test : __CLASS__, 'mockGetQuery'), + 'quote' => array(is_callable(array($test, 'mockQuote')) ? $test : __CLASS__, 'mockQuote'), + 'quoteName' => array(is_callable(array($test, 'mockQuoteName')) ? $test : __CLASS__, 'mockQuoteName'), + 'setQuery' => array(is_callable(array($test, 'mockSetQuery')) ? $test : __CLASS__, 'mockSetQuery'), ) ); diff --git a/Tests/QueryElementTest.php b/Tests/QueryElementTest.php index 0d6c9a30..2a002e98 100644 --- a/Tests/QueryElementTest.php +++ b/Tests/QueryElementTest.php @@ -241,7 +241,7 @@ public function test__clone_array() $baseElement->testArray = array(); - $cloneElement = clone($baseElement); + $cloneElement = clone $baseElement; $baseElement->testArray[] = 'a'; @@ -262,7 +262,7 @@ public function test__clone_object() $baseElement->testObject = new \stdClass; - $cloneElement = clone($baseElement); + $cloneElement = clone $baseElement; $this->assertFalse($baseElement === $cloneElement); $this->assertFalse($baseElement->testObject === $cloneElement->testObject); diff --git a/Tests/QueryTest.php b/Tests/QueryTest.php index f8e174c2..45074dc5 100644 --- a/Tests/QueryTest.php +++ b/Tests/QueryTest.php @@ -1736,7 +1736,7 @@ public function test__clone_array() $baseElement->testArray = array(); - $cloneElement = clone($baseElement); + $cloneElement = clone $baseElement; $baseElement->testArray[] = 'test'; @@ -1765,7 +1765,7 @@ public function test__clone_object() $baseElement->testObject = new \stdClass; - $cloneElement = clone($baseElement); + $cloneElement = clone $baseElement; $this->assertThat( TestHelper::getValue($baseElement, 'db'), diff --git a/Tests/Stubs/nosqldriver.php b/Tests/Stubs/nosqldriver.php index 74d4ba90..8f29a4b8 100644 --- a/Tests/Stubs/nosqldriver.php +++ b/Tests/Stubs/nosqldriver.php @@ -83,7 +83,6 @@ public function connected() */ public function disconnect() { - return; } /** diff --git a/src/DatabaseDriver.php b/src/DatabaseDriver.php index 96b39f7f..e6f884a3 100644 --- a/src/DatabaseDriver.php +++ b/src/DatabaseDriver.php @@ -238,7 +238,7 @@ public static function getConnectors() $class = '\\Joomla\\Database\\' . ucfirst(strtolower($baseName)) . '\\' . ucfirst(strtolower($baseName)) . 'Driver'; // If the class doesn't exist, or if it's not supported on this system, move on to the next type. - if (!class_exists($class) || !($class::isSupported())) + if (!class_exists($class) || !$class::isSupported()) { continue; } @@ -271,9 +271,9 @@ public static function getConnectors() public static function getInstance($options = array()) { // Sanitize the database connector options. - $options['driver'] = (isset($options['driver'])) ? preg_replace('/[^A-Z0-9_\.-]/i', '', $options['driver']) : 'mysqli'; - $options['database'] = (isset($options['database'])) ? $options['database'] : null; - $options['select'] = (isset($options['select'])) ? $options['select'] : true; + $options['driver'] = isset($options['driver']) ? preg_replace('/[^A-Z0-9_\.-]/i', '', $options['driver']) : 'mysqli'; + $options['database'] = isset($options['database']) ? $options['database'] : null; + $options['select'] = isset($options['select']) ? $options['select'] : true; // Get the options signature for the database connector. $signature = md5(serialize($options)); @@ -397,7 +397,7 @@ public static function splitSql($sql) if ($comment && $start < $i) { - $query .= substr($sql, $start, ($i - $start)); + $query .= substr($sql, $start, $i - $start); } } } @@ -412,7 +412,7 @@ public static function splitSql($sql) { if ($start <= $i) { - $query .= substr($sql, $start, ($i - $start + 1)); + $query .= substr($sql, $start, $i - $start + 1); } $query = trim($query); @@ -502,9 +502,9 @@ public function __get($name) public function __construct($options) { // Initialise object variables. - $this->database = (isset($options['database'])) ? $options['database'] : ''; + $this->database = isset($options['database']) ? $options['database'] : ''; - $this->tablePrefix = (isset($options['prefix'])) ? $options['prefix'] : 'jos_'; + $this->tablePrefix = isset($options['prefix']) ? $options['prefix'] : 'jos_'; $this->count = 0; $this->errorNum = 0; @@ -1151,7 +1151,7 @@ public function loadAssocList($key = null, $column = null) // Get all of the rows from the result set. while ($row = $this->fetchAssoc($cursor)) { - $value = ($column) ? (isset($row[$column]) ? $row[$column] : $row) : $row; + $value = $column ? (isset($row[$column]) ? $row[$column] : $row) : $row; if ($key) { @@ -1898,5 +1898,5 @@ abstract public function execute(); * @since 1.0 * @throws \RuntimeException */ - public abstract function unlockTables(); + abstract public function unlockTables(); } diff --git a/src/DatabaseFactory.php b/src/DatabaseFactory.php index 5e609a7a..b7140246 100644 --- a/src/DatabaseFactory.php +++ b/src/DatabaseFactory.php @@ -42,8 +42,8 @@ public function getDriver($name = 'mysqli', $options = array()) { // Sanitize the database connector options. $options['driver'] = preg_replace('/[^A-Z0-9_\.-]/i', '', $name); - $options['database'] = (isset($options['database'])) ? $options['database'] : null; - $options['select'] = (isset($options['select'])) ? $options['select'] : true; + $options['database'] = isset($options['database']) ? $options['database'] : null; + $options['select'] = isset($options['select']) ? $options['select'] : true; // Derive the class name from the driver. $class = __NAMESPACE__ . '\\' . ucfirst(strtolower($options['driver'])) . '\\' . ucfirst(strtolower($options['driver'])) . 'Driver'; diff --git a/src/Mysql/MysqlDriver.php b/src/Mysql/MysqlDriver.php index 1b3ca9c9..c362e4f3 100644 --- a/src/Mysql/MysqlDriver.php +++ b/src/Mysql/MysqlDriver.php @@ -75,7 +75,7 @@ public function __construct($options) { // Get some basic values from the options. $options['driver'] = 'mysql'; - $options['charset'] = (isset($options['charset'])) ? $options['charset'] : 'utf8'; + $options['charset'] = isset($options['charset']) ? $options['charset'] : 'utf8'; $this->charset = $options['charset']; @@ -355,9 +355,7 @@ public function getTableKeys($table) // Get the details columns information. $this->setQuery('SHOW KEYS FROM ' . $this->quoteName($table)); - $keys = $this->loadObjectList(); - - return $keys; + return $this->loadObjectList(); } /** @@ -374,9 +372,8 @@ public function getTableList() // Set the query to get the tables statement. $this->setQuery('SHOW TABLES'); - $tables = $this->loadColumn(); - return $tables; + return $this->loadColumn(); } /** diff --git a/src/Mysql/MysqlImporter.php b/src/Mysql/MysqlImporter.php index ab1fd7cc..8d10deb9 100644 --- a/src/Mysql/MysqlImporter.php +++ b/src/Mysql/MysqlImporter.php @@ -286,9 +286,7 @@ protected function getDropKeySql($table, $name) */ protected function getDropPrimaryKeySql($table) { - $sql = 'ALTER TABLE ' . $this->db->quoteName($table) . ' DROP PRIMARY KEY'; - - return $sql; + return 'ALTER TABLE ' . $this->db->quoteName($table) . ' DROP PRIMARY KEY'; } /** diff --git a/src/Mysqli/MysqliDriver.php b/src/Mysqli/MysqliDriver.php index c0746f0a..951c0f08 100644 --- a/src/Mysqli/MysqliDriver.php +++ b/src/Mysqli/MysqliDriver.php @@ -103,14 +103,14 @@ class MysqliDriver extends DatabaseDriver public function __construct($options) { // Get some basic values from the options. - $options['host'] = (isset($options['host'])) ? $options['host'] : 'localhost'; - $options['user'] = (isset($options['user'])) ? $options['user'] : 'root'; - $options['password'] = (isset($options['password'])) ? $options['password'] : ''; - $options['database'] = (isset($options['database'])) ? $options['database'] : ''; - $options['select'] = (isset($options['select'])) ? (bool) $options['select'] : true; - $options['port'] = (isset($options['port'])) ? (int) $options['port'] : null; - $options['socket'] = (isset($options['socket'])) ? $options['socket'] : null; - $options['utf8mb4'] = (isset($options['utf8mb4'])) ? (bool) $options['utf8mb4'] : false; + $options['host'] = isset($options['host']) ? $options['host'] : 'localhost'; + $options['user'] = isset($options['user']) ? $options['user'] : 'root'; + $options['password'] = isset($options['password']) ? $options['password'] : ''; + $options['database'] = isset($options['database']) ? $options['database'] : ''; + $options['select'] = isset($options['select']) ? (bool) $options['select'] : true; + $options['port'] = isset($options['port']) ? (int) $options['port'] : null; + $options['socket'] = isset($options['socket']) ? $options['socket'] : null; + $options['utf8mb4'] = isset($options['utf8mb4']) ? (bool) $options['utf8mb4'] : false; // Finalize initialisation. parent::__construct($options); @@ -506,9 +506,8 @@ public function getTableKeys($table) // Get the details columns information. $this->setQuery('SHOW KEYS FROM ' . $this->quoteName($table)); - $keys = $this->loadObjectList(); - return $keys; + return $this->loadObjectList(); } /** @@ -525,9 +524,8 @@ public function getTableList() // Set the query to get the tables statement. $this->setQuery('SHOW TABLES'); - $tables = $this->loadColumn(); - return $tables; + return $this->loadColumn(); } /** diff --git a/src/Mysqli/MysqliImporter.php b/src/Mysqli/MysqliImporter.php index c8be444d..69134cd1 100644 --- a/src/Mysqli/MysqliImporter.php +++ b/src/Mysqli/MysqliImporter.php @@ -348,9 +348,7 @@ protected function getDropKeySql($table, $name) */ protected function getDropPrimaryKeySql($table) { - $sql = 'ALTER TABLE ' . $this->db->quoteName($table) . ' DROP PRIMARY KEY'; - - return $sql; + return 'ALTER TABLE ' . $this->db->quoteName($table) . ' DROP PRIMARY KEY'; } /** diff --git a/src/Oracle/OracleDriver.php b/src/Oracle/OracleDriver.php index 8196e3f2..483562a8 100644 --- a/src/Oracle/OracleDriver.php +++ b/src/Oracle/OracleDriver.php @@ -63,8 +63,8 @@ class OracleDriver extends PdoDriver public function __construct($options) { $options['driver'] = 'oci'; - $options['charset'] = (isset($options['charset'])) ? $options['charset'] : 'AL32UTF8'; - $options['dateformat'] = (isset($options['dateformat'])) ? $options['dateformat'] : 'RRRR-MM-DD HH24:MI:SS'; + $options['charset'] = isset($options['charset']) ? $options['charset'] : 'AL32UTF8'; + $options['dateformat'] = isset($options['dateformat']) ? $options['dateformat'] : 'RRRR-MM-DD HH24:MI:SS'; $this->charset = $options['charset']; $this->dateformat = $options['dateformat']; diff --git a/src/Pdo/PdoDriver.php b/src/Pdo/PdoDriver.php index 8afd71e0..a28b9e2a 100644 --- a/src/Pdo/PdoDriver.php +++ b/src/Pdo/PdoDriver.php @@ -78,14 +78,14 @@ abstract class PdoDriver extends DatabaseDriver public function __construct($options) { // Get some basic values from the options. - $options['driver'] = (isset($options['driver'])) ? $options['driver'] : 'odbc'; - $options['dsn'] = (isset($options['dsn'])) ? $options['dsn'] : ''; - $options['host'] = (isset($options['host'])) ? $options['host'] : 'localhost'; - $options['database'] = (isset($options['database'])) ? $options['database'] : ''; - $options['user'] = (isset($options['user'])) ? $options['user'] : ''; - $options['port'] = (isset($options['port'])) ? (int) $options['port'] : null; - $options['password'] = (isset($options['password'])) ? $options['password'] : ''; - $options['driverOptions'] = (isset($options['driverOptions'])) ? $options['driverOptions'] : array(); + $options['driver'] = isset($options['driver']) ? $options['driver'] : 'odbc'; + $options['dsn'] = isset($options['dsn']) ? $options['dsn'] : ''; + $options['host'] = isset($options['host']) ? $options['host'] : 'localhost'; + $options['database'] = isset($options['database']) ? $options['database'] : ''; + $options['user'] = isset($options['user']) ? $options['user'] : ''; + $options['port'] = isset($options['port']) ? (int) $options['port'] : null; + $options['password'] = isset($options['password']) ? $options['password'] : ''; + $options['driverOptions'] = isset($options['driverOptions']) ? $options['driverOptions'] : array(); // Finalize initialisation parent::__construct($options); @@ -126,113 +126,119 @@ public function connect() switch ($this->options['driver']) { case 'cubrid': - $this->options['port'] = (isset($this->options['port'])) ? $this->options['port'] : 33000; + $this->options['port'] = isset($this->options['port']) ? $this->options['port'] : 33000; $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; case 'dblib': - $this->options['port'] = (isset($this->options['port'])) ? $this->options['port'] : 1433; + $this->options['port'] = isset($this->options['port']) ? $this->options['port'] : 1433; $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; case 'firebird': - $this->options['port'] = (isset($this->options['port'])) ? $this->options['port'] : 3050; + $this->options['port'] = isset($this->options['port']) ? $this->options['port'] : 3050; $format = 'firebird:dbname=#DBNAME#'; $replace = array('#DBNAME#'); - $with = array($this->options['database']); + $with = array($this->options['database']); break; case 'ibm': - $this->options['port'] = (isset($this->options['port'])) ? $this->options['port'] : 56789; + $this->options['port'] = isset($this->options['port']) ? $this->options['port'] : 56789; if (!empty($this->options['dsn'])) { $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['protocol'] = (isset($this->options['protocol'])) ? $this->options['protocol'] : 'onsoctcp'; + $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; case 'mssql': - $this->options['port'] = (isset($this->options['port'])) ? $this->options['port'] : 1433; + $this->options['port'] = isset($this->options['port']) ? $this->options['port'] : 1433; $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; case 'mysql': - $this->options['port'] = (isset($this->options['port'])) ? $this->options['port'] : 3306; + $this->options['port'] = isset($this->options['port']) ? $this->options['port'] : 3306; $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['charset'] = (isset($this->options['charset'])) ? $this->options['charset'] : 'AL32UTF8'; + $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']; @@ -243,17 +249,17 @@ 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; case 'pgsql': - $this->options['port'] = (isset($this->options['port'])) ? $this->options['port'] : 5432; + $this->options['port'] = isset($this->options['port']) ? $this->options['port'] : 5432; $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; @@ -268,17 +274,17 @@ public function connect() } $replace = array('#DBNAME#'); - $with = array($this->options['database']); + $with = array($this->options['database']); break; case 'sybase': - $this->options['port'] = (isset($this->options['port'])) ? $this->options['port'] : 1433; + $this->options['port'] = isset($this->options['port']) ? $this->options['port'] : 1433; $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; @@ -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 @@ -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; @@ -897,7 +903,7 @@ public function loadNextAssoc() // Execute the query and get the result set cursor. if (!$this->executed) { - if (!($this->execute())) + if (!$this->execute()) { return $this->errorNum ? null : false; } diff --git a/src/Pgsql/PgsqlDriver.php b/src/Pgsql/PgsqlDriver.php index f26fab43..8b080978 100644 --- a/src/Pgsql/PgsqlDriver.php +++ b/src/Pgsql/PgsqlDriver.php @@ -72,11 +72,11 @@ class PgsqlDriver extends PdoDriver public function __construct($options) { $options['driver'] = 'pgsql'; - $options['host'] = (isset($options['host'])) ? $options['host'] : 'localhost'; - $options['user'] = (isset($options['user'])) ? $options['user'] : ''; - $options['password'] = (isset($options['password'])) ? $options['password'] : ''; - $options['database'] = (isset($options['database'])) ? $options['database'] : ''; - $options['port'] = (isset($options['port'])) ? $options['port'] : null; + $options['host'] = isset($options['host']) ? $options['host'] : 'localhost'; + $options['user'] = isset($options['user']) ? $options['user'] : ''; + $options['password'] = isset($options['password']) ? $options['password'] : ''; + $options['database'] = isset($options['database']) ? $options['database'] : ''; + $options['port'] = isset($options['port']) ? $options['port'] : null; // Finalize initialization parent::__construct($options); diff --git a/src/Postgresql/PostgresqlDriver.php b/src/Postgresql/PostgresqlDriver.php index ebf91590..9dea0bfb 100644 --- a/src/Postgresql/PostgresqlDriver.php +++ b/src/Postgresql/PostgresqlDriver.php @@ -109,11 +109,11 @@ class PostgresqlDriver extends DatabaseDriver */ public function __construct( $options ) { - $options['host'] = (isset($options['host'])) ? $options['host'] : 'localhost'; - $options['user'] = (isset($options['user'])) ? $options['user'] : ''; - $options['password'] = (isset($options['password'])) ? $options['password'] : ''; - $options['database'] = (isset($options['database'])) ? $options['database'] : ''; - $options['port'] = (isset($options['port'])) ? $options['port'] : null; + $options['host'] = isset($options['host']) ? $options['host'] : 'localhost'; + $options['user'] = isset($options['user']) ? $options['user'] : ''; + $options['password'] = isset($options['password']) ? $options['password'] : ''; + $options['database'] = isset($options['database']) ? $options['database'] : ''; + $options['port'] = isset($options['port']) ? $options['port'] : null; // Finalize initialization parent::__construct($options); @@ -156,7 +156,7 @@ public function connect() */ // Check for empty port - if (!($this->options['port'])) + if (!$this->options['port']) { // Port is empty or not set via options, check for port annotation (:) in the host string $tmp = substr(strstr($this->options['host'], ':'), 1); @@ -486,13 +486,13 @@ public function getTableColumns($table, $typeOnly = true) // @todo: Come up with and implement a standard across databases. $result[$field->column_name] = (object) array( 'column_name' => $field->column_name, - 'type' => $field->type, - 'null' => $field->null, - 'Default' => $field->Default, - 'comments' => '', - 'Field' => $field->column_name, - 'Type' => $field->type, - 'Null' => $field->null, + 'type' => $field->type, + 'null' => $field->null, + 'Default' => $field->Default, + 'comments' => '', + 'Field' => $field->column_name, + 'Type' => $field->type, + 'Null' => $field->null, // @todo: Improve query above to return primary key info as well // 'Key' => ($field->PK == '1' ? 'PRI' : '') ); @@ -543,9 +543,8 @@ public function getTableKeys($table) LEFT JOIN pg_index AS pgIndex ON pgClassFirst.oid=pgIndex.indexrelid WHERE tablename=' . $this->quote($table) . ' ORDER BY indkey' ); - $keys = $this->loadObjectList(); - return $keys; + return $this->loadObjectList(); } return false; @@ -573,9 +572,8 @@ public function getTableList() ->order('table_name ASC'); $this->setQuery($query); - $tables = $this->loadColumn(); - return $tables; + return $this->loadColumn(); } /** @@ -619,9 +617,8 @@ public function getTableSequences($table) ->leftJoin('information_schema.sequences AS info ON info.sequence_name=s.relname') ->where("s.relkind='S' AND d.deptype='a' AND t.relname=" . $this->quote($table)); $this->setQuery($query); - $seq = $this->loadObjectList(); - return $seq; + return $this->loadObjectList(); } return false; @@ -676,7 +673,7 @@ public function insertid() { $this->connect(); $insertQuery = $this->getQuery(false, true); - $table = $insertQuery->insert->getElements(); + $table = $insertQuery->insert->getElements(); /* find sequence column name */ $colNameQuery = $this->getQuery(true); @@ -690,7 +687,7 @@ public function insertid() ->where("column_default LIKE '%nextval%'"); $this->setQuery($colNameQuery); - $colName = $this->loadRow(); + $colName = $this->loadRow(); $changedColName = str_replace('nextval', 'currval', $colName); $insertidQuery = $this->getQuery(true); @@ -1289,7 +1286,7 @@ public function insertObject($table, &$object, $key = null) */ public static function isSupported() { - return (function_exists('pg_connect')); + return function_exists('pg_connect'); } /** @@ -1312,9 +1309,8 @@ public function showTables() ); $this->setQuery($query); - $tableList = $this->loadColumn(); - return $tableList; + return $this->loadColumn(); } /** diff --git a/src/Postgresql/PostgresqlImporter.php b/src/Postgresql/PostgresqlImporter.php index 5dadaae4..83511633 100644 --- a/src/Postgresql/PostgresqlImporter.php +++ b/src/Postgresql/PostgresqlImporter.php @@ -244,9 +244,7 @@ protected function getAlterTableSql(\SimpleXMLElement $structure) */ protected function getDropSequenceSql($name) { - $sql = 'DROP SEQUENCE ' . $this->db->quoteName($name); - - return $sql; + return 'DROP SEQUENCE ' . $this->db->quoteName($name); } /** @@ -445,9 +443,7 @@ protected function getColumnSql(\SimpleXMLElement $field) */ protected function getDropIndexSql($name) { - $sql = 'DROP INDEX ' . $this->db->quoteName($name); - - return $sql; + return 'DROP INDEX ' . $this->db->quoteName($name); } /** diff --git a/src/Sqlite/SqliteDriver.php b/src/Sqlite/SqliteDriver.php index aa316763..02ce07c8 100644 --- a/src/Sqlite/SqliteDriver.php +++ b/src/Sqlite/SqliteDriver.php @@ -199,9 +199,9 @@ public function getTableColumns($table, $typeOnly = true) $columns[$field->NAME] = (object) array( 'Field' => $field->NAME, 'Type' => $field->TYPE, - 'Null' => ($field->NOTNULL == '1' ? 'NO' : 'YES'), + 'Null' => $field->NOTNULL == '1' ? 'NO' : 'YES', 'Default' => $field->DFLT_VALUE, - 'Key' => ($field->PK != '0' ? 'PRI' : ''), + 'Key' => $field->PK != '0' ? 'PRI' : '', ); } } @@ -278,9 +278,7 @@ public function getTableList() $this->setQuery($query); - $tables = $this->loadColumn(); - - return $tables; + return $this->loadColumn(); } /** diff --git a/src/Sqlsrv/SqlsrvDriver.php b/src/Sqlsrv/SqlsrvDriver.php index c0ddd699..289e06ac 100644 --- a/src/Sqlsrv/SqlsrvDriver.php +++ b/src/Sqlsrv/SqlsrvDriver.php @@ -83,11 +83,11 @@ public static function isSupported() public function __construct($options) { // Get some basic values from the options. - $options['host'] = (isset($options['host'])) ? $options['host'] : 'localhost'; - $options['user'] = (isset($options['user'])) ? $options['user'] : ''; - $options['password'] = (isset($options['password'])) ? $options['password'] : ''; - $options['database'] = (isset($options['database'])) ? $options['database'] : ''; - $options['select'] = (isset($options['select'])) ? (bool) $options['select'] : true; + $options['host'] = isset($options['host']) ? $options['host'] : 'localhost'; + $options['user'] = isset($options['user']) ? $options['user'] : ''; + $options['password'] = isset($options['password']) ? $options['password'] : ''; + $options['database'] = isset($options['database']) ? $options['database'] : ''; + $options['select'] = isset($options['select']) ? (bool) $options['select'] : true; // Finalize initialisation parent::__construct($options); @@ -123,11 +123,12 @@ public function connect() // Build the connection configuration array. $config = array( - 'Database' => $this->options['database'], - 'uid' => $this->options['user'], - 'pwd' => $this->options['password'], - 'CharacterSet' => 'UTF-8', - 'ReturnDatesAsStrings' => true); + 'Database' => $this->options['database'], + 'uid' => $this->options['user'], + 'pwd' => $this->options['password'], + 'CharacterSet' => 'UTF-8', + 'ReturnDatesAsStrings' => true + ); // Make sure the SQLSRV extension for PHP is installed and enabled. if (!static::isSupported()) @@ -469,9 +470,8 @@ public function getTableList() // Set the query to get the tables statement. $this->setQuery('SELECT name FROM ' . $this->getDatabase() . '.sys.Tables WHERE type = \'U\';'); - $tables = $this->loadColumn(); - return $tables; + return $this->loadColumn(); } /**