diff --git a/src/Query/AbstractDriver.php b/src/Query/AbstractDriver.php index 6d13372..ecaabec 100644 --- a/src/Query/AbstractDriver.php +++ b/src/Query/AbstractDriver.php @@ -220,7 +220,10 @@ abstract class AbstractDriver extends \PDO implements DriverInterface { { // Parameters are 1-based, the data is 0-based // So, if the key is numeric, add 1 - if(is_numeric($k)) $k++; + if(is_numeric($k)) + { + $k++; + } $this->statement->bindValue($k, $value); } @@ -533,7 +536,10 @@ abstract class AbstractDriver extends \PDO implements DriverInterface { // Return if the values are returned instead of a query, // or if the query doesn't apply to the driver - if ( ! is_string($query)) return $query; + if ( ! is_string($query)) + { + return $query; + } // Run the query! $res = $this->query($query); diff --git a/src/Query/AbstractQueryBuilder.php b/src/Query/AbstractQueryBuilder.php index ddc1abf..555df93 100644 --- a/src/Query/AbstractQueryBuilder.php +++ b/src/Query/AbstractQueryBuilder.php @@ -229,7 +229,10 @@ abstract class AbstractQueryBuilder { // Escape the identifiers $field = $this->db->quote_ident($field); - if ( ! is_string($as)) return $field; + if ( ! is_string($as)) + { + return $field; + } $as = $this->db->quote_ident($as); @@ -251,7 +254,10 @@ abstract class AbstractQueryBuilder { $sql = $this->_compile($type, $table); // Reset the query builder for the next query - if ($reset) $this->reset_query(); + if ($reset) + { + $this->reset_query(); + } return $sql; } diff --git a/src/Query/ConnectionManager.php b/src/Query/ConnectionManager.php index 3117a2c..73ad086 100644 --- a/src/Query/ConnectionManager.php +++ b/src/Query/ConnectionManager.php @@ -87,7 +87,10 @@ final class ConnectionManager { */ public static function get_instance() { - if (self::$instance === null) self::$instance = new self(); + if (self::$instance === null) + { + self::$instance = new self(); + } return self::$instance; } diff --git a/src/Query/Drivers/Firebird/Driver.php b/src/Query/Drivers/Firebird/Driver.php index b7beb6b..4fac9e7 100644 --- a/src/Query/Drivers/Firebird/Driver.php +++ b/src/Query/Drivers/Firebird/Driver.php @@ -79,7 +79,7 @@ class Driver extends \Query\AbstractDriver { */ public function __construct($dbpath, $user='SYSDBA', $pass='masterkey', array $options = array()) { - $connect_function = (isset($options[\PDO::ATTR_PERSISTENT]) && $options[\PDO::ATTR_PERSISTENT] == TRUE) + $connect_function = (isset($options[\PDO::ATTR_PERSISTENT]) && $options[\PDO::ATTR_PERSISTENT]) ? '\\fbird_pconnect' : '\\fbird_connect'; @@ -87,7 +87,10 @@ class Driver extends \Query\AbstractDriver { $this->service = \fbird_service_attach('localhost', $user, $pass); // Throw an exception to make this match other pdo classes - if ( ! \is_resource($this->conn)) throw new \PDOException(\fbird_errmsg(), \fbird_errcode(), NULL); + if ( ! \is_resource($this->conn)) + { + throw new \PDOException(\fbird_errmsg(), \fbird_errcode(), NULL); + } // Load these classes here because this // driver does not call the constructor @@ -191,7 +194,10 @@ class Driver extends \Query\AbstractDriver { // Throw the error as a exception $err_string = \fbird_errmsg() . "Last query:" . $this->get_last_query(); - if ($this->statement_link === FALSE) throw new \PDOException($err_string, \fbird_errcode(), NULL); + if ($this->statement_link === FALSE) + { + throw new \PDOException($err_string, \fbird_errcode(), NULL); + } $this->statement = new Result($this->statement_link, $this); @@ -213,7 +219,10 @@ class Driver extends \Query\AbstractDriver { $this->statement_link = \fbird_prepare($this->conn, $query); // Throw the error as an exception - if ($this->statement_link === FALSE) throw new \PDOException(\fbird_errmsg(), \fbird_errcode(), NULL); + if ($this->statement_link === FALSE) + { + throw new \PDOException(\fbird_errmsg(), \fbird_errcode(), NULL); + } $this->statement = new Result($this->statement_link, $this); @@ -366,7 +375,10 @@ class Driver extends \Query\AbstractDriver { public function insert_batch($table, $data=array()) { // Each member of the data array needs to be an array - if ( ! is_array(current($data))) return NULL; + if ( ! is_array(current($data))) + { + return NULL; + } // Start the block of sql statements $sql = "EXECUTE BLOCK AS BEGIN\n"; diff --git a/src/Query/Drivers/Firebird/Result.php b/src/Query/Drivers/Firebird/Result.php index a3d71b1..3a86fb3 100644 --- a/src/Query/Drivers/Firebird/Result.php +++ b/src/Query/Drivers/Firebird/Result.php @@ -61,7 +61,10 @@ class Result extends \PDOStatement { */ public function __construct($link, Driver $db = NULL) { - if ( ! is_null($db)) $this->db = $db; + if ( ! is_null($db)) + { + $this->db = $db; + } $this->statement = $link; $this->setFetchMode(\PDO::FETCH_ASSOC); $this->row = -1; diff --git a/src/Query/Drivers/Firebird/Util.php b/src/Query/Drivers/Firebird/Util.php index 86c7856..b72ecc7 100644 --- a/src/Query/Drivers/Firebird/Util.php +++ b/src/Query/Drivers/Firebird/Util.php @@ -98,7 +98,10 @@ class Util extends \Query\AbstractUtil { $obj_res = $res->fetchAll(\PDO::FETCH_ASSOC); // Don't add to the file if the table is empty - if (count($obj_res) < 1) continue; + if (count($obj_res) < 1) + { + continue; + } // Nab the column names by getting the keys of the first row $columns = @array_keys($obj_res[0]); diff --git a/src/Query/Drivers/Mysql/Driver.php b/src/Query/Drivers/Mysql/Driver.php index c63a7e0..ab35620 100644 --- a/src/Query/Drivers/Mysql/Driver.php +++ b/src/Query/Drivers/Mysql/Driver.php @@ -49,7 +49,10 @@ class Driver extends \Query\AbstractDriver { )); } - if (strpos($dsn, 'mysql') === FALSE) $dsn = 'mysql:'.$dsn; + if (strpos($dsn, 'mysql') === FALSE) + { + $dsn = 'mysql:'.$dsn; + } parent::__construct($dsn, $username, $password, $options); } diff --git a/src/Query/Drivers/Mysql/SQL.php b/src/Query/Drivers/Mysql/SQL.php index 6df4552..004e35e 100644 --- a/src/Query/Drivers/Mysql/SQL.php +++ b/src/Query/Drivers/Mysql/SQL.php @@ -88,7 +88,10 @@ class SQL extends \Query\AbstractSQL { */ public function table_list($database='') { - if ( ! empty($database)) return "SHOW TABLES FROM `{$database}`"; + if ( ! empty($database)) + { + return "SHOW TABLES FROM `{$database}`"; + } return 'SHOW TABLES'; } diff --git a/src/Query/Drivers/Mysql/Util.php b/src/Query/Drivers/Mysql/Util.php index 6c0f662..2c9cfd8 100644 --- a/src/Query/Drivers/Mysql/Util.php +++ b/src/Query/Drivers/Mysql/Util.php @@ -38,7 +38,10 @@ class Util extends \Query\AbstractUtil { foreach($dbs as &$d) { // Skip built-in dbs - if ($d == 'mysql') continue; + if ($d == 'mysql') + { + continue; + } // Get the list of tables $tables = $this->get_driver()->driver_query("SHOW TABLES FROM `{$d}`", TRUE); @@ -48,7 +51,10 @@ class Util extends \Query\AbstractUtil { $array = $this->get_driver()->driver_query("SHOW CREATE TABLE `{$d}`.`{$table}`", FALSE); $row = current($array); - if ( ! isset($row['Create Table'])) continue; + if ( ! isset($row['Create Table'])) + { + continue; + } $string[] = $row['Create Table']; @@ -86,7 +92,10 @@ class Util extends \Query\AbstractUtil { $rows = $res->fetchAll(\PDO::FETCH_ASSOC); // Skip empty tables - if (count($rows) < 1) continue; + if (count($rows) < 1) + { + continue; + } // Nab the column names by getting the keys of the first row $columns = @array_keys($rows[0]); diff --git a/src/Query/Drivers/Pgsql/Driver.php b/src/Query/Drivers/Pgsql/Driver.php index 13bdb8a..ec9ed01 100644 --- a/src/Query/Drivers/Pgsql/Driver.php +++ b/src/Query/Drivers/Pgsql/Driver.php @@ -34,7 +34,10 @@ class Driver extends \Query\AbstractDriver { */ public function __construct($dsn, $username=null, $password=null, array $options=array()) { - if (strpos($dsn, 'pgsql') === FALSE) $dsn = 'pgsql:'.$dsn; + if (strpos($dsn, 'pgsql') === FALSE) + { + $dsn = 'pgsql:'.$dsn; + } parent::__construct($dsn, $username, $password, $options); } @@ -78,7 +81,10 @@ SQL; { foreach(array('update', 'delete') AS $type) { - if ( ! isset($value_map[$key[$type]])) continue; + if ( ! isset($value_map[$key[$type]])) + { + continue; + } $key[$type] = $value_map[$key[$type]]; } diff --git a/src/Query/Drivers/Pgsql/Util.php b/src/Query/Drivers/Pgsql/Util.php index c527b24..e5cc9f5 100644 --- a/src/Query/Drivers/Pgsql/Util.php +++ b/src/Query/Drivers/Pgsql/Util.php @@ -62,7 +62,10 @@ class Util extends \Query\AbstractUtil { $obj_res = $res->fetchAll(\PDO::FETCH_ASSOC); // Don't add to the file if the table is empty - if (count($obj_res) < 1) continue; + if (count($obj_res) < 1) + { + continue; + } $res = NULL; diff --git a/src/Query/Drivers/Sqlite/Driver.php b/src/Query/Drivers/Sqlite/Driver.php index 87ba535..2cf276c 100644 --- a/src/Query/Drivers/Sqlite/Driver.php +++ b/src/Query/Drivers/Sqlite/Driver.php @@ -47,7 +47,10 @@ class Driver extends \Query\AbstractDriver { */ public function __construct($dsn, $user=NULL, $pass=NULL, array $driver_options=array()) { - if (strpos($dsn, 'sqlite:') === FALSE) $dsn = "sqlite:{$dsn}"; + if (strpos($dsn, 'sqlite:') === FALSE) + { + $dsn = "sqlite:{$dsn}"; + } parent::__construct($dsn, $user, $pass); } @@ -117,7 +120,10 @@ class Driver extends \Query\AbstractDriver { // -------------------------------------------------------------------------- // Each member of the data array needs to be an array - if ( ! is_array(current($data))) return NULL; + if ( ! is_array(current($data))) + { + return NULL; + } // Start the block of sql statements $table = $this->quote_table($table); diff --git a/src/Query/Drivers/Sqlite/Util.php b/src/Query/Drivers/Sqlite/Util.php index 0c2f23a..65a80d3 100644 --- a/src/Query/Drivers/Sqlite/Util.php +++ b/src/Query/Drivers/Sqlite/Util.php @@ -60,7 +60,10 @@ class Util extends \Query\AbstractUtil { unset($res); // If the row is empty, continue; - if (empty($obj_res)) continue; + if (empty($obj_res)) + { + continue; + } // Nab the column names by getting the keys of the first row $columns = array_keys(current($obj_res)); diff --git a/src/Query/QueryBuilder.php b/src/Query/QueryBuilder.php index c4bdd23..0b0e3b1 100644 --- a/src/Query/QueryBuilder.php +++ b/src/Query/QueryBuilder.php @@ -677,10 +677,16 @@ class QueryBuilder extends AbstractQueryBuilder implements QueryBuilderInterface public function get($table='', $limit=FALSE, $offset=FALSE) { // Set the table - if ( ! empty($table)) $this->from($table); + if ( ! empty($table)) + { + $this->from($table); + } // Set the limit, if it exists - if (is_int($limit)) $this->limit($limit, $offset); + if (is_int($limit)) + { + $this->limit($limit, $offset); + } return $this->_run("get", $table); } @@ -732,7 +738,10 @@ class QueryBuilder extends AbstractQueryBuilder implements QueryBuilderInterface public function count_all_results($table='') { // Set the table - if ( ! empty($table)) $this->from($table); + if ( ! empty($table)) + { + $this->from($table); + } $result = $this->_run('get', $table); $rows = $result->fetchAll(); @@ -751,8 +760,10 @@ class QueryBuilder extends AbstractQueryBuilder implements QueryBuilderInterface */ public function insert($table, $data=array()) { - // No use duplicating logic! - if ( ! empty($data)) $this->set($data); + if ( ! empty($data)) + { + $this->set($data); + } return $this->_run("insert", $table); } @@ -787,8 +798,10 @@ class QueryBuilder extends AbstractQueryBuilder implements QueryBuilderInterface */ public function update($table, $data=array()) { - // No use duplicating logic! - if ( ! empty($data)) $this->set($data); + if ( ! empty($data)) + { + $this->set($data); + } return $this->_run("update", $table); } @@ -805,7 +818,10 @@ class QueryBuilder extends AbstractQueryBuilder implements QueryBuilderInterface public function delete($table, $where='') { // Set the where clause - if ( ! empty($where)) $this->where($where); + if ( ! empty($where)) + { + $this->where($where); + } return $this->_run("delete", $table); } @@ -826,7 +842,10 @@ class QueryBuilder extends AbstractQueryBuilder implements QueryBuilderInterface public function get_compiled_select($table='', $reset=TRUE) { // Set the table - if ( ! empty($table)) $this->from($table); + if ( ! empty($table)) + { + $this->from($table); + } return $this->_get_compile('select', $table, $reset); } diff --git a/src/common.php b/src/common.php index 8d16d05..8e39a72 100644 --- a/src/common.php +++ b/src/common.php @@ -147,7 +147,10 @@ if ( ! function_exists('array_column')) $output = array(); // No point iterating over an empty array - if (empty($array)) return $array; + if (empty($array)) + { + return $array; + } foreach($array as $inner_array) { @@ -175,7 +178,10 @@ if ( ! function_exists('regex_in_array')) */ function regex_in_array(Array $array, $pattern) { - if (empty($array)) return FALSE; + if (empty($array)) + { + return FALSE; + } foreach($array as $item) {