summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--system/database/DB.php20
-rw-r--r--system/database/DB_driver.php40
2 files changed, 30 insertions, 30 deletions
diff --git a/system/database/DB.php b/system/database/DB.php
index 7e6cd7466..f8d020493 100644
--- a/system/database/DB.php
+++ b/system/database/DB.php
@@ -102,13 +102,13 @@ function &DB($params = '', $query_builder_override = NULL)
}
$params = array(
- 'dbdriver' => $dsn['scheme'],
- 'hostname' => isset($dsn['host']) ? rawurldecode($dsn['host']) : '',
- 'port' => isset($dsn['port']) ? rawurldecode($dsn['port']) : '',
- 'username' => isset($dsn['user']) ? rawurldecode($dsn['user']) : '',
- 'password' => isset($dsn['pass']) ? rawurldecode($dsn['pass']) : '',
- 'database' => isset($dsn['path']) ? rawurldecode(substr($dsn['path'], 1)) : ''
- );
+ 'dbdriver' => $dsn['scheme'],
+ 'hostname' => isset($dsn['host']) ? rawurldecode($dsn['host']) : '',
+ 'port' => isset($dsn['port']) ? rawurldecode($dsn['port']) : '',
+ 'username' => isset($dsn['user']) ? rawurldecode($dsn['user']) : '',
+ 'password' => isset($dsn['pass']) ? rawurldecode($dsn['pass']) : '',
+ 'database' => isset($dsn['path']) ? rawurldecode(substr($dsn['path'], 1)) : ''
+ );
// Were additional config items set?
if (isset($dsn['query']))
@@ -177,11 +177,7 @@ function &DB($params = '', $query_builder_override = NULL)
// Load the DB driver
$driver_file = BASEPATH.'database/drivers/'.$params['dbdriver'].'/'.$params['dbdriver'].'_driver.php';
- if ( ! file_exists($driver_file))
- {
- show_error('Invalid DB driver');
- }
-
+ file_exists($driver_file) OR show_error('Invalid DB driver');
require_once($driver_file);
// Instantiate the DB adapter
diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php
index ad9e31fc4..b004de355 100644
--- a/system/database/DB_driver.php
+++ b/system/database/DB_driver.php
@@ -387,7 +387,7 @@ abstract class CI_DB_driver {
// ----------------------------------------------------------------
// Connect to the database and set the connection ID
- $this->conn_id = ($this->pconnect === FALSE) ? $this->db_connect() : $this->db_pconnect();
+ $this->conn_id = $this->db_connect($this->pconnect);
// No connection resource? Check if there is a failover else throw an error
if ( ! $this->conn_id)
@@ -405,7 +405,7 @@ abstract class CI_DB_driver {
}
// Try to connect
- $this->conn_id = ($this->pconnect === FALSE) ? $this->db_connect() : $this->db_pconnect();
+ $this->conn_id = $this->db_connect($this->pconnect);
// If a connection is made break the foreach loop
if ($this->conn_id)
@@ -424,6 +424,7 @@ abstract class CI_DB_driver {
{
$this->display_error('db_unable_to_connect');
}
+
return FALSE;
}
}
@@ -535,8 +536,7 @@ abstract class CI_DB_driver {
return ($this->db_debug) ? $this->display_error('db_unsupported_function') : FALSE;
}
- $query = $this->query($sql);
- $query = $query->row();
+ $query = $this->query($sql)->row();
return $this->data_cache['version'] = $query->ver;
}
@@ -724,8 +724,8 @@ abstract class CI_DB_driver {
if ( ! class_exists($driver, FALSE))
{
- include_once(BASEPATH.'database/DB_result.php');
- include_once(BASEPATH.'database/drivers/'.$this->dbdriver.'/'.$this->dbdriver.'_result.php');
+ require_once(BASEPATH.'database/DB_result.php');
+ require_once(BASEPATH.'database/drivers/'.$this->dbdriver.'/'.$this->dbdriver.'_result.php');
}
return $driver;
@@ -1031,9 +1031,11 @@ abstract class CI_DB_driver {
// escape LIKE condition wildcards
if ($like === TRUE)
{
- return str_replace(array($this->_like_escape_chr, '%', '_'),
- array($this->_like_escape_chr.$this->_like_escape_chr, $this->_like_escape_chr.'%', $this->_like_escape_chr.'_'),
- $str);
+ return str_replace(
+ array($this->_like_escape_chr, '%', '_'),
+ array($this->_like_escape_chr.$this->_like_escape_chr, $this->_like_escape_chr.'%', $this->_like_escape_chr.'_'),
+ $str
+ );
}
return $str;
@@ -1308,9 +1310,11 @@ abstract class CI_DB_driver {
if (is_array($this->_escape_char))
{
$preg_ec = array(
- preg_quote($this->_escape_char[0], '/'), preg_quote($this->_escape_char[1], '/'),
- $this->_escape_char[0], $this->_escape_char[1]
- );
+ preg_quote($this->_escape_char[0], '/'),
+ preg_quote($this->_escape_char[1], '/'),
+ $this->_escape_char[0],
+ $this->_escape_char[1]
+ );
}
else
{
@@ -1549,7 +1553,7 @@ abstract class CI_DB_driver {
*/
public function cache_delete($segment_one = '', $segment_two = '')
{
- return ($this->_cache_init())
+ return $this->_cache_init()
? $this->CACHE->delete($segment_one, $segment_two)
: FALSE;
}
@@ -1563,7 +1567,7 @@ abstract class CI_DB_driver {
*/
public function cache_delete_all()
{
- return ($this->_cache_init())
+ return $this->_cache_init()
? $this->CACHE->delete_all()
: FALSE;
}
@@ -1741,15 +1745,15 @@ abstract class CI_DB_driver {
if ($offset = strripos($item, ' AS '))
{
$alias = ($protect_identifiers)
- ? substr($item, $offset, 4).$this->escape_identifiers(substr($item, $offset + 4))
- : substr($item, $offset);
+ ? substr($item, $offset, 4).$this->escape_identifiers(substr($item, $offset + 4))
+ : substr($item, $offset);
$item = substr($item, 0, $offset);
}
elseif ($offset = strrpos($item, ' '))
{
$alias = ($protect_identifiers)
- ? ' '.$this->escape_identifiers(substr($item, $offset + 1))
- : substr($item, $offset);
+ ? ' '.$this->escape_identifiers(substr($item, $offset + 1))
+ : substr($item, $offset);
$item = substr($item, 0, $offset);
}
else