summaryrefslogtreecommitdiffstats
path: root/system
diff options
context:
space:
mode:
authorAndrey Andreev <narf@bofh.bg>2012-03-26 12:07:55 +0200
committerAndrey Andreev <narf@bofh.bg>2012-03-26 12:07:55 +0200
commited1aa21dcd5312b2884f140be8c0d2ee94379423 (patch)
tree9fef4a1e0cb43494e75585fbfa9b15010a801b96 /system
parent35bbb1ab4f7ee09d75fb407c6d9d9637b4404698 (diff)
parentc2697db0f2721cc9fefb58b85bf55e6bdb91db9b (diff)
Merge upstream branch
Diffstat (limited to 'system')
-rwxr-xr-xsystem/database/DB.php19
-rw-r--r--system/database/DB_active_rec.php24
-rw-r--r--system/database/DB_cache.php2
-rw-r--r--system/database/DB_driver.php23
-rw-r--r--system/database/DB_forge.php4
-rw-r--r--system/database/DB_result.php2
-rw-r--r--system/database/DB_utility.php4
-rw-r--r--system/database/drivers/cubrid/cubrid_driver.php104
-rw-r--r--system/database/drivers/interbase/interbase_driver.php178
-rw-r--r--system/database/drivers/interbase/interbase_result.php85
-rw-r--r--system/database/drivers/mssql/mssql_driver.php170
-rw-r--r--system/database/drivers/mssql/mssql_forge.php45
-rw-r--r--system/database/drivers/mssql/mssql_result.php38
-rw-r--r--system/database/drivers/mssql/mssql_utility.php26
-rw-r--r--system/database/drivers/mysql/mysql_driver.php2
-rw-r--r--system/database/drivers/mysql/mysql_forge.php2
-rw-r--r--system/database/drivers/mysql/mysql_result.php2
-rw-r--r--system/database/drivers/mysql/mysql_utility.php2
-rw-r--r--system/database/drivers/mysqli/mysqli_driver.php2
-rw-r--r--system/database/drivers/mysqli/mysqli_forge.php2
-rw-r--r--system/database/drivers/mysqli/mysqli_result.php2
-rw-r--r--system/database/drivers/mysqli/mysqli_utility.php2
-rw-r--r--system/database/drivers/oci8/oci8_driver.php265
-rw-r--r--system/database/drivers/oci8/oci8_forge.php29
-rw-r--r--system/database/drivers/oci8/oci8_result.php36
-rw-r--r--system/database/drivers/oci8/oci8_utility.php25
-rw-r--r--system/database/drivers/odbc/odbc_driver.php44
-rw-r--r--system/database/drivers/odbc/odbc_forge.php2
-rw-r--r--system/database/drivers/odbc/odbc_result.php2
-rw-r--r--system/database/drivers/odbc/odbc_utility.php2
-rw-r--r--system/database/drivers/pdo/pdo_driver.php206
-rw-r--r--system/database/drivers/pdo/pdo_forge.php34
-rw-r--r--system/database/drivers/pdo/pdo_result.php60
-rw-r--r--system/database/drivers/pdo/pdo_utility.php24
-rw-r--r--system/database/drivers/postgre/postgre_driver.php89
-rw-r--r--system/database/drivers/postgre/postgre_forge.php2
-rw-r--r--system/database/drivers/postgre/postgre_result.php2
-rw-r--r--system/database/drivers/postgre/postgre_utility.php4
-rw-r--r--system/database/drivers/sqlite/sqlite_driver.php149
-rw-r--r--system/database/drivers/sqlite/sqlite_forge.php37
-rw-r--r--system/database/drivers/sqlite/sqlite_result.php40
-rw-r--r--system/database/drivers/sqlite/sqlite_utility.php2
-rw-r--r--system/database/drivers/sqlsrv/sqlsrv_driver.php238
-rw-r--r--system/database/drivers/sqlsrv/sqlsrv_forge.php38
-rw-r--r--system/database/drivers/sqlsrv/sqlsrv_result.php56
-rw-r--r--system/database/drivers/sqlsrv/sqlsrv_utility.php30
-rw-r--r--system/libraries/Email.php13
47 files changed, 880 insertions, 1289 deletions
diff --git a/system/database/DB.php b/system/database/DB.php
index 7c12e562b..96e495515 100755
--- a/system/database/DB.php
+++ b/system/database/DB.php
@@ -37,11 +37,11 @@
function &DB($params = '', $active_record_override = NULL)
{
// Load the DB config file if a DSN string wasn't passed
- if (is_string($params) AND strpos($params, '://') === FALSE)
+ if (is_string($params) && strpos($params, '://') === FALSE)
{
// Is the config file in the environment folder?
if (( ! defined('ENVIRONMENT') OR ! file_exists($file_path = APPPATH.'config/'.ENVIRONMENT.'/database.php'))
- AND ! file_exists($file_path = APPPATH.'config/database.php'))
+ && ! file_exists($file_path = APPPATH.'config/database.php'))
{
show_error('The configuration file database.php does not exist.');
}
@@ -81,11 +81,11 @@ function &DB($params = '', $active_record_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)) : ''
+ '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?
@@ -104,10 +104,7 @@ function &DB($params = '', $active_record_override = NULL)
$val = FALSE;
}
- if ( ! isset($params[$key]))
- {
- $params[$key] = $val;
- }
+ $params[$key] = $val;
}
}
}
diff --git a/system/database/DB_active_rec.php b/system/database/DB_active_rec.php
index 35164a79c..fe591dda1 100644
--- a/system/database/DB_active_rec.php
+++ b/system/database/DB_active_rec.php
@@ -38,7 +38,7 @@
* @author EllisLab Dev Team
* @link http://codeigniter.com/user_guide/database/
*/
-class CI_DB_active_record extends CI_DB_driver {
+abstract class CI_DB_active_record extends CI_DB_driver {
protected $return_delete_sql = FALSE;
protected $reset_delete_data = FALSE;
@@ -2197,19 +2197,19 @@ class CI_DB_active_record extends CI_DB_driver {
protected function _reset_write()
{
$this->_reset_run(array(
- 'ar_set' => array(),
- 'ar_from' => array(),
- 'ar_where' => array(),
- 'ar_like' => array(),
- 'ar_orderby' => array(),
- 'ar_keys' => array(),
- 'ar_limit' => FALSE,
- 'ar_order' => FALSE
- )
- );
+ 'ar_set' => array(),
+ 'ar_from' => array(),
+ 'ar_where' => array(),
+ 'ar_like' => array(),
+ 'ar_orderby' => array(),
+ 'ar_keys' => array(),
+ 'ar_limit' => FALSE,
+ 'ar_order' => FALSE
+ )
+ );
}
}
/* End of file DB_active_rec.php */
-/* Location: ./system/database/DB_active_rec.php */
+/* Location: ./system/database/DB_active_rec.php */ \ No newline at end of file
diff --git a/system/database/DB_cache.php b/system/database/DB_cache.php
index fb0cfa89a..58e6968c0 100644
--- a/system/database/DB_cache.php
+++ b/system/database/DB_cache.php
@@ -183,4 +183,4 @@ class CI_DB_Cache {
}
/* End of file DB_cache.php */
-/* Location: ./system/database/DB_cache.php */
+/* Location: ./system/database/DB_cache.php */ \ No newline at end of file
diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php
index 1fce76cb5..f0b8e7789 100644
--- a/system/database/DB_driver.php
+++ b/system/database/DB_driver.php
@@ -38,7 +38,7 @@
* @author EllisLab Dev Team
* @link http://codeigniter.com/user_guide/database/
*/
-class CI_DB_driver {
+abstract class CI_DB_driver {
public $dsn;
public $username;
@@ -175,6 +175,23 @@ class CI_DB_driver {
// --------------------------------------------------------------------
/**
+ * Reconnect
+ *
+ * Keep / reestablish the db connection if no queries have been
+ * sent for a length of time exceeding the server's idle timeout.
+ *
+ * This is just a dummy method to allow drivers without such
+ * functionality to not declare it, while others will override it.
+ *
+ * @return void
+ */
+ public function reconnect()
+ {
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Set client character set
*
* @param string
@@ -1320,9 +1337,7 @@ class CI_DB_driver {
*
* @return void
*/
- protected function _reset_select()
- {
- }
+ abstract protected function _reset_select();
}
diff --git a/system/database/DB_forge.php b/system/database/DB_forge.php
index fe2a67728..34c502a99 100644
--- a/system/database/DB_forge.php
+++ b/system/database/DB_forge.php
@@ -34,7 +34,7 @@
* @author EllisLab Dev Team
* @link http://codeigniter.com/user_guide/database/
*/
-class CI_DB_forge {
+abstract class CI_DB_forge {
public $fields = array();
public $keys = array();
@@ -346,4 +346,4 @@ class CI_DB_forge {
}
/* End of file DB_forge.php */
-/* Location: ./system/database/DB_forge.php */
+/* Location: ./system/database/DB_forge.php */ \ No newline at end of file
diff --git a/system/database/DB_result.php b/system/database/DB_result.php
index c3cdd24ff..04f964fb1 100644
--- a/system/database/DB_result.php
+++ b/system/database/DB_result.php
@@ -392,4 +392,4 @@ class CI_DB_result {
}
/* End of file DB_result.php */
-/* Location: ./system/database/DB_result.php */
+/* Location: ./system/database/DB_result.php */ \ No newline at end of file
diff --git a/system/database/DB_utility.php b/system/database/DB_utility.php
index c94f93e5e..642a004bd 100644
--- a/system/database/DB_utility.php
+++ b/system/database/DB_utility.php
@@ -32,7 +32,7 @@
* @author EllisLab Dev Team
* @link http://codeigniter.com/user_guide/database/
*/
-class CI_DB_utility extends CI_DB_forge {
+abstract class CI_DB_utility extends CI_DB_forge {
public $db;
public $data_cache = array();
@@ -384,4 +384,4 @@ class CI_DB_utility extends CI_DB_forge {
}
/* End of file DB_utility.php */
-/* Location: ./system/database/DB_utility.php */
+/* Location: ./system/database/DB_utility.php */ \ No newline at end of file
diff --git a/system/database/drivers/cubrid/cubrid_driver.php b/system/database/drivers/cubrid/cubrid_driver.php
index 7b468bc5c..bed3d8685 100644
--- a/system/database/drivers/cubrid/cubrid_driver.php
+++ b/system/database/drivers/cubrid/cubrid_driver.php
@@ -57,38 +57,35 @@ class CI_DB_cubrid_driver extends CI_DB {
protected $_count_string = 'SELECT COUNT(*) AS ';
protected $_random_keyword = ' RAND()'; // database specific random keyword
- /**
- * Non-persistent database connection
- *
- * @return resource
- */
- public function db_connect()
- {
- // If no port is defined by the user, use the default value
- if ($this->port == '')
- {
- // Default CUBRID Broker port
- $this->port = 33000;
- }
+ // CUBRID-specific properties
+ public $auto_commit = TRUE;
- $conn = cubrid_connect($this->hostname, $this->port, $this->database, $this->username, $this->password);
+ public function __construct($params)
+ {
+ parent::__construct($params);
- if ($conn)
+ if (preg_match('/^CUBRID:[^:]+(:[0-9][1-9]{0,4})?:[^:]+:[^:]*:[^:]*:(\?.+)?$/', $this->dsn, $matches))
{
- // Check if a user wants to run queries in dry, i.e. run the
- // queries but not commit them.
- if (isset($this->auto_commit) && ! $this->auto_commit)
+ if (stripos($matches[2], 'autocommit=off') !== FALSE)
{
- cubrid_set_autocommit($conn, CUBRID_AUTOCOMMIT_FALSE);
- }
- else
- {
- cubrid_set_autocommit($conn, CUBRID_AUTOCOMMIT_TRUE);
- $this->auto_commit = TRUE;
+ $this->auto_commit = FALSE;
}
}
+ else
+ {
+ // If no port is defined by the user, use the default value
+ $this->port == '' OR $this->port = 33000;
+ }
+ }
- return $conn;
+ /**
+ * Non-persistent database connection
+ *
+ * @return resource
+ */
+ public function db_connect()
+ {
+ return $this->_cubrid_connect();
}
// --------------------------------------------------------------------
@@ -100,15 +97,45 @@ class CI_DB_cubrid_driver extends CI_DB {
* engine which can be configured in the CUBRID Broker configuration
* file by setting the CCI_PCONNECT parameter to ON. In that case, all
* connections established between the client application and the
- * server will become persistent. This is calling the same
- * @cubrid_connect function will establish persisten connection
- * considering that the CCI_PCONNECT is ON.
+ * server will become persistent.
*
* @return resource
*/
public function db_pconnect()
{
- return $this->db_connect();
+ return $this->_cubrid_connect(TRUE);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * CUBRID connection
+ *
+ * A CUBRID-specific method to create a connection to the database.
+ * Except for determining if a persistent connection should be used,
+ * the rest of the logic is the same for db_connect() and db_pconnect().
+ *
+ * @param bool
+ * @return resource
+ */
+ protected function _cubrid_connect($persistent = FALSE)
+ {
+ if (preg_match('/^CUBRID:[^:]+(:[0-9][1-9]{0,4})?:[^:]+:([^:]*):([^:]*):(\?.+)?$/', $this->dsn, $matches))
+ {
+ $_temp = ($persistent !== TRUE) ? 'cubrid_connect_with_url' : 'cubrid_pconnect_with_url';
+ $conn_id = ($matches[2] === '' && $matches[3] === '' && $this->username !== '' && $this->password !== '')
+ ? $_temp($this->dsn, $this->username, $this->password)
+ : $_temp($this->dsn);
+ }
+ else
+ {
+ $_temp = ($persistent !== TRUE) ? 'cubrid_connect' : 'cubrid_pconnect';
+ $conn_id = ($this->username !== '')
+ ? $_temp($this->hostname, $this->port, $this->database, $this->username, $this->password)
+ : $_temp($this->hostname, $this->port, $this->database);
+ }
+
+ return $conn_id;
}
// --------------------------------------------------------------------
@@ -169,29 +196,12 @@ class CI_DB_cubrid_driver extends CI_DB {
*/
protected function _execute($sql)
{
- $sql = $this->_prep_query($sql);
return @cubrid_query($sql, $this->conn_id);
}
// --------------------------------------------------------------------
/**
- * Prep the query
- *
- * If needed, each database adapter can prep the query string
- *
- * @param string an SQL query
- * @return string
- */
- protected function _prep_query($sql)
- {
- // No need to prepare
- return $sql;
- }
-
- // --------------------------------------------------------------------
-
- /**
* Begin Transaction
*
* @return bool
@@ -732,4 +742,4 @@ class CI_DB_cubrid_driver extends CI_DB {
}
/* End of file cubrid_driver.php */
-/* Location: ./system/database/drivers/cubrid/cubrid_driver.php */
+/* Location: ./system/database/drivers/cubrid/cubrid_driver.php */ \ No newline at end of file
diff --git a/system/database/drivers/interbase/interbase_driver.php b/system/database/drivers/interbase/interbase_driver.php
index a9a647202..d8b6ae571 100644
--- a/system/database/drivers/interbase/interbase_driver.php
+++ b/system/database/drivers/interbase/interbase_driver.php
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* Firebird/Interbase Database Adapter Class
*
@@ -56,8 +54,8 @@ class CI_DB_interbase_driver extends CI_DB {
* database engines, so this string appears in each driver and is
* used for the count_all() and count_all_results() functions.
*/
- protected $_count_string = "SELECT COUNT(*) AS ";
- protected $_random_keyword = ' Random()'; // database specific random keyword
+ protected $_count_string = 'SELECT COUNT(*) AS ';
+ protected $_random_keyword = ' Random()'; // database specific random keyword
// Keeps track of the resource for the current transaction
protected $trans;
@@ -87,21 +85,6 @@ class CI_DB_interbase_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * Reconnect
- *
- * Keep / reestablish the db connection if no queries have been
- * sent for a length of time exceeding the server's idle timeout
- *
- * @return void
- */
- public function reconnect()
- {
- // not implemented in Interbase/Firebird
- }
-
- // --------------------------------------------------------------------
-
- /**
* Select the database
*
* @return bool
@@ -148,41 +131,20 @@ class CI_DB_interbase_driver extends CI_DB {
*/
protected function _execute($sql)
{
- $sql = $this->_prep_query($sql);
return @ibase_query($this->conn_id, $sql);
}
// --------------------------------------------------------------------
/**
- * Prep the query
- *
- * If needed, each database adapter can prep the query string
- *
- * @param string an SQL query
- * @return string
- */
- protected function _prep_query($sql)
- {
- return $sql;
- }
-
- // --------------------------------------------------------------------
-
- /**
* Begin Transaction
*
* @return bool
*/
public function trans_begin($test_mode = FALSE)
{
- if ( ! $this->trans_enabled)
- {
- return TRUE;
- }
-
// When transactions are nested we only begin/commit/rollback the outermost ones
- if ($this->_trans_depth > 0)
+ if ( ! $this->trans_enabled OR $this->_trans_depth > 0)
{
return TRUE;
}
@@ -190,7 +152,7 @@ class CI_DB_interbase_driver extends CI_DB {
// Reset the transaction failure flag.
// If the $test_mode flag is set to TRUE transactions will be rolled back
// even if the queries produce a successful result.
- $this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE;
+ $this->_trans_failure = ($test_mode === TRUE);
$this->trans = @ibase_trans($this->conn_id);
@@ -206,13 +168,8 @@ class CI_DB_interbase_driver extends CI_DB {
*/
public function trans_commit()
{
- if ( ! $this->trans_enabled)
- {
- return TRUE;
- }
-
// When transactions are nested we only begin/commit/rollback the outermost ones
- if ($this->_trans_depth > 0)
+ if ( ! $this->trans_enabled OR $this->_trans->depth > 0)
{
return TRUE;
}
@@ -229,13 +186,8 @@ class CI_DB_interbase_driver extends CI_DB {
*/
public function trans_rollback()
{
- if ( ! $this->trans_enabled)
- {
- return TRUE;
- }
-
// When transactions are nested we only begin/commit/rollback the outermost ones
- if ($this->_trans_depth > 0)
+ if ( ! $this->trans_enabled OR $this->_trans_depth > 0)
{
return TRUE;
}
@@ -267,9 +219,9 @@ class CI_DB_interbase_driver extends CI_DB {
// escape LIKE condition wildcards
if ($like === TRUE)
{
- $str = 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;
@@ -280,7 +232,7 @@ class CI_DB_interbase_driver extends CI_DB {
/**
* Affected Rows
*
- * @return integer
+ * @return int
*/
public function affected_rows()
{
@@ -292,9 +244,9 @@ class CI_DB_interbase_driver extends CI_DB {
/**
* Insert ID
*
- * @param string $generator_name
- * @param integer $inc_by
- * @return integer
+ * @param string $generator_name
+ * @param int $inc_by
+ * @return int
*/
public function insert_id($generator_name, $inc_by=0)
{
@@ -326,9 +278,9 @@ class CI_DB_interbase_driver extends CI_DB {
return 0;
}
- $row = $query->row();
+ $query = $query->row();
$this->_reset_select();
- return (int) $row->numrows;
+ return (int) $query->numrows;
}
// --------------------------------------------------------------------
@@ -338,21 +290,18 @@ class CI_DB_interbase_driver extends CI_DB {
*
* Generates a platform-specific query string so that the table names can be fetched
*
- * @param boolean
+ * @param bool
* @return string
*/
protected function _list_tables($prefix_limit = FALSE)
{
- $sql = <<<SQL
- SELECT "RDB\$RELATION_NAME" FROM "RDB\$RELATIONS"
- WHERE "RDB\$RELATION_NAME" NOT LIKE 'RDB$%'
- AND "RDB\$RELATION_NAME" NOT LIKE 'MON$%'
-SQL;
+ $sql = 'SELECT "RDB$RELATION_NAME" FROM "RDB$RELATIONS" WHERE "RDB$RELATION_NAME" NOT LIKE \'RDB$%\' AND "RDB$RELATION_NAME" NOT LIKE \'MON$%\'';
- if ($prefix_limit !== FALSE AND $this->dbprefix != '')
+ if ($prefix_limit !== FALSE && $this->dbprefix != '')
{
- $sql .= ' AND "RDB$RELATION_NAME" LIKE \''.$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr);
+ return $sql.' AND "RDB$RELATION_NAME" LIKE \''.$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr);
}
+
return $sql;
}
@@ -368,10 +317,7 @@ SQL;
*/
protected function _list_columns($table = '')
{
- return <<<SQL
- SELECT "RDB\$FIELD_NAME" FROM "RDB\$RELATION_FIELDS"
- WHERE "RDB\$RELATION_NAME"='{$table}';
-SQL;
+ return 'SELECT "RDB$FIELD_NAME" FROM "RDB$RELATION_FIELDS" WHERE "RDB$RELATION_NAME" = \''.$this->escape_str($table)."'";
}
// --------------------------------------------------------------------
@@ -382,14 +328,14 @@ SQL;
* Generates a platform-specific query so that the column data can be retrieved
*
* @param string the table name
- * @return object
+ * @return string
*/
protected function _field_data($table)
{
// Need to find a more efficient way to do this
// but Interbase/Firebird seems to lack the
// limit clause
- return "SELECT * FROM {$table}";
+ return 'SELECT * FROM '.$table;
}
// --------------------------------------------------------------------
@@ -423,24 +369,20 @@ SQL;
{
if (strpos($item, '.'.$id) !== FALSE)
{
- $str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item);
+ $item = str_replace('.', $this->_escape_char.'.', $item);
// remove duplicates if the user already included the escape
- return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
+ return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $this->_escape_char.$item);
}
}
if (strpos($item, '.') !== FALSE)
{
- $str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char;
- }
- else
- {
- $str = $this->_escape_char.$item.$this->_escape_char;
+ $item = str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item);
}
// remove duplicates if the user already included the escape
- return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
+ return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $this->_escape_char.$item.$this->_escape_char);
}
// --------------------------------------------------------------------
@@ -451,8 +393,8 @@ SQL;
* This public function implicitly groups FROM tables so there is no confusion
* about operator precedence in harmony with SQL standards
*
- * @param type
- * @return type
+ * @param array
+ * @return string
*/
protected function _from_tables($tables)
{
@@ -479,7 +421,7 @@ SQL;
*/
protected function _insert($table, $keys, $values)
{
- return "INSERT INTO {$table} (".implode(', ', $keys).') VALUES ('.implode(', ', $values).')';
+ return 'INSERT INTO '.$table.' ('.implode(', ', $keys).') VALUES ('.implode(', ', $values).')';
}
// --------------------------------------------------------------------
@@ -500,20 +442,14 @@ SQL;
{
foreach ($values as $key => $val)
{
- $valstr[] = $key." = ".$val;
+ $valstr[] = $key.' = '.$val;
}
//$limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
- $orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):'';
-
- $sql = "UPDATE {$table} SET ".implode(', ', $valstr);
-
- $sql .= ($where != '' AND count($where) >=1) ? ' WHERE '.implode(' ', $where) : '';
-
- $sql .= $orderby;
-
- return $sql;
+ return 'UPDATE '.$table.' SET '.implode(', ', $valstr)
+ .(($where != '' && count($where) > 0) ? ' WHERE '.implode(' ', $where) : '')
+ .(count($orderby) > 0 ? ' ORDER BY '.implode(', ', $orderby) : '');
}
@@ -548,23 +484,20 @@ SQL;
*/
protected function _delete($table, $where = array(), $like = array(), $limit = FALSE)
{
- $conditions = '';
-
if (count($where) > 0 OR count($like) > 0)
{
- $conditions = "\nWHERE ";
- $conditions .= implode("\n", $this->ar_where);
-
- if (count($where) > 0 && count($like) > 0)
- {
- $conditions .= ' AND ';
- }
- $conditions .= implode("\n", $like);
+ $conditions = "\nWHERE ".implode("\n", $where)
+ .((count($where) > 0 && count($like) > 0) ? ' AND ' : '')
+ .implode("\n", $like);
+ }
+ else
+ {
+ $conditions = '';
}
//$limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
- return "DELETE FROM {$table}{$conditions}";
+ return 'DELETE FROM '.$table.' '.$conditions;
}
// --------------------------------------------------------------------
@@ -575,36 +508,25 @@ SQL;
* Generates a platform-specific LIMIT clause
*
* @param string the sql query string
- * @param integer the number of rows to limit the query to
- * @param integer the offset value
+ * @param int the number of rows to limit the query to
+ * @param int the offset value
* @return string
*/
protected function _limit($sql, $limit, $offset)
{
- // Keep the current sql string safe for a moment
- $orig_sql = $sql;
-
// Limit clause depends on if Interbase or Firebird
if (stripos($this->version(), 'firebird') !== FALSE)
{
- $sql = 'FIRST '. (int) $limit;
-
- if ($offset > 0)
- {
- $sql .= ' SKIP '. (int) $offset;
- }
+ $select = 'FIRST '. (int) $limit
+ .($offset > 0 ? ' SKIP '. (int) $offset : '');
}
else
{
- $sql = 'ROWS ' . (int) $limit;
-
- if ($offset > 0)
- {
- $sql = 'ROWS '. (int) $offset . ' TO ' . ($limit + $offset);
- }
+ $select = 'ROWS '
+ .($offset > 0 ? (int) $offset.' TO '.($limit + $offset) : (int) $limit);
}
- return preg_replace('`SELECT`i', "SELECT {$sql}", $orig_sql);
+ return preg_replace('`SELECT`i', 'SELECT '.$select, $sql);
}
// --------------------------------------------------------------------
@@ -623,4 +545,4 @@ SQL;
}
/* End of file interbase_driver.php */
-/* Location: ./system/database/drivers/interbase/interbase_driver.php */
+/* Location: ./system/database/drivers/interbase/interbase_driver.php */ \ No newline at end of file
diff --git a/system/database/drivers/interbase/interbase_result.php b/system/database/drivers/interbase/interbase_result.php
index 5bf0c902d..fd4178dec 100644
--- a/system/database/drivers/interbase/interbase_result.php
+++ b/system/database/drivers/interbase/interbase_result.php
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* Interbase/Firebird Result Class
*
@@ -43,18 +41,18 @@ class CI_DB_interbase_result extends CI_DB_result {
/**
* Number of rows in the result set
*
- * @return integer
+ * @return int
*/
public function num_rows()
{
- if( ! is_null($this->num_rows))
+ if (is_int($this->num_rows))
{
return $this->num_rows;
}
-
- //Get the results so that you can get an accurate rowcount
+
+ // Get the results so that you can get an accurate rowcount
$this->result();
-
+
return $this->num_rows;
}
@@ -63,7 +61,7 @@ class CI_DB_interbase_result extends CI_DB_result {
/**
* Number of fields in the result set
*
- * @return integer
+ * @return int
*/
public function num_fields()
{
@@ -102,20 +100,17 @@ class CI_DB_interbase_result extends CI_DB_result {
*/
public function field_data()
{
-
$retval = array();
- for ($i = 0, $num_fields = $this->num_fields(); $i < $num_fields; $i++)
+ for ($i = 0, $c = $this->num_fields(); $i < $c; $i++)
{
$info = ibase_field_info($this->result_id, $i);
-
- $F = new stdClass();
- $F->name = $info['name'];
- $F->type = $info['type'];
- $F->max_length = $info['length'];
- $F->primary_key = 0;
- $F->default = '';
-
- $retval[] = $F;
+
+ $retval[$i] = new stdClass();
+ $retval[$i]->name = $info['name'];
+ $retval[$i]->type = $info['type'];
+ $retval[$i]->max_length = $info['length'];
+ $retval[$i]->primary_key = 0;
+ $retval[$i]->default = '';
}
return $retval;
@@ -126,7 +121,7 @@ class CI_DB_interbase_result extends CI_DB_result {
/**
* Free the result
*
- * @return null
+ * @return void
*/
public function free_result()
{
@@ -138,7 +133,7 @@ class CI_DB_interbase_result extends CI_DB_result {
/**
* Data Seek
*
- * Moves the internal pointer to the desired offset. We call
+ * Moves the internal pointer to the desired offset. We call
* this internally before fetching results to make sure the
* result set starts at zero
*
@@ -146,11 +141,8 @@ class CI_DB_interbase_result extends CI_DB_result {
*/
protected function _data_seek($n = 0)
{
- //Set the row count to 0
- $this->num_rows = 0;
-
- //Interbase driver doesn't implement a suitable function
- return FALSE;
+ // Interbase driver doesn't implement a suitable function
+ return FALSE;
}
// --------------------------------------------------------------------
@@ -169,7 +161,7 @@ class CI_DB_interbase_result extends CI_DB_result {
//Increment row count
$this->num_rows++;
}
-
+
return $row;
}
@@ -189,10 +181,10 @@ class CI_DB_interbase_result extends CI_DB_result {
//Increment row count
$this->num_rows++;
}
-
+
return $row;
}
-
+
// --------------------------------------------------------------------
/**
@@ -202,29 +194,20 @@ class CI_DB_interbase_result extends CI_DB_result {
*/
public function result_object()
{
- if (count($this->result_object) > 0)
+ if (count($this->result_object) === $this->num_rows)
{
return $this->result_object;
}
-
- // Convert result array to object so that
+
+ // Convert result array to object so that
// We don't have to get the result again
- if (count($this->result_array) > 0)
+ if (($c = count($this->result_array)) > 0)
{
- $i = 0;
-
- foreach ($this->result_array as $array)
+ for ($i = 0; $i < $c; $i++)
{
- $this->result_object[$i] = new StdClass();
-
- foreach ($array as $key => $val)
- {
- $this->result_object[$i]->{$key} = $val;
- }
-
- ++$i;
+ $this->result_object[$i] = (object) $this->result_array[$i];
}
-
+
return $this->result_object;
}
@@ -254,20 +237,20 @@ class CI_DB_interbase_result extends CI_DB_result {
*/
public function result_array()
{
- if (count($this->result_array) > 0)
+ if (count($this->result_array) === $this->num_rows)
{
return $this->result_array;
}
-
+
// Since the object and array are really similar, just case
// the result object to an array if need be
- if (count($this->result_object) > 0)
+ if (($c = count($this->result_object)) > 0)
{
- foreach ($this->result_object as $obj)
+ for ($i = 0; $i < $c; $i++)
{
- $this->result_array[] = (array) $obj;
+ $this->result_array[$i] = (array) $this->result_object[$i];
}
-
+
return $this->result_array;
}
diff --git a/system/database/drivers/mssql/mssql_driver.php b/system/database/drivers/mssql/mssql_driver.php
index b6b64cc44..f2933fe43 100644
--- a/system/database/drivers/mssql/mssql_driver.php
+++ b/system/database/drivers/mssql/mssql_driver.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* MS SQL Database Adapter Class
*
@@ -42,30 +40,29 @@
*/
class CI_DB_mssql_driver extends CI_DB {
- var $dbdriver = 'mssql';
+ public $dbdriver = 'mssql';
// The character used for escaping
- var $_escape_char = '';
+ protected $_escape_char = '';
// clause and character used for LIKE escape sequences
- var $_like_escape_str = " ESCAPE '%s' ";
- var $_like_escape_chr = '!';
+ protected $_like_escape_str = " ESCAPE '%s' ";
+ protected $_like_escape_chr = '!';
/**
* The syntax to count rows is slightly different across different
* database engines, so this string appears in each driver and is
* used for the count_all() and count_all_results() functions.
*/
- var $_count_string = "SELECT COUNT(*) AS ";
- var $_random_keyword = ' ASC'; // not currently supported
+ protected $_count_string = 'SELECT COUNT(*) AS ';
+ protected $_random_keyword = ' ASC'; // not currently supported
/**
* Non-persistent database connection
*
- * @access private called by the base class
* @return resource
*/
- function db_connect()
+ public function db_connect()
{
if ($this->port != '')
{
@@ -80,10 +77,9 @@ class CI_DB_mssql_driver extends CI_DB {
/**
* Persistent database connection
*
- * @access private called by the base class
* @return resource
*/
- function db_pconnect()
+ public function db_pconnect()
{
if ($this->port != '')
{
@@ -96,22 +92,6 @@ class CI_DB_mssql_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * Reconnect
- *
- * Keep / reestablish the db connection if no queries have been
- * sent for a length of time exceeding the server's idle timeout
- *
- * @access public
- * @return void
- */
- function reconnect()
- {
- // not implemented in MSSQL
- }
-
- // --------------------------------------------------------------------
-
- /**
* Select the database
*
* @param string database name
@@ -140,41 +120,22 @@ class CI_DB_mssql_driver extends CI_DB {
/**
* Execute the query
*
- * @access private called by the base class
* @param string an SQL query
* @return resource
*/
- function _execute($sql)
+ protected function _execute($sql)
{
- $sql = $this->_prep_query($sql);
return @mssql_query($sql, $this->conn_id);
}
// --------------------------------------------------------------------
/**
- * Prep the query
- *
- * If needed, each database adapter can prep the query string
- *
- * @access private called by execute()
- * @param string an SQL query
- * @return string
- */
- function _prep_query($sql)
- {
- return $sql;
- }
-
- // --------------------------------------------------------------------
-
- /**
* Begin Transaction
*
- * @access public
* @return bool
*/
- function trans_begin($test_mode = FALSE)
+ public function trans_begin($test_mode = FALSE)
{
if ( ! $this->trans_enabled)
{
@@ -201,10 +162,9 @@ class CI_DB_mssql_driver extends CI_DB {
/**
* Commit Transaction
*
- * @access public
* @return bool
*/
- function trans_commit()
+ public function trans_commit()
{
if ( ! $this->trans_enabled)
{
@@ -226,10 +186,9 @@ class CI_DB_mssql_driver extends CI_DB {
/**
* Rollback Transaction
*
- * @access public
* @return bool
*/
- function trans_rollback()
+ public function trans_rollback()
{
if ( ! $this->trans_enabled)
{
@@ -251,12 +210,11 @@ class CI_DB_mssql_driver extends CI_DB {
/**
* Escape String
*
- * @access public
* @param string
* @param bool whether or not the string will be used in a LIKE condition
* @return string
*/
- function escape_str($str, $like = FALSE)
+ public function escape_str($str, $like = FALSE)
{
if (is_array($str))
{
@@ -289,10 +247,9 @@ class CI_DB_mssql_driver extends CI_DB {
/**
* Affected Rows
*
- * @access public
- * @return integer
+ * @return int
*/
- function affected_rows()
+ public function affected_rows()
{
return @mssql_rows_affected($this->conn_id);
}
@@ -300,14 +257,13 @@ class CI_DB_mssql_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * Insert ID
- *
- * Returns the last id created in the Identity column.
- *
- * @access public
- * @return integer
- */
- function insert_id()
+ * Insert ID
+ *
+ * Returns the last id created in the Identity column.
+ *
+ * @return string
+ */
+ public function insert_id()
{
$ver = self::_parse_major_version($this->version());
$sql = ($ver >= 8 ? "SELECT SCOPE_IDENTITY() AS last_id" : "SELECT @@IDENTITY AS last_id");
@@ -319,16 +275,15 @@ class CI_DB_mssql_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * Parse major version
- *
- * Grabs the major version number from the
- * database server version string passed in.
- *
- * @access private
- * @param string $version
- * @return int16 major version number
- */
- function _parse_major_version($version)
+ * Parse major version
+ *
+ * Grabs the major version number from the
+ * database server version string passed in.
+ *
+ * @param string $version
+ * @return int major version number
+ */
+ protected function _parse_major_version($version)
{
preg_match('/([0-9]+)\.([0-9]+)\.([0-9]+)/', $version, $ver_info);
return $ver_info[1]; // return the major version b/c that's all we're interested in.
@@ -337,10 +292,10 @@ class CI_DB_mssql_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * Version number query string
- *
- * @return string
- */
+ * Version number query string
+ *
+ * @return string
+ */
protected function _version()
{
return 'SELECT @@VERSION AS ver';
@@ -354,11 +309,10 @@ class CI_DB_mssql_driver extends CI_DB {
* Generates a platform-specific query string that counts all records in
* the specified database
*
- * @access public
* @param string
* @return string
*/
- function count_all($table = '')
+ public function count_all($table = '')
{
if ($table == '')
{
@@ -383,11 +337,10 @@ class CI_DB_mssql_driver extends CI_DB {
*
* Generates a platform-specific query string so that the table names can be fetched
*
- * @access private
- * @param boolean
+ * @param bool
* @return string
*/
- function _list_tables($prefix_limit = FALSE)
+ protected function _list_tables($prefix_limit = FALSE)
{
$sql = "SELECT name FROM sysobjects WHERE type = 'U' ORDER BY name";
@@ -408,11 +361,10 @@ class CI_DB_mssql_driver extends CI_DB {
*
* Generates a platform-specific query string so that the column names can be fetched
*
- * @access private
* @param string the table name
* @return string
*/
- function _list_columns($table = '')
+ protected function _list_columns($table = '')
{
return "SELECT * FROM INFORMATION_SCHEMA.Columns WHERE TABLE_NAME = '".$table."'";
}
@@ -424,11 +376,10 @@ class CI_DB_mssql_driver extends CI_DB {
*
* Generates a platform-specific query so that the column data can be retrieved
*
- * @access public
* @param string the table name
- * @return object
+ * @return string
*/
- function _field_data($table)
+ protected function _field_data($table)
{
return "SELECT TOP 1 * FROM ".$table;
}
@@ -457,11 +408,10 @@ class CI_DB_mssql_driver extends CI_DB {
*
* This function escapes column and table names
*
- * @access private
* @param string
* @return string
*/
- function _escape_identifiers($item)
+ public function _escape_identifiers($item)
{
if ($this->_escape_char == '')
{
@@ -500,11 +450,10 @@ class CI_DB_mssql_driver extends CI_DB {
* This function implicitly groups FROM tables so there is no confusion
* about operator precedence in harmony with SQL standards
*
- * @access public
- * @param type
- * @return type
+ * @param array
+ * @return string
*/
- function _from_tables($tables)
+ protected function _from_tables($tables)
{
if ( ! is_array($tables))
{
@@ -521,13 +470,12 @@ class CI_DB_mssql_driver extends CI_DB {
*
* Generates a platform-specific insert string from the supplied data
*
- * @access public
* @param string the table name
* @param array the insert keys
* @param array the insert values
* @return string
*/
- function _insert($table, $keys, $values)
+ protected function _insert($table, $keys, $values)
{
return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")";
}
@@ -539,7 +487,6 @@ class CI_DB_mssql_driver extends CI_DB {
*
* Generates a platform-specific update string from the supplied data
*
- * @access public
* @param string the table name
* @param array the update data
* @param array the where clause
@@ -547,7 +494,7 @@ class CI_DB_mssql_driver extends CI_DB {
* @param array the limit clause
* @return string
*/
- function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
+ protected function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
{
foreach ($values as $key => $val)
{
@@ -577,11 +524,10 @@ class CI_DB_mssql_driver extends CI_DB {
* If the database does not support the truncate() command
* This function maps to "DELETE FROM table"
*
- * @access public
* @param string the table name
* @return string
*/
- function _truncate($table)
+ protected function _truncate($table)
{
return "TRUNCATE ".$table;
}
@@ -627,13 +573,12 @@ class CI_DB_mssql_driver extends CI_DB {
*
* Generates a platform-specific LIMIT clause
*
- * @access public
* @param string the sql query string
- * @param integer the number of rows to limit the query to
- * @param integer the offset value
+ * @param int the number of rows to limit the query to
+ * @param int the offset value
* @return string
*/
- function _limit($sql, $limit, $offset)
+ protected function _limit($sql, $limit, $offset)
{
$i = $limit + $offset;
@@ -645,18 +590,15 @@ class CI_DB_mssql_driver extends CI_DB {
/**
* Close DB Connection
*
- * @access public
* @param resource
* @return void
*/
- function _close($conn_id)
+ protected function _close($conn_id)
{
@mssql_close($conn_id);
}
}
-
-
/* End of file mssql_driver.php */
-/* Location: ./system/database/drivers/mssql/mssql_driver.php */
+/* Location: ./system/database/drivers/mssql/mssql_driver.php */ \ No newline at end of file
diff --git a/system/database/drivers/mssql/mssql_forge.php b/system/database/drivers/mssql/mssql_forge.php
index 4a8089bb1..2e3e314ed 100644
--- a/system/database/drivers/mssql/mssql_forge.php
+++ b/system/database/drivers/mssql/mssql_forge.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* MS SQL Forge Class
*
@@ -39,11 +37,10 @@ class CI_DB_mssql_forge extends CI_DB_forge {
/**
* Create database
*
- * @access private
* @param string the database name
- * @return bool
+ * @return string
*/
- function _create_database($name)
+ public function _create_database($name)
{
return "CREATE DATABASE ".$name;
}
@@ -53,11 +50,10 @@ class CI_DB_mssql_forge extends CI_DB_forge {
/**
* Drop database
*
- * @access private
* @param string the database name
- * @return bool
+ * @return string
*/
- function _drop_database($name)
+ public function _drop_database($name)
{
return "DROP DATABASE ".$name;
}
@@ -67,10 +63,10 @@ class CI_DB_mssql_forge extends CI_DB_forge {
/**
* Drop Table
*
- * @access private
- * @return bool
+ * @param string table name
+ * @return string
*/
- function _drop_table($table)
+ public function _drop_table($table)
{
return "DROP TABLE ".$this->db->_escape_identifiers($table);
}
@@ -80,15 +76,14 @@ class CI_DB_mssql_forge extends CI_DB_forge {
/**
* Create Table
*
- * @access private
* @param string the table name
* @param array the fields
* @param mixed primary key(s)
* @param mixed key(s)
- * @param boolean should 'IF NOT EXISTS' be added to the SQL
- * @return bool
+ * @param bool should 'IF NOT EXISTS' be added to the SQL
+ * @return string
*/
- function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
+ public function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
{
$sql = 'CREATE TABLE ';
@@ -100,7 +95,7 @@ class CI_DB_mssql_forge extends CI_DB_forge {
$sql .= $this->db->_escape_identifiers($table)." (";
$current_field_count = 0;
- foreach ($fields as $field=>$attributes)
+ foreach ($fields as $field => $attributes)
{
// Numeric field names aren't allowed in databases, so if the key is
// numeric, we know it was assigned by PHP and the developer manually
@@ -190,17 +185,16 @@ class CI_DB_mssql_forge extends CI_DB_forge {
* Generates a platform-specific query so that a table can be altered
* Called by add_column(), drop_column(), and column_alter(),
*
- * @access private
* @param string the ALTER type (ADD, DROP, CHANGE)
* @param string the column name
* @param string the table name
* @param string the column definition
* @param string the default value
- * @param boolean should 'NOT NULL' be added
+ * @param bool should 'NOT NULL' be added
* @param string the field after which we should add the new field
- * @return object
+ * @return string
*/
- function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '')
+ public function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '')
{
$sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '.$this->db->protect_identifiers($column_name);
@@ -242,12 +236,11 @@ class CI_DB_mssql_forge extends CI_DB_forge {
*
* Generates a platform-specific query so that a table can be renamed
*
- * @access private
* @param string the old table name
* @param string the new table name
* @return string
*/
- function _rename_table($table_name, $new_table_name)
+ public function _rename_table($table_name, $new_table_name)
{
// I think this syntax will work, but can find little documentation on renaming tables in MSSQL
return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name);
@@ -256,4 +249,4 @@ class CI_DB_mssql_forge extends CI_DB_forge {
}
/* End of file mssql_forge.php */
-/* Location: ./system/database/drivers/mssql/mssql_forge.php */
+/* Location: ./system/database/drivers/mssql/mssql_forge.php */ \ No newline at end of file
diff --git a/system/database/drivers/mssql/mssql_result.php b/system/database/drivers/mssql/mssql_result.php
index b205ce2d1..2723f4614 100644
--- a/system/database/drivers/mssql/mssql_result.php
+++ b/system/database/drivers/mssql/mssql_result.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* MS SQL Result Class
*
@@ -41,10 +39,9 @@ class CI_DB_mssql_result extends CI_DB_result {
/**
* Number of rows in the result set
*
- * @access public
- * @return integer
+ * @return int
*/
- function num_rows()
+ public function num_rows()
{
return @mssql_num_rows($this->result_id);
}
@@ -54,10 +51,9 @@ class CI_DB_mssql_result extends CI_DB_result {
/**
* Number of fields in the result set
*
- * @access public
- * @return integer
+ * @return int
*/
- function num_fields()
+ public function num_fields()
{
return @mssql_num_fields($this->result_id);
}
@@ -69,10 +65,9 @@ class CI_DB_mssql_result extends CI_DB_result {
*
* Generates an array of column names
*
- * @access public
* @return array
*/
- function list_fields()
+ public function list_fields()
{
$field_names = array();
while ($field = mssql_fetch_field($this->result_id))
@@ -90,10 +85,9 @@ class CI_DB_mssql_result extends CI_DB_result {
*
* Generates an array of objects containing field meta-data
*
- * @access public
* @return array
*/
- function field_data()
+ public function field_data()
{
$retval = array();
while ($field = mssql_fetch_field($this->result_id))
@@ -116,9 +110,9 @@ class CI_DB_mssql_result extends CI_DB_result {
/**
* Free the result
*
- * @return null
+ * @return void
*/
- function free_result()
+ public function free_result()
{
if (is_resource($this->result_id))
{
@@ -136,10 +130,9 @@ class CI_DB_mssql_result extends CI_DB_result {
* this internally before fetching results to make sure the
* result set starts at zero
*
- * @access private
* @return array
*/
- function _data_seek($n = 0)
+ protected function _data_seek($n = 0)
{
return mssql_data_seek($this->result_id, $n);
}
@@ -151,10 +144,9 @@ class CI_DB_mssql_result extends CI_DB_result {
*
* Returns the result set as an array
*
- * @access private
* @return array
*/
- function _fetch_assoc()
+ protected function _fetch_assoc()
{
return mssql_fetch_assoc($this->result_id);
}
@@ -166,16 +158,14 @@ class CI_DB_mssql_result extends CI_DB_result {
*
* Returns the result set as an object
*
- * @access private
* @return object
*/
- function _fetch_object()
+ protected function _fetch_object()
{
return mssql_fetch_object($this->result_id);
}
}
-
/* End of file mssql_result.php */
/* Location: ./system/database/drivers/mssql/mssql_result.php */ \ No newline at end of file
diff --git a/system/database/drivers/mssql/mssql_utility.php b/system/database/drivers/mssql/mssql_utility.php
index 28f34b999..5c144330d 100644
--- a/system/database/drivers/mssql/mssql_utility.php
+++ b/system/database/drivers/mssql/mssql_utility.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* MS SQL Utility Class
*
@@ -39,10 +37,9 @@ class CI_DB_mssql_utility extends CI_DB_utility {
/**
* List databases
*
- * @access private
- * @return bool
+ * @return string
*/
- function _list_databases()
+ public function _list_databases()
{
return "EXEC sp_helpdb"; // Can also be: EXEC sp_databases
}
@@ -54,11 +51,10 @@ class CI_DB_mssql_utility extends CI_DB_utility {
*
* Generates a platform-specific query so that a table can be optimized
*
- * @access private
* @param string the table name
- * @return object
+ * @return bool
*/
- function _optimize_table($table)
+ public function _optimize_table($table)
{
return FALSE; // Is this supported in MS SQL?
}
@@ -70,11 +66,10 @@ class CI_DB_mssql_utility extends CI_DB_utility {
*
* Generates a platform-specific query so that a table can be repaired
*
- * @access private
* @param string the table name
- * @return object
+ * @return bool
*/
- function _repair_table($table)
+ public function _repair_table($table)
{
return FALSE; // Is this supported in MS SQL?
}
@@ -84,11 +79,10 @@ class CI_DB_mssql_utility extends CI_DB_utility {
/**
* MSSQL Export
*
- * @access private
* @param array Preferences
* @return mixed
*/
- function _backup($params = array())
+ public function _backup($params = array())
{
// Currently unsupported
return $this->db->display_error('db_unsuported_feature');
diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php
index ba646d226..bef4111c3 100644
--- a/system/database/drivers/mysql/mysql_driver.php
+++ b/system/database/drivers/mysql/mysql_driver.php
@@ -701,4 +701,4 @@ class CI_DB_mysql_driver extends CI_DB {
}
/* End of file mysql_driver.php */
-/* Location: ./system/database/drivers/mysql/mysql_driver.php */
+/* Location: ./system/database/drivers/mysql/mysql_driver.php */ \ No newline at end of file
diff --git a/system/database/drivers/mysql/mysql_forge.php b/system/database/drivers/mysql/mysql_forge.php
index d317ac3e0..11172b41b 100644
--- a/system/database/drivers/mysql/mysql_forge.php
+++ b/system/database/drivers/mysql/mysql_forge.php
@@ -237,4 +237,4 @@ class CI_DB_mysql_forge extends CI_DB_forge {
}
/* End of file mysql_forge.php */
-/* Location: ./system/database/drivers/mysql/mysql_forge.php */
+/* Location: ./system/database/drivers/mysql/mysql_forge.php */ \ No newline at end of file
diff --git a/system/database/drivers/mysql/mysql_result.php b/system/database/drivers/mysql/mysql_result.php
index cec28dc2d..f76076f4c 100644
--- a/system/database/drivers/mysql/mysql_result.php
+++ b/system/database/drivers/mysql/mysql_result.php
@@ -166,4 +166,4 @@ class CI_DB_mysql_result extends CI_DB_result {
}
/* End of file mysql_result.php */
-/* Location: ./system/database/drivers/mysql/mysql_result.php */
+/* Location: ./system/database/drivers/mysql/mysql_result.php */ \ No newline at end of file
diff --git a/system/database/drivers/mysql/mysql_utility.php b/system/database/drivers/mysql/mysql_utility.php
index d716b004a..2d89cb9cb 100644
--- a/system/database/drivers/mysql/mysql_utility.php
+++ b/system/database/drivers/mysql/mysql_utility.php
@@ -204,4 +204,4 @@ class CI_DB_mysql_utility extends CI_DB_utility {
}
/* End of file mysql_utility.php */
-/* Location: ./system/database/drivers/mysql/mysql_utility.php */
+/* Location: ./system/database/drivers/mysql/mysql_utility.php */ \ No newline at end of file
diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php
index f38b94c13..4c5d52127 100644
--- a/system/database/drivers/mysqli/mysqli_driver.php
+++ b/system/database/drivers/mysqli/mysqli_driver.php
@@ -697,4 +697,4 @@ class CI_DB_mysqli_driver extends CI_DB {
}
/* End of file mysqli_driver.php */
-/* Location: ./system/database/drivers/mysqli/mysqli_driver.php */
+/* Location: ./system/database/drivers/mysqli/mysqli_driver.php */ \ No newline at end of file
diff --git a/system/database/drivers/mysqli/mysqli_forge.php b/system/database/drivers/mysqli/mysqli_forge.php
index 9ec4bf7aa..8cf0ae1fd 100644
--- a/system/database/drivers/mysqli/mysqli_forge.php
+++ b/system/database/drivers/mysqli/mysqli_forge.php
@@ -237,4 +237,4 @@ class CI_DB_mysqli_forge extends CI_DB_forge {
}
/* End of file mysqli_forge.php */
-/* Location: ./system/database/drivers/mysqli/mysqli_forge.php */
+/* Location: ./system/database/drivers/mysqli/mysqli_forge.php */ \ No newline at end of file
diff --git a/system/database/drivers/mysqli/mysqli_result.php b/system/database/drivers/mysqli/mysqli_result.php
index f135f4d46..83d88aae3 100644
--- a/system/database/drivers/mysqli/mysqli_result.php
+++ b/system/database/drivers/mysqli/mysqli_result.php
@@ -167,4 +167,4 @@ class CI_DB_mysqli_result extends CI_DB_result {
}
/* End of file mysqli_result.php */
-/* Location: ./system/database/drivers/mysqli/mysqli_result.php */
+/* Location: ./system/database/drivers/mysqli/mysqli_result.php */ \ No newline at end of file
diff --git a/system/database/drivers/mysqli/mysqli_utility.php b/system/database/drivers/mysqli/mysqli_utility.php
index 650ddfd18..4d7002e78 100644
--- a/system/database/drivers/mysqli/mysqli_utility.php
+++ b/system/database/drivers/mysqli/mysqli_utility.php
@@ -90,4 +90,4 @@ class CI_DB_mysqli_utility extends CI_DB_utility {
}
/* End of file mysqli_utility.php */
-/* Location: ./system/database/drivers/mysqli/mysqli_utility.php */
+/* Location: ./system/database/drivers/mysqli/mysqli_utility.php */ \ No newline at end of file
diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php
index 070d58a34..3bc8c114c 100644
--- a/system/database/drivers/oci8/oci8_driver.php
+++ b/system/database/drivers/oci8/oci8_driver.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* oci8 Database Adapter Class
*
@@ -50,46 +48,125 @@
* @author Kelly McArdle
*
*/
-
class CI_DB_oci8_driver extends CI_DB {
- var $dbdriver = 'oci8';
+ public $dbdriver = 'oci8';
// The character used for excaping
- var $_escape_char = '"';
+ protected $_escape_char = '"';
// clause and character used for LIKE escape sequences
- var $_like_escape_str = " escape '%s' ";
- var $_like_escape_chr = '!';
+ protected $_like_escape_str = " ESCAPE '%s' ";
+ protected $_like_escape_chr = '!';
/**
* The syntax to count rows is slightly different across different
* database engines, so this string appears in each driver and is
* used for the count_all() and count_all_results() functions.
*/
- var $_count_string = "SELECT COUNT(1) AS ";
- var $_random_keyword = ' ASC'; // not currently supported
+ protected $_count_string = 'SELECT COUNT(1) AS ';
+ protected $_random_keyword = ' ASC'; // not currently supported
// Set "auto commit" by default
- var $_commit = OCI_COMMIT_ON_SUCCESS;
+ protected $_commit = OCI_COMMIT_ON_SUCCESS;
// need to track statement id and cursor id
- var $stmt_id;
- var $curs_id;
+ public $stmt_id;
+ public $curs_id;
// if we use a limit, we will add a field that will
// throw off num_fields later
- var $limit_used;
+ public $limit_used;
+
+ public function __construct($params)
+ {
+ parent::__construct($params);
+
+ $valid_dsns = array(
+ 'tns' => '/^\(DESCRIPTION=(\(.+\)){2,}\)$/', // TNS
+ // Easy Connect string (Oracle 10g+)
+ 'ec' => '/^(\/\/)?[a-z0-9.:_-]+(:[1-9][0-9]{0,4})?(\/[a-z0-9$_]+)?(:[^\/])?(\/[a-z0-9$_]+)?$/i',
+ 'in' => '/^[a-z0-9$_]+$/i' // Instance name (defined in tnsnames.ora)
+ );
+
+ /* Space characters don't have any effect when actually
+ * connecting, but can be a hassle while validating the DSN.
+ */
+ $this->dsn = str_replace(array("\n", "\r", "\t", ' '), '', $this->dsn);
+
+ if ($this->dsn !== '')
+ {
+ foreach ($valid_dsns as $regexp)
+ {
+ if (preg_match($regexp, $this->dsn))
+ {
+ return;
+ }
+ }
+ }
+
+ // Legacy support for TNS in the hostname configuration field
+ $this->hostname = str_replace(array("\n", "\r", "\t", ' '), '', $this->hostname);
+ if (preg_match($valid_dsns['tns'], $this->hostname))
+ {
+ $this->dsn = $this->hostname;
+ return;
+ }
+ elseif ($this->hostname !== '' && strpos($this->hostname, '/') === FALSE && strpos($this->hostname, ':') === FALSE
+ && (( ! empty($this->port) && ctype_digit($this->port)) OR $this->database !== ''))
+ {
+ /* If the hostname field isn't empty, doesn't contain
+ * ':' and/or '/' and if port and/or database aren't
+ * empty, then the hostname field is most likely indeed
+ * just a hostname. Therefore we'll try and build an
+ * Easy Connect string from these 3 settings, assuming
+ * that the database field is a service name.
+ */
+ $this->dsn = $this->hostname
+ .(( ! empty($this->port) && ctype_digit($this->port)) ? ':'.$this->port : '')
+ .($this->database !== '' ? '/'.ltrim($this->database, '/') : '');
+
+ if (preg_match($valid_dsns['ec'], $this->dsn))
+ {
+ return;
+ }
+ }
+
+ /* At this point, we can only try and validate the hostname and
+ * database fields separately as DSNs.
+ */
+ if (preg_match($valid_dsns['ec'], $this->hostname) OR preg_match($valid_dsns['in'], $this->hostname))
+ {
+ $this->dsn = $this->hostname;
+ return;
+ }
+
+ $this->database = str_replace(array("\n", "\r", "\t", ' '), '', $this->database);
+ foreach ($valid_dsns as $regexp)
+ {
+ if (preg_match($regexp, $this->database))
+ {
+ return;
+ }
+ }
+
+ /* Well - OK, an empty string should work as well.
+ * PHP will try to use environment variables to
+ * determine which Oracle instance to connect to.
+ */
+ $this->dsn = '';
+ }
/**
* Non-persistent database connection
*
- * @access private called by the base class
- * @return resource
+ * @return resource
*/
public function db_connect()
{
- return @oci_connect($this->username, $this->password, $this->hostname, $this->char_set);
+ return ( ! empty($this->char_set))
+ ? @oci_connect($this->username, $this->password, $this->dsn, $this->char_set)
+ : @oci_connect($this->username, $this->password, $this->dsn);
}
// --------------------------------------------------------------------
@@ -97,29 +174,13 @@ class CI_DB_oci8_driver extends CI_DB {
/**
* Persistent database connection
*
- * @access private called by the base class
- * @return resource
+ * @return resource
*/
public function db_pconnect()
{
- return @oci_pconnect($this->username, $this->password, $this->hostname, $this->char_set);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Reconnect
- *
- * Keep / reestablish the db connection if no queries have been
- * sent for a length of time exceeding the server's idle timeout
- *
- * @access public
- * @return void
- */
- public function reconnect()
- {
- // not implemented in oracle
- return;
+ return ( ! empty($this->char_set))
+ ? @oci_pconnect($this->username, $this->password, $this->dsn, $this->char_set)
+ : @oci_pconnect($this->username, $this->password, $this->dsn);
}
// --------------------------------------------------------------------
@@ -127,8 +188,7 @@ class CI_DB_oci8_driver extends CI_DB {
/**
* Select the database
*
- * @access private called by the base class
- * @return resource
+ * @return resource
*/
public function db_select()
{
@@ -155,9 +215,8 @@ class CI_DB_oci8_driver extends CI_DB {
/**
* Execute the query
*
- * @access protected called by the base class
- * @param string an SQL query
- * @return resource
+ * @param string an SQL query
+ * @return resource
*/
protected function _execute($sql)
{
@@ -172,41 +231,23 @@ class CI_DB_oci8_driver extends CI_DB {
/**
* Generate a statement ID
*
- * @access private
- * @param string an SQL query
- * @return none
+ * @param string an SQL query
+ * @return void
*/
- private function _set_stmt_id($sql)
+ protected function _set_stmt_id($sql)
{
if ( ! is_resource($this->stmt_id))
{
- $this->stmt_id = oci_parse($this->conn_id, $this->_prep_query($sql));
+ $this->stmt_id = oci_parse($this->conn_id, $sql);
}
}
// --------------------------------------------------------------------
/**
- * Prep the query
+ * Get cursor. Returns a cursor from the database
*
- * If needed, each database adapter can prep the query string
- *
- * @access private called by execute()
- * @param string an SQL query
- * @return string
- */
- private function _prep_query($sql)
- {
- return $sql;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * getCursor. Returns a cursor from the datbase
- *
- * @access public
- * @return cursor id
+ * @return cursor id
*/
public function get_cursor()
{
@@ -219,11 +260,10 @@ class CI_DB_oci8_driver extends CI_DB {
/**
* Stored Procedure. Executes a stored procedure
*
- * @access public
- * @param package package stored procedure is in
- * @param procedure stored procedure to execute
- * @param params array of parameters
- * @return array
+ * @param string package stored procedure is in
+ * @param string stored procedure to execute
+ * @param array parameters
+ * @return object
*
* params array keys
*
@@ -272,10 +312,9 @@ class CI_DB_oci8_driver extends CI_DB {
/**
* Bind parameters
*
- * @access private
- * @return none
+ * @return void
*/
- private function _bind_params($params)
+ protected function _bind_params($params)
{
if ( ! is_array($params) OR ! is_resource($this->stmt_id))
{
@@ -301,7 +340,6 @@ class CI_DB_oci8_driver extends CI_DB {
/**
* Begin Transaction
*
- * @access public
* @return bool
*/
public function trans_begin($test_mode = FALSE)
@@ -331,7 +369,6 @@ class CI_DB_oci8_driver extends CI_DB {
/**
* Commit Transaction
*
- * @access public
* @return bool
*/
public function trans_commit()
@@ -357,7 +394,6 @@ class CI_DB_oci8_driver extends CI_DB {
/**
* Rollback Transaction
*
- * @access public
* @return bool
*/
public function trans_rollback()
@@ -417,8 +453,7 @@ class CI_DB_oci8_driver extends CI_DB {
/**
* Affected Rows
*
- * @access public
- * @return integer
+ * @return int
*/
public function affected_rows()
{
@@ -430,8 +465,7 @@ class CI_DB_oci8_driver extends CI_DB {
/**
* Insert ID
*
- * @access public
- * @return integer
+ * @return int
*/
public function insert_id()
{
@@ -447,9 +481,8 @@ class CI_DB_oci8_driver extends CI_DB {
* Generates a platform-specific query string that counts all records in
* the specified database
*
- * @access public
- * @param string
- * @return string
+ * @param string
+ * @return string
*/
public function count_all($table = '')
{
@@ -476,8 +509,7 @@ class CI_DB_oci8_driver extends CI_DB {
*
* Generates a platform-specific query string so that the table names can be fetched
*
- * @access protected
- * @param boolean
+ * @param bool
* @return string
*/
protected function _list_tables($prefix_limit = FALSE)
@@ -499,9 +531,8 @@ class CI_DB_oci8_driver extends CI_DB {
*
* Generates a platform-specific query string so that the column names can be fetched
*
- * @access protected
- * @param string the table name
- * @return string
+ * @param string the table name
+ * @return string
*/
protected function _list_columns($table = '')
{
@@ -515,9 +546,8 @@ class CI_DB_oci8_driver extends CI_DB {
*
* Generates a platform-specific query so that the column data can be retrieved
*
- * @access public
- * @param string the table name
- * @return object
+ * @param string the table name
+ * @return string
*/
protected function _field_data($table)
{
@@ -562,11 +592,10 @@ class CI_DB_oci8_driver extends CI_DB {
*
* This function escapes column and table names
*
- * @access protected
* @param string
* @return string
*/
- protected function _escape_identifiers($item)
+ public function _escape_identifiers($item)
{
if ($this->_escape_char == '')
{
@@ -605,9 +634,8 @@ class CI_DB_oci8_driver extends CI_DB {
* This function implicitly groups FROM tables so there is no confusion
* about operator precedence in harmony with SQL standards
*
- * @access protected
- * @param type
- * @return type
+ * @param array
+ * @return string
*/
protected function _from_tables($tables)
{
@@ -626,11 +654,10 @@ class CI_DB_oci8_driver extends CI_DB {
*
* Generates a platform-specific insert string from the supplied data
*
- * @access public
- * @param string the table name
- * @param array the insert keys
- * @param array the insert values
- * @return string
+ * @param string the table name
+ * @param array the insert keys
+ * @param array the insert values
+ * @return string
*/
protected function _insert($table, $keys, $values)
{
@@ -644,10 +671,10 @@ class CI_DB_oci8_driver extends CI_DB {
*
* Generates a platform-specific insert string from the supplied data
*
- * @param string the table name
- * @param array the insert keys
- * @param array the insert values
- * @return string
+ * @param string the table name
+ * @param array the insert keys
+ * @param array the insert values
+ * @return string
*/
protected function _insert_batch($table, $keys, $values)
{
@@ -671,7 +698,6 @@ class CI_DB_oci8_driver extends CI_DB {
*
* Generates a platform-specific update string from the supplied data
*
- * @access protected
* @param string the table name
* @param array the update data
* @param array the where clause
@@ -708,7 +734,6 @@ class CI_DB_oci8_driver extends CI_DB {
* If the database does not support the truncate() command
* This function maps to "DELETE FROM table"
*
- * @access protected
* @param string the table name
* @return string
*/
@@ -724,7 +749,6 @@ class CI_DB_oci8_driver extends CI_DB {
*
* Generates a platform-specific delete string from the supplied data
*
- * @access protected
* @param string the table name
* @param array the where clause
* @param string the limit clause
@@ -758,11 +782,10 @@ class CI_DB_oci8_driver extends CI_DB {
*
* Generates a platform-specific LIMIT clause
*
- * @access protected
- * @param string the sql query string
- * @param integer the number of rows to limit the query to
- * @param integer the offset value
- * @return string
+ * @param string the sql query string
+ * @param int the number of rows to limit the query to
+ * @param int the offset value
+ * @return string
*/
protected function _limit($sql, $limit, $offset)
{
@@ -785,19 +808,15 @@ class CI_DB_oci8_driver extends CI_DB {
/**
* Close DB Connection
*
- * @access protected
- * @param resource
- * @return void
+ * @param resource
+ * @return void
*/
protected function _close($conn_id)
{
@oci_close($conn_id);
}
-
}
-
-
/* End of file oci8_driver.php */
-/* Location: ./system/database/drivers/oci8/oci8_driver.php */
+/* Location: ./system/database/drivers/oci8/oci8_driver.php */ \ No newline at end of file
diff --git a/system/database/drivers/oci8/oci8_forge.php b/system/database/drivers/oci8/oci8_forge.php
index 7fcc8094d..8285a29d2 100644
--- a/system/database/drivers/oci8/oci8_forge.php
+++ b/system/database/drivers/oci8/oci8_forge.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* Oracle Forge Class
*
@@ -39,11 +37,10 @@ class CI_DB_oci8_forge extends CI_DB_forge {
/**
* Create database
*
- * @access public
* @param string the database name
* @return bool
*/
- function _create_database($name)
+ public function _create_database($name)
{
return FALSE;
}
@@ -53,11 +50,10 @@ class CI_DB_oci8_forge extends CI_DB_forge {
/**
* Drop database
*
- * @access private
* @param string the database name
* @return bool
*/
- function _drop_database($name)
+ public function _drop_database($name)
{
return FALSE;
}
@@ -144,10 +140,9 @@ class CI_DB_oci8_forge extends CI_DB_forge {
/**
* Drop Table
*
- * @access private
* @return bool
*/
- function _drop_table($table)
+ public function _drop_table($table)
{
return FALSE;
}
@@ -160,17 +155,16 @@ class CI_DB_oci8_forge extends CI_DB_forge {
* Generates a platform-specific query so that a table can be altered
* Called by add_column(), drop_column(), and column_alter(),
*
- * @access private
* @param string the ALTER type (ADD, DROP, CHANGE)
* @param string the column name
* @param string the table name
* @param string the column definition
* @param string the default value
- * @param boolean should 'NOT NULL' be added
+ * @param bool should 'NOT NULL' be added
* @param string the field after which we should add the new field
- * @return object
+ * @return string
*/
- function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '')
+ public function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '')
{
$sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '.$this->db->protect_identifiers($column_name);
@@ -212,12 +206,11 @@ class CI_DB_oci8_forge extends CI_DB_forge {
*
* Generates a platform-specific query so that a table can be renamed
*
- * @access private
* @param string the old table name
* @param string the new table name
* @return string
*/
- function _rename_table($table_name, $new_table_name)
+ public function _rename_table($table_name, $new_table_name)
{
return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name);
}
@@ -225,4 +218,4 @@ class CI_DB_oci8_forge extends CI_DB_forge {
}
/* End of file oci8_forge.php */
-/* Location: ./system/database/drivers/oci8/oci8_forge.php */
+/* Location: ./system/database/drivers/oci8/oci8_forge.php */ \ No newline at end of file
diff --git a/system/database/drivers/oci8/oci8_result.php b/system/database/drivers/oci8/oci8_result.php
index 6f1b8b4c1..c3f775730 100644
--- a/system/database/drivers/oci8/oci8_result.php
+++ b/system/database/drivers/oci8/oci8_result.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* oci8 Result Class
*
@@ -57,9 +55,7 @@ class CI_DB_oci8_result extends CI_DB_result {
* Oracle doesn't have a graceful way to retun the number of rows
* so we have to use what amounts to a hack.
*
- *
- * @access public
- * @return integer
+ * @return int
*/
public function num_rows()
{
@@ -82,8 +78,7 @@ class CI_DB_oci8_result extends CI_DB_result {
/**
* Number of fields in the result set
*
- * @access public
- * @return integer
+ * @return int
*/
public function num_fields()
{
@@ -105,7 +100,6 @@ class CI_DB_oci8_result extends CI_DB_result {
*
* Generates an array of column names
*
- * @access public
* @return array
*/
public function list_fields()
@@ -125,8 +119,7 @@ class CI_DB_oci8_result extends CI_DB_result {
*
* Generates an array of objects containing field meta-data
*
- * @access public
- * @return array
+ * @return array
*/
public function field_data()
{
@@ -149,7 +142,7 @@ class CI_DB_oci8_result extends CI_DB_result {
/**
* Free the result
*
- * @return null
+ * @return void
*/
public function free_result()
{
@@ -167,8 +160,7 @@ class CI_DB_oci8_result extends CI_DB_result {
*
* Returns the result set as an array
*
- * @access protected
- * @return array
+ * @return array
*/
protected function _fetch_assoc()
{
@@ -183,8 +175,7 @@ class CI_DB_oci8_result extends CI_DB_result {
*
* Returns the result set as an object
*
- * @access protected
- * @return object
+ * @return object
*/
protected function _fetch_object()
{
@@ -197,8 +188,7 @@ class CI_DB_oci8_result extends CI_DB_result {
/**
* Query result. "array" version.
*
- * @access public
- * @return array
+ * @return array
*/
public function result_array()
{
@@ -221,11 +211,10 @@ class CI_DB_oci8_result extends CI_DB_result {
/**
* Data Seek
*
- * Moves the internal pointer to the desired offset. We call
+ * Moves the internal pointer to the desired offset. We call
* this internally before fetching results to make sure the
* result set starts at zero
*
- * @access protected
* @return array
*/
protected function _data_seek($n = 0)
@@ -235,6 +224,5 @@ class CI_DB_oci8_result extends CI_DB_result {
}
-
/* End of file oci8_result.php */
-/* Location: ./system/database/drivers/oci8/oci8_result.php */
+/* Location: ./system/database/drivers/oci8/oci8_result.php */ \ No newline at end of file
diff --git a/system/database/drivers/oci8/oci8_utility.php b/system/database/drivers/oci8/oci8_utility.php
index 62dfb2f3c..e303fb6cb 100644
--- a/system/database/drivers/oci8/oci8_utility.php
+++ b/system/database/drivers/oci8/oci8_utility.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* Oracle Utility Class
*
@@ -39,10 +37,9 @@ class CI_DB_oci8_utility extends CI_DB_utility {
/**
* List databases
*
- * @access private
* @return bool
*/
- function _list_databases()
+ public function _list_databases()
{
return FALSE;
}
@@ -54,11 +51,10 @@ class CI_DB_oci8_utility extends CI_DB_utility {
*
* Generates a platform-specific query so that a table can be optimized
*
- * @access private
* @param string the table name
- * @return object
+ * @return bool
*/
- function _optimize_table($table)
+ public function _optimize_table($table)
{
return FALSE; // Is this supported in Oracle?
}
@@ -70,11 +66,10 @@ class CI_DB_oci8_utility extends CI_DB_utility {
*
* Generates a platform-specific query so that a table can be repaired
*
- * @access private
* @param string the table name
- * @return object
+ * @return bool
*/
- function _repair_table($table)
+ public function _repair_table($table)
{
return FALSE; // Is this supported in Oracle?
}
@@ -84,15 +79,15 @@ class CI_DB_oci8_utility extends CI_DB_utility {
/**
* Oracle Export
*
- * @access private
* @param array Preferences
* @return mixed
*/
- function _backup($params = array())
+ public function _backup($params = array())
{
// Currently unsupported
return $this->db->display_error('db_unsuported_feature');
}
+
}
/* End of file oci8_utility.php */
diff --git a/system/database/drivers/odbc/odbc_driver.php b/system/database/drivers/odbc/odbc_driver.php
index cfa561c3d..ad773117f 100644
--- a/system/database/drivers/odbc/odbc_driver.php
+++ b/system/database/drivers/odbc/odbc_driver.php
@@ -57,12 +57,17 @@ class CI_DB_odbc_driver extends CI_DB {
protected $_count_string = 'SELECT COUNT(*) AS ';
protected $_random_keyword;
-
public function __construct($params)
{
parent::__construct($params);
$this->_random_keyword = ' RND('.time().')'; // database specific random keyword
+
+ // Legacy support for DSN in the hostname field
+ if ($this->dsn == '')
+ {
+ $this->dsn = $this->hostname;
+ }
}
/**
@@ -72,7 +77,7 @@ class CI_DB_odbc_driver extends CI_DB {
*/
public function db_connect()
{
- return @odbc_connect($this->hostname, $this->username, $this->password);
+ return @odbc_connect($this->dsn, $this->username, $this->password);
}
// --------------------------------------------------------------------
@@ -84,22 +89,7 @@ class CI_DB_odbc_driver extends CI_DB {
*/
public function db_pconnect()
{
- return @odbc_pconnect($this->hostname, $this->username, $this->password);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Reconnect
- *
- * Keep / reestablish the db connection if no queries have been
- * sent for a length of time exceeding the server's idle timeout
- *
- * @return void
- */
- public function reconnect()
- {
- // not implemented in odbc
+ return @odbc_pconnect($this->dsn, $this->username, $this->password);
}
// --------------------------------------------------------------------
@@ -125,28 +115,12 @@ class CI_DB_odbc_driver extends CI_DB {
*/
protected function _execute($sql)
{
- $sql = $this->_prep_query($sql);
return @odbc_exec($this->conn_id, $sql);
}
// --------------------------------------------------------------------
/**
- * Prep the query
- *
- * If needed, each database adapter can prep the query string
- *
- * @param string an SQL query
- * @return string
- */
- protected function _prep_query($sql)
- {
- return $sql;
- }
-
- // --------------------------------------------------------------------
-
- /**
* Begin Transaction
*
* @return bool
@@ -577,4 +551,4 @@ class CI_DB_odbc_driver extends CI_DB {
}
/* End of file odbc_driver.php */
-/* Location: ./system/database/drivers/odbc/odbc_driver.php */
+/* Location: ./system/database/drivers/odbc/odbc_driver.php */ \ No newline at end of file
diff --git a/system/database/drivers/odbc/odbc_forge.php b/system/database/drivers/odbc/odbc_forge.php
index 26a524a64..486a8dd7f 100644
--- a/system/database/drivers/odbc/odbc_forge.php
+++ b/system/database/drivers/odbc/odbc_forge.php
@@ -265,4 +265,4 @@ class CI_DB_odbc_forge extends CI_DB_forge {
}
/* End of file odbc_forge.php */
-/* Location: ./system/database/drivers/odbc/odbc_forge.php */
+/* Location: ./system/database/drivers/odbc/odbc_forge.php */ \ No newline at end of file
diff --git a/system/database/drivers/odbc/odbc_result.php b/system/database/drivers/odbc/odbc_result.php
index f6aee356f..30cc979ce 100644
--- a/system/database/drivers/odbc/odbc_result.php
+++ b/system/database/drivers/odbc/odbc_result.php
@@ -319,4 +319,4 @@ class CI_DB_odbc_result extends CI_DB_result {
}
/* End of file odbc_result.php */
-/* Location: ./system/database/drivers/odbc/odbc_result.php */
+/* Location: ./system/database/drivers/odbc/odbc_result.php */ \ No newline at end of file
diff --git a/system/database/drivers/odbc/odbc_utility.php b/system/database/drivers/odbc/odbc_utility.php
index 5244f084f..65445e96c 100644
--- a/system/database/drivers/odbc/odbc_utility.php
+++ b/system/database/drivers/odbc/odbc_utility.php
@@ -106,4 +106,4 @@ class CI_DB_odbc_utility extends CI_DB_utility {
}
/* End of file odbc_utility.php */
-/* Location: ./system/database/drivers/odbc/odbc_utility.php */
+/* Location: ./system/database/drivers/odbc/odbc_utility.php */ \ No newline at end of file
diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php
index 658a3d5a0..19338e30f 100644
--- a/system/database/drivers/pdo/pdo_driver.php
+++ b/system/database/drivers/pdo/pdo_driver.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* PDO Database Adapter Class
*
@@ -42,28 +40,28 @@
*/
class CI_DB_pdo_driver extends CI_DB {
- var $dbdriver = 'pdo';
+ public $dbdriver = 'pdo';
// the character used to excape - not necessary for PDO
- var $_escape_char = '';
+ protected $_escape_char = '';
// clause and character used for LIKE escape sequences
- var $_like_escape_str;
- var $_like_escape_chr;
+ protected $_like_escape_str;
+ protected $_like_escape_chr;
/**
* The syntax to count rows is slightly different across different
* database engines, so this string appears in each driver and is
* used for the count_all() and count_all_results() functions.
*/
- var $_count_string = "SELECT COUNT(*) AS ";
- var $_random_keyword;
+ protected $_count_string = 'SELECT COUNT(*) AS ';
+ protected $_random_keyword;
// need to track the pdo driver and options
- var $pdodriver;
- var $options = array();
+ public $pdodriver;
+ public $options = array();
- function __construct($params)
+ public function __construct($params)
{
parent::__construct($params);
@@ -96,19 +94,18 @@ class CI_DB_pdo_driver extends CI_DB {
$this->_like_escape_str = " ESCAPE '%s' ";
$this->_like_escape_chr = '!';
}
-
- $this->trans_enabled = FALSE;
+
+ $this->trans_enabled = FALSE;
$this->_random_keyword = ' RND('.time().')'; // database specific random keyword
}
/**
* Connection String
*
- * @access private
* @param array
* @return void
*/
- function _connect_string($params)
+ protected function _connect_string($params)
{
if (strpos($this->hostname, ':'))
{
@@ -138,7 +135,7 @@ class CI_DB_pdo_driver extends CI_DB {
$this->dsn = $this->pdodriver.':';
// Add hostname to the DSN for databases that need it
- if ( ! empty($this->hostname)
+ if ( ! empty($this->hostname)
&& strpos($this->hostname, ':') === FALSE
&& in_array($this->pdodriver, array('informix', 'mysql', 'pgsql', 'sybase', 'mssql', 'dblib', 'cubrid')))
{
@@ -153,7 +150,7 @@ class CI_DB_pdo_driver extends CI_DB {
}
// Add the database name to the DSN, if needed
- if (stripos($this->dsn, 'dbname') === FALSE
+ if (stripos($this->dsn, 'dbname') === FALSE
&& in_array($this->pdodriver, array('4D', 'pgsql', 'mysql', 'firebird', 'sybase', 'mssql', 'dblib', 'cubrid')))
{
$this->dsn .= 'dbname='.$this->database.';';
@@ -190,10 +187,9 @@ class CI_DB_pdo_driver extends CI_DB {
/**
* Non-persistent database connection
*
- * @access private called by the base class
- * @return resource
+ * @return object
*/
- function db_connect()
+ public function db_connect()
{
$this->options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_SILENT;
@@ -205,14 +201,13 @@ class CI_DB_pdo_driver extends CI_DB {
/**
* Persistent database connection
*
- * @access private called by the base class
- * @return resource
+ * @return object
*/
- function db_pconnect()
+ public function db_pconnect()
{
- $this->options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_SILENT;
+ $this->options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_SILENT;
$this->options[PDO::ATTR_PERSISTENT] = TRUE;
-
+
return $this->pdo_connect();
}
@@ -221,23 +216,22 @@ class CI_DB_pdo_driver extends CI_DB {
/**
* PDO connection
*
- * @access private called by the PDO driver class
- * @return resource
+ * @return object
*/
- function pdo_connect()
+ public function pdo_connect()
{
// Refer : http://php.net/manual/en/ref.pdo-mysql.connection.php
- if ($this->pdodriver == 'mysql' && is_php('5.3.6'))
+ if ($this->pdodriver === 'mysql' && ! is_php('5.3.6'))
{
$this->options[PDO::MYSQL_ATTR_INIT_COMMAND] = "SET NAMES $this->char_set COLLATE '$this->dbcollat'";
}
// Connecting...
- try
+ try
{
$db = new PDO($this->dsn, $this->username, $this->password, $this->options);
- }
- catch (PDOException $e)
+ }
+ catch (PDOException $e)
{
if ($this->db_debug && empty($this->failover))
{
@@ -253,33 +247,11 @@ class CI_DB_pdo_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * Reconnect
- *
- * Keep / reestablish the db connection if no queries have been
- * sent for a length of time exceeding the server's idle timeout
- *
- * @access public
- * @return void
- */
- function reconnect()
- {
- if ($this->db->db_debug)
- {
- return $this->db->display_error('db_unsuported_feature');
- }
-
- return FALSE;
- }
-
- // --------------------------------------------------------------------
-
- /**
* Select the database
*
- * @access private called by the base class
* @return resource
*/
- function db_select()
+ public function db_select()
{
// Not needed for PDO
return TRUE;
@@ -304,16 +276,15 @@ class CI_DB_pdo_driver extends CI_DB {
/**
* Execute the query
*
- * @access private called by the base class
* @param string an SQL query
- * @return object
+ * @return mixed
*/
- function _execute($sql)
+ protected function _execute($sql)
{
$sql = $this->_prep_query($sql);
$result_id = $this->conn_id->query($sql);
-
+
if (is_object($result_id))
{
$this->affect_rows = $result_id->rowCount();
@@ -322,7 +293,7 @@ class CI_DB_pdo_driver extends CI_DB {
{
$this->affect_rows = 0;
}
-
+
return $result_id;
}
@@ -333,11 +304,10 @@ class CI_DB_pdo_driver extends CI_DB {
*
* If needed, each database adapter can prep the query string
*
- * @access private called by execute()
* @param string an SQL query
* @return string
*/
- function _prep_query($sql)
+ protected function _prep_query($sql)
{
if ($this->pdodriver === 'pgsql')
{
@@ -358,10 +328,9 @@ class CI_DB_pdo_driver extends CI_DB {
/**
* Begin Transaction
*
- * @access public
* @return bool
*/
- function trans_begin($test_mode = FALSE)
+ public function trans_begin($test_mode = FALSE)
{
if ( ! $this->trans_enabled)
{
@@ -387,10 +356,9 @@ class CI_DB_pdo_driver extends CI_DB {
/**
* Commit Transaction
*
- * @access public
* @return bool
*/
- function trans_commit()
+ public function trans_commit()
{
if ( ! $this->trans_enabled)
{
@@ -404,7 +372,7 @@ class CI_DB_pdo_driver extends CI_DB {
}
$ret = $this->conn->commit();
-
+
return $ret;
}
@@ -413,10 +381,9 @@ class CI_DB_pdo_driver extends CI_DB {
/**
* Rollback Transaction
*
- * @access public
* @return bool
*/
- function trans_rollback()
+ public function trans_rollback()
{
if ( ! $this->trans_enabled)
{
@@ -439,12 +406,11 @@ class CI_DB_pdo_driver extends CI_DB {
/**
* Escape String
*
- * @access public
* @param string
* @param bool whether or not the string will be used in a LIKE condition
* @return string
*/
- function escape_str($str, $like = FALSE)
+ public function escape_str($str, $like = FALSE)
{
if (is_array($str))
{
@@ -455,24 +421,22 @@ class CI_DB_pdo_driver extends CI_DB {
return $str;
}
-
+
//Escape the string
$str = $this->conn_id->quote($str);
-
+
//If there are duplicated quotes, trim them away
if (strpos($str, "'") === 0)
{
$str = substr($str, 1, -1);
}
-
+
// escape LIKE condition wildcards
if ($like === TRUE)
{
- $str = 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;
@@ -483,10 +447,9 @@ class CI_DB_pdo_driver extends CI_DB {
/**
* Affected Rows
*
- * @access public
- * @return integer
+ * @return int
*/
- function affected_rows()
+ public function affected_rows()
{
return $this->affect_rows;
}
@@ -518,7 +481,6 @@ class CI_DB_pdo_driver extends CI_DB {
* Generates a platform-specific query string that counts all records in
* the specified database
*
- * @access public
* @param string
* @return string
*/
@@ -550,11 +512,10 @@ class CI_DB_pdo_driver extends CI_DB {
*
* Generates a platform-specific query string so that the table names can be fetched
*
- * @access private
- * @param boolean
+ * @param bool
* @return string
*/
- function _list_tables($prefix_limit = FALSE)
+ protected function _list_tables($prefix_limit = FALSE)
{
if ($this->pdodriver == 'pgsql')
{
@@ -573,7 +534,7 @@ class CI_DB_pdo_driver extends CI_DB {
if ($prefix_limit !== FALSE AND $this->dbprefix != '')
{
- return FALSE;
+ return FALSE;
}
return $sql;
@@ -586,11 +547,10 @@ class CI_DB_pdo_driver extends CI_DB {
*
* Generates a platform-specific query string so that the column names can be fetched
*
- * @access public
* @param string the table name
* @return string
*/
- function _list_columns($table = '')
+ protected function _list_columns($table = '')
{
return 'SHOW COLUMNS FROM '.$this->_from_tables($table);
}
@@ -602,11 +562,10 @@ class CI_DB_pdo_driver extends CI_DB {
*
* Generates a platform-specific query so that the column data can be retrieved
*
- * @access public
* @param string the table name
- * @return object
+ * @return string
*/
- function _field_data($table)
+ protected function _field_data($table)
{
if ($this->pdodriver == 'mysql' or $this->pdodriver == 'pgsql')
{
@@ -623,7 +582,7 @@ class CI_DB_pdo_driver extends CI_DB {
// Analog function for sqlite
return 'PRAGMA table_info('.$this->_from_tables($table).')';
}
-
+
return 'SELECT TOP 1 FROM '.$this->_from_tables($table);
}
@@ -663,11 +622,10 @@ class CI_DB_pdo_driver extends CI_DB {
*
* This function escapes column and table names
*
- * @access private
* @param string
* @return string
*/
- function _escape_identifiers($item)
+ public function _escape_identifiers($item)
{
if ($this->_escape_char == '')
{
@@ -707,11 +665,10 @@ class CI_DB_pdo_driver extends CI_DB {
* This function implicitly groups FROM tables so there is no confusion
* about operator precedence in harmony with SQL standards
*
- * @access public
- * @param type
- * @return type
+ * @param array
+ * @return string
*/
- function _from_tables($tables)
+ protected function _from_tables($tables)
{
if ( ! is_array($tables))
{
@@ -728,17 +685,16 @@ class CI_DB_pdo_driver extends CI_DB {
*
* Generates a platform-specific insert string from the supplied data
*
- * @access public
* @param string the table name
* @param array the insert keys
* @param array the insert values
* @return string
*/
- function _insert($table, $keys, $values)
+ protected function _insert($table, $keys, $values)
{
return 'INSERT INTO '.$this->_from_tables($table).' ('.implode(', ', $keys).') VALUES ('.implode(', ', $values).')';
}
-
+
// --------------------------------------------------------------------
/**
@@ -746,13 +702,12 @@ class CI_DB_pdo_driver extends CI_DB {
*
* Generates a platform-specific insert string from the supplied data
*
- * @access public
- * @param string the table name
- * @param array the insert keys
- * @param array the insert values
- * @return string
+ * @param string the table name
+ * @param array the insert keys
+ * @param array the insert values
+ * @return string
*/
- function _insert_batch($table, $keys, $values)
+ protected function _insert_batch($table, $keys, $values)
{
return 'INSERT INTO '.$this->_from_tables($table).' ('.implode(', ', $keys).') VALUES '.implode(', ', $values);
}
@@ -764,7 +719,6 @@ class CI_DB_pdo_driver extends CI_DB {
*
* Generates a platform-specific update string from the supplied data
*
- * @access public
* @param string the table name
* @param array the update data
* @param array the where clause
@@ -772,7 +726,7 @@ class CI_DB_pdo_driver extends CI_DB {
* @param array the limit clause
* @return string
*/
- function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
+ protected function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
{
foreach ($values as $key => $val)
{
@@ -788,7 +742,7 @@ class CI_DB_pdo_driver extends CI_DB {
return $sql;
}
-
+
// --------------------------------------------------------------------
/**
@@ -796,13 +750,12 @@ class CI_DB_pdo_driver extends CI_DB {
*
* Generates a platform-specific batch update string from the supplied data
*
- * @access public
* @param string the table name
* @param array the update data
* @param array the where clause
* @return string
*/
- function _update_batch($table, $values, $index, $where = NULL)
+ protected function _update_batch($table, $values, $index, $where = NULL)
{
$ids = array();
$where = ($where != '' && count($where) >=1) ? implode(" ", $where).' AND ' : '';
@@ -841,7 +794,6 @@ class CI_DB_pdo_driver extends CI_DB {
return $sql;
}
-
// --------------------------------------------------------------------
/**
@@ -851,11 +803,10 @@ class CI_DB_pdo_driver extends CI_DB {
* If the database does not support the truncate() command
* This function maps to "DELETE FROM table"
*
- * @access public
* @param string the table name
* @return string
*/
- function _truncate($table)
+ protected function _truncate($table)
{
return $this->_delete($table);
}
@@ -867,13 +818,12 @@ class CI_DB_pdo_driver extends CI_DB {
*
* Generates a platform-specific delete string from the supplied data
*
- * @access public
* @param string the table name
* @param array the where clause
* @param string the limit clause
* @return string
*/
- function _delete($table, $where = array(), $like = array(), $limit = FALSE)
+ protected function _delete($table, $where = array(), $like = array(), $limit = FALSE)
{
$conditions = '';
@@ -902,13 +852,12 @@ class CI_DB_pdo_driver extends CI_DB {
*
* Generates a platform-specific LIMIT clause
*
- * @access public
* @param string the sql query string
- * @param integer the number of rows to limit the query to
- * @param integer the offset value
+ * @param int the number of rows to limit the query to
+ * @param int the offset value
* @return string
*/
- function _limit($sql, $limit, $offset)
+ protected function _limit($sql, $limit, $offset)
{
if ($this->pdodriver == 'cubrid' OR $this->pdodriver == 'sqlite')
{
@@ -920,7 +869,7 @@ class CI_DB_pdo_driver extends CI_DB {
{
$sql .= 'LIMIT '.$limit;
$sql .= ($offset > 0) ? ' OFFSET '.$offset : '';
-
+
return $sql;
}
}
@@ -930,11 +879,10 @@ class CI_DB_pdo_driver extends CI_DB {
/**
* Close DB Connection
*
- * @access public
* @param resource
* @return void
*/
- function _close($conn_id)
+ protected function _close($conn_id)
{
$this->conn_id = null;
}
@@ -942,4 +890,4 @@ class CI_DB_pdo_driver extends CI_DB {
}
/* End of file pdo_driver.php */
-/* Location: ./system/database/drivers/pdo/pdo_driver.php */
+/* Location: ./system/database/drivers/pdo/pdo_driver.php */ \ No newline at end of file
diff --git a/system/database/drivers/pdo/pdo_forge.php b/system/database/drivers/pdo/pdo_forge.php
index 87b638570..6bff3542f 100644
--- a/system/database/drivers/pdo/pdo_forge.php
+++ b/system/database/drivers/pdo/pdo_forge.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* PDO Forge Class
*
@@ -39,11 +37,10 @@ class CI_DB_pdo_forge extends CI_DB_forge {
/**
* Create database
*
- * @access private
* @param string the database name
* @return bool
*/
- function _create_database()
+ public function _create_database()
{
// PDO has no "create database" command since it's
// designed to connect to an existing database
@@ -59,11 +56,10 @@ class CI_DB_pdo_forge extends CI_DB_forge {
/**
* Drop database
*
- * @access private
* @param string the database name
* @return bool
*/
- function _drop_database($name)
+ public function _drop_database($name)
{
// PDO has no "drop database" command since it's
// designed to connect to an existing database
@@ -79,15 +75,14 @@ class CI_DB_pdo_forge extends CI_DB_forge {
/**
* Create Table
*
- * @access private
* @param string the table name
* @param array the fields
* @param mixed primary key(s)
* @param mixed key(s)
- * @param boolean should 'IF NOT EXISTS' be added to the SQL
+ * @param bool should 'IF NOT EXISTS' be added to the SQL
* @return bool
*/
- function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
+ public function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
{
$sql = 'CREATE TABLE ';
@@ -191,10 +186,9 @@ class CI_DB_pdo_forge extends CI_DB_forge {
/**
* Drop Table
*
- * @access private
* @return bool
*/
- function _drop_table($table)
+ public function _drop_table($table)
{
// Not a supported PDO feature
if ($this->db->db_debug)
@@ -212,17 +206,16 @@ class CI_DB_pdo_forge extends CI_DB_forge {
* Generates a platform-specific query so that a table can be altered
* Called by add_column(), drop_column(), and column_alter(),
*
- * @access private
* @param string the ALTER type (ADD, DROP, CHANGE)
* @param string the column name
* @param string the table name
* @param string the column definition
* @param string the default value
- * @param boolean should 'NOT NULL' be added
+ * @param bool should 'NOT NULL' be added
* @param string the field after which we should add the new field
- * @return object
+ * @return string
*/
- function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '')
+ public function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '')
{
$sql = 'ALTER TABLE `'.$this->db->protect_identifiers($table).'` '.$alter_type.' '.$this->db->protect_identifiers($column_name);
@@ -265,12 +258,11 @@ class CI_DB_pdo_forge extends CI_DB_forge {
*
* Generates a platform-specific query so that a table can be renamed
*
- * @access private
* @param string the old table name
* @param string the new table name
* @return string
*/
- function _rename_table($table_name, $new_table_name)
+ public function _rename_table($table_name, $new_table_name)
{
return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name);
}
@@ -278,4 +270,4 @@ class CI_DB_pdo_forge extends CI_DB_forge {
}
/* End of file pdo_forge.php */
-/* Location: ./system/database/drivers/pdo/pdo_forge.php */
+/* Location: ./system/database/drivers/pdo/pdo_forge.php */ \ No newline at end of file
diff --git a/system/database/drivers/pdo/pdo_result.php b/system/database/drivers/pdo/pdo_result.php
index 384b753da..5bbd85d75 100644
--- a/system/database/drivers/pdo/pdo_result.php
+++ b/system/database/drivers/pdo/pdo_result.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* PDO Result Class
*
@@ -51,10 +49,9 @@ class CI_DB_pdo_result extends CI_DB_result {
/**
* Number of rows in the result set
*
- * @access public
- * @return integer
+ * @return int
*/
- function num_rows()
+ public function num_rows()
{
if (empty($this->result_id) OR ! is_object($this->result_id))
{
@@ -74,10 +71,9 @@ class CI_DB_pdo_result extends CI_DB_result {
/**
* Fetch the result handler
*
- * @access public
* @return mixed
*/
- function result_assoc()
+ public function result_assoc()
{
// If the result already fetched before, use that one
if (count($this->result_array) > 0 OR $this->is_fetched)
@@ -94,7 +90,7 @@ class CI_DB_pdo_result extends CI_DB_result {
// Define the method and handler
$res_method = '_fetch_'.$type;
$res_handler = 'result_'.$type;
-
+
$this->$res_handler = array();
$this->_data_seek(0);
@@ -116,10 +112,9 @@ class CI_DB_pdo_result extends CI_DB_result {
/**
* Number of fields in the result set
*
- * @access public
- * @return integer
+ * @return int
*/
- function num_fields()
+ public function num_fields()
{
return $this->result_id->columnCount();
}
@@ -131,16 +126,15 @@ class CI_DB_pdo_result extends CI_DB_result {
*
* Generates an array of column names
*
- * @access public
- * @return array
+ * @return bool
*/
- function list_fields()
+ public function list_fields()
{
if ($this->db->db_debug)
{
return $this->db->display_error('db_unsuported_feature');
}
-
+
return FALSE;
}
@@ -151,13 +145,12 @@ class CI_DB_pdo_result extends CI_DB_result {
*
* Generates an array of objects containing field meta-data
*
- * @access public
* @return array
*/
- function field_data()
+ public function field_data()
{
$data = array();
-
+
try
{
if (strpos($this->result_id->queryString, 'PRAGMA') !== FALSE)
@@ -173,7 +166,7 @@ class CI_DB_pdo_result extends CI_DB_result {
$F->max_length = ( ! empty($matches[2])) ? preg_replace('/[^\d]/', '', $matches[2]) : NULL;
$F->primary_key = (int) $field['pk'];
$F->pdo_type = NULL;
-
+
$data[] = $F;
}
}
@@ -188,7 +181,7 @@ class CI_DB_pdo_result extends CI_DB_result {
$F->type = $field['native_type'];
$F->default = NULL;
$F->pdo_type = $field['pdo_type'];
-
+
if ($field['precision'] < 0)
{
$F->max_length = NULL;
@@ -203,7 +196,7 @@ class CI_DB_pdo_result extends CI_DB_result {
$data[] = $F;
}
}
-
+
return $data;
}
catch (Exception $e)
@@ -222,9 +215,9 @@ class CI_DB_pdo_result extends CI_DB_result {
/**
* Free the result
*
- * @return null
+ * @return void
*/
- function free_result()
+ public function free_result()
{
if (is_object($this->result_id))
{
@@ -237,14 +230,13 @@ class CI_DB_pdo_result extends CI_DB_result {
/**
* Data Seek
*
- * Moves the internal pointer to the desired offset. We call
+ * Moves the internal pointer to the desired offset. We call
* this internally before fetching results to make sure the
* result set starts at zero
*
- * @access private
- * @return array
+ * @return bool
*/
- function _data_seek($n = 0)
+ protected function _data_seek($n = 0)
{
return FALSE;
}
@@ -256,10 +248,9 @@ class CI_DB_pdo_result extends CI_DB_result {
*
* Returns the result set as an array
*
- * @access private
* @return array
*/
- function _fetch_assoc()
+ protected function _fetch_assoc()
{
return $this->result_id->fetch(PDO::FETCH_ASSOC);
}
@@ -271,11 +262,10 @@ class CI_DB_pdo_result extends CI_DB_result {
*
* Returns the result set as an object
*
- * @access private
* @return object
*/
- function _fetch_object()
- {
+ protected function _fetch_object()
+ {
return $this->result_id->fetchObject();
}
diff --git a/system/database/drivers/pdo/pdo_utility.php b/system/database/drivers/pdo/pdo_utility.php
index c278c5172..86c798397 100644
--- a/system/database/drivers/pdo/pdo_utility.php
+++ b/system/database/drivers/pdo/pdo_utility.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* PDO Utility Class
*
@@ -39,10 +37,9 @@ class CI_DB_pdo_utility extends CI_DB_utility {
/**
* List databases
*
- * @access private
* @return bool
*/
- function _list_databases()
+ public function _list_databases()
{
// Not sure if PDO lets you list all databases...
if ($this->db->db_debug)
@@ -59,11 +56,10 @@ class CI_DB_pdo_utility extends CI_DB_utility {
*
* Generates a platform-specific query so that a table can be optimized
*
- * @access private
* @param string the table name
- * @return object
+ * @return bool
*/
- function _optimize_table($table)
+ public function _optimize_table($table)
{
// Not a supported PDO feature
if ($this->db->db_debug)
@@ -80,11 +76,10 @@ class CI_DB_pdo_utility extends CI_DB_utility {
*
* Generates a platform-specific query so that a table can be repaired
*
- * @access private
* @param string the table name
- * @return object
+ * @return bool
*/
- function _repair_table($table)
+ public function _repair_table($table)
{
// Not a supported PDO feature
if ($this->db->db_debug)
@@ -99,11 +94,10 @@ class CI_DB_pdo_utility extends CI_DB_utility {
/**
* PDO Export
*
- * @access private
* @param array Preferences
* @return mixed
*/
- function _backup($params = array())
+ public function _backup($params = array())
{
// Currently unsupported
return $this->db->display_error('db_unsuported_feature');
diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php
index 8112cf9de..3e2d05ce8 100644
--- a/system/database/drivers/postgre/postgre_driver.php
+++ b/system/database/drivers/postgre/postgre_driver.php
@@ -57,29 +57,64 @@ class CI_DB_postgre_driver extends CI_DB {
protected $_random_keyword = ' RANDOM()'; // database specific random keyword
/**
- * Connection String
+ * Constructor
*
- * @return string
+ * Creates a DSN string to be used for db_connect() and db_pconnect()
+ *
+ * @return void
*/
- protected function _connect_string()
+ public function __construct($params)
{
- $components = array(
- 'hostname' => 'host',
- 'port' => 'port',
- 'database' => 'dbname',
- 'username' => 'user',
- 'password' => 'password'
- );
-
- $connect_string = "";
- foreach ($components as $key => $val)
+ parent::__construct($params);
+
+ if ( ! empty($this->dsn))
+ {
+ return;
+ }
+
+ $this->dsn === '' OR $this->dsn = '';
+
+ if (strpos($this->hostname, '/') !== FALSE)
+ {
+ // If UNIX sockets are used, we shouldn't set a port
+ $this->port = '';
+ }
+
+ $this->hostname === '' OR $this->dsn = 'host='.$this->hostname;
+
+ if ( ! empty($this->port) && ctype_digit($this->port))
+ {
+ $this->dsn .= 'host='.$this->port.' ';
+ }
+
+ if ($this->username !== '')
+ {
+ $this->dsn .= 'username='.$this->username.' ';
+
+ /* An empty password is valid!
+ *
+ * $db['password'] = NULL must be done in order to ignore it.
+ */
+ $this->password === NULL OR $this->dsn .= "password='".$this->password."' ";
+ }
+
+ $this->database === '' OR $this->dsn .= 'dbname='.$this->database.' ';
+
+ /* We don't have these options as elements in our standard configuration
+ * array, but they might be set by parse_url() if the configuration was
+ * provided via string. Example:
+ *
+ * postgre://username:password@localhost:5432/database?connect_timeout=5&sslmode=1
+ */
+ foreach (array('connect_timeout', 'options', 'sslmode', 'service') as $key)
{
- if (isset($this->$key) && $this->$key != '')
+ if (isset($this->$key) && is_string($this->key) && $this->key !== '')
{
- $connect_string .= " $val=".$this->$key;
+ $this->dsn .= $key."='".$this->key."' ";
}
}
- return trim($connect_string);
+
+ $this->dsn = rtrim($this->dsn);
}
// --------------------------------------------------------------------
@@ -91,7 +126,7 @@ class CI_DB_postgre_driver extends CI_DB {
*/
public function db_connect()
{
- return @pg_connect($this->_connect_string());
+ return @pg_connect($this->dsn);
}
// --------------------------------------------------------------------
@@ -103,7 +138,7 @@ class CI_DB_postgre_driver extends CI_DB {
*/
public function db_pconnect()
{
- return @pg_pconnect($this->_connect_string());
+ return @pg_pconnect($this->dsn);
}
// --------------------------------------------------------------------
@@ -189,28 +224,12 @@ class CI_DB_postgre_driver extends CI_DB {
*/
protected function _execute($sql)
{
- $sql = $this->_prep_query($sql);
return @pg_query($this->conn_id, $sql);
}
// --------------------------------------------------------------------
/**
- * Prep the query
- *
- * If needed, each database adapter can prep the query string
- *
- * @param string an SQL query
- * @return string
- */
- protected function _prep_query($sql)
- {
- return $sql;
- }
-
- // --------------------------------------------------------------------
-
- /**
* Begin Transaction
*
* @return bool
@@ -659,4 +678,4 @@ class CI_DB_postgre_driver extends CI_DB {
}
/* End of file postgre_driver.php */
-/* Location: ./system/database/drivers/postgre/postgre_driver.php */
+/* Location: ./system/database/drivers/postgre/postgre_driver.php */ \ No newline at end of file
diff --git a/system/database/drivers/postgre/postgre_forge.php b/system/database/drivers/postgre/postgre_forge.php
index 2a8fdd676..a72449820 100644
--- a/system/database/drivers/postgre/postgre_forge.php
+++ b/system/database/drivers/postgre/postgre_forge.php
@@ -299,4 +299,4 @@ class CI_DB_postgre_forge extends CI_DB_forge {
}
/* End of file postgre_forge.php */
-/* Location: ./system/database/drivers/postgre/postgre_forge.php */
+/* Location: ./system/database/drivers/postgre/postgre_forge.php */ \ No newline at end of file
diff --git a/system/database/drivers/postgre/postgre_result.php b/system/database/drivers/postgre/postgre_result.php
index b3eafb8f7..8b22564b3 100644
--- a/system/database/drivers/postgre/postgre_result.php
+++ b/system/database/drivers/postgre/postgre_result.php
@@ -168,4 +168,4 @@ class CI_DB_postgre_result extends CI_DB_result {
}
/* End of file postgre_result.php */
-/* Location: ./system/database/drivers/postgre/postgre_result.php */
+/* Location: ./system/database/drivers/postgre/postgre_result.php */ \ No newline at end of file
diff --git a/system/database/drivers/postgre/postgre_utility.php b/system/database/drivers/postgre/postgre_utility.php
index e31a6db8f..cf29201ff 100644
--- a/system/database/drivers/postgre/postgre_utility.php
+++ b/system/database/drivers/postgre/postgre_utility.php
@@ -78,7 +78,7 @@ class CI_DB_postgre_utility extends CI_DB_utility {
* @param array Preferences
* @return mixed
*/
- function _backup($params = array())
+ public function _backup($params = array())
{
// Currently unsupported
return $this->db->display_error('db_unsuported_feature');
@@ -86,4 +86,4 @@ class CI_DB_postgre_utility extends CI_DB_utility {
}
/* End of file postgre_utility.php */
-/* Location: ./system/database/drivers/postgre/postgre_utility.php */
+/* Location: ./system/database/drivers/postgre/postgre_utility.php */ \ No newline at end of file
diff --git a/system/database/drivers/sqlite/sqlite_driver.php b/system/database/drivers/sqlite/sqlite_driver.php
index 55d9bfdb8..102c79bb3 100644
--- a/system/database/drivers/sqlite/sqlite_driver.php
+++ b/system/database/drivers/sqlite/sqlite_driver.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,10 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
-
-
/**
* SQLite Database Adapter Class
*
@@ -44,30 +40,29 @@
*/
class CI_DB_sqlite_driver extends CI_DB {
- var $dbdriver = 'sqlite';
+ public $dbdriver = 'sqlite';
// The character used to escape with - not needed for SQLite
- var $_escape_char = '';
+ protected $_escape_char = '';
// clause and character used for LIKE escape sequences
- var $_like_escape_str = " ESCAPE '%s' ";
- var $_like_escape_chr = '!';
+ protected $_like_escape_str = " ESCAPE '%s' ";
+ protected $_like_escape_chr = '!';
/**
* The syntax to count rows is slightly different across different
* database engines, so this string appears in each driver and is
* used for the count_all() and count_all_results() functions.
*/
- var $_count_string = "SELECT COUNT(*) AS ";
- var $_random_keyword = ' Random()'; // database specific random keyword
+ protected $_count_string = 'SELECT COUNT(*) AS ';
+ protected $_random_keyword = ' Random()'; // database specific random keyword
/**
* Non-persistent database connection
*
- * @access private called by the base class
* @return resource
*/
- function db_connect()
+ public function db_connect()
{
if ( ! $conn_id = @sqlite_open($this->database, FILE_WRITE_MODE, $error))
{
@@ -89,10 +84,9 @@ class CI_DB_sqlite_driver extends CI_DB {
/**
* Persistent database connection
*
- * @access private called by the base class
* @return resource
*/
- function db_pconnect()
+ public function db_pconnect()
{
if ( ! $conn_id = @sqlite_popen($this->database, FILE_WRITE_MODE, $error))
{
@@ -112,28 +106,11 @@ class CI_DB_sqlite_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * Reconnect
- *
- * Keep / reestablish the db connection if no queries have been
- * sent for a length of time exceeding the server's idle timeout
- *
- * @access public
- * @return void
- */
- function reconnect()
- {
- // not implemented in SQLite
- }
-
- // --------------------------------------------------------------------
-
- /**
* Select the database
*
- * @access private called by the base class
* @return resource
*/
- function db_select()
+ public function db_select()
{
return TRUE;
}
@@ -157,41 +134,22 @@ class CI_DB_sqlite_driver extends CI_DB {
/**
* Execute the query
*
- * @access private called by the base class
* @param string an SQL query
* @return resource
*/
- function _execute($sql)
+ protected function _execute($sql)
{
- $sql = $this->_prep_query($sql);
return @sqlite_query($this->conn_id, $sql);
}
// --------------------------------------------------------------------
/**
- * Prep the query
- *
- * If needed, each database adapter can prep the query string
- *
- * @access private called by execute()
- * @param string an SQL query
- * @return string
- */
- function _prep_query($sql)
- {
- return $sql;
- }
-
- // --------------------------------------------------------------------
-
- /**
* Begin Transaction
*
- * @access public
* @return bool
*/
- function trans_begin($test_mode = FALSE)
+ public function trans_begin($test_mode = FALSE)
{
if ( ! $this->trans_enabled)
{
@@ -218,10 +176,9 @@ class CI_DB_sqlite_driver extends CI_DB {
/**
* Commit Transaction
*
- * @access public
* @return bool
*/
- function trans_commit()
+ public function trans_commit()
{
if ( ! $this->trans_enabled)
{
@@ -243,10 +200,9 @@ class CI_DB_sqlite_driver extends CI_DB {
/**
* Rollback Transaction
*
- * @access public
* @return bool
*/
- function trans_rollback()
+ public function trans_rollback()
{
if ( ! $this->trans_enabled)
{
@@ -268,12 +224,11 @@ class CI_DB_sqlite_driver extends CI_DB {
/**
* Escape String
*
- * @access public
* @param string
* @param bool whether or not the string will be used in a LIKE condition
* @return string
*/
- function escape_str($str, $like = FALSE)
+ public function escape_str($str, $like = FALSE)
{
if (is_array($str))
{
@@ -290,9 +245,9 @@ class CI_DB_sqlite_driver extends CI_DB {
// escape LIKE condition wildcards
if ($like === TRUE)
{
- $str = 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;
@@ -303,10 +258,9 @@ class CI_DB_sqlite_driver extends CI_DB {
/**
* Affected Rows
*
- * @access public
- * @return integer
+ * @return int
*/
- function affected_rows()
+ public function affected_rows()
{
return sqlite_changes($this->conn_id);
}
@@ -316,10 +270,9 @@ class CI_DB_sqlite_driver extends CI_DB {
/**
* Insert ID
*
- * @access public
- * @return integer
+ * @return int
*/
- function insert_id()
+ public function insert_id()
{
return @sqlite_last_insert_rowid($this->conn_id);
}
@@ -332,11 +285,10 @@ class CI_DB_sqlite_driver extends CI_DB {
* Generates a platform-specific query string that counts all records in
* the specified database
*
- * @access public
* @param string
* @return string
*/
- function count_all($table = '')
+ public function count_all($table = '')
{
if ($table == '')
{
@@ -361,11 +313,10 @@ class CI_DB_sqlite_driver extends CI_DB {
*
* Generates a platform-specific query string so that the table names can be fetched
*
- * @access private
- * @param boolean
+ * @param bool
* @return string
*/
- function _list_tables($prefix_limit = FALSE)
+ protected function _list_tables($prefix_limit = FALSE)
{
$sql = "SELECT name from sqlite_master WHERE type='table'";
@@ -383,11 +334,10 @@ class CI_DB_sqlite_driver extends CI_DB {
*
* Generates a platform-specific query string so that the column names can be fetched
*
- * @access public
* @param string the table name
- * @return string
+ * @return bool
*/
- function _list_columns($table = '')
+ protected function _list_columns($table = '')
{
// Not supported
return FALSE;
@@ -400,11 +350,10 @@ class CI_DB_sqlite_driver extends CI_DB {
*
* Generates a platform-specific query so that the column data can be retrieved
*
- * @access public
* @param string the table name
- * @return object
+ * @return string
*/
- function _field_data($table)
+ protected function _field_data($table)
{
return "SELECT * FROM ".$table." LIMIT 1";
}
@@ -433,11 +382,10 @@ class CI_DB_sqlite_driver extends CI_DB {
*
* This function escapes column and table names
*
- * @access private
* @param string
* @return string
*/
- function _escape_identifiers($item)
+ public function _escape_identifiers($item)
{
if ($this->_escape_char == '')
{
@@ -476,11 +424,10 @@ class CI_DB_sqlite_driver extends CI_DB {
* This function implicitly groups FROM tables so there is no confusion
* about operator precedence in harmony with SQL standards
*
- * @access public
- * @param type
- * @return type
+ * @param array
+ * @return string
*/
- function _from_tables($tables)
+ protected function _from_tables($tables)
{
if ( ! is_array($tables))
{
@@ -497,13 +444,12 @@ class CI_DB_sqlite_driver extends CI_DB {
*
* Generates a platform-specific insert string from the supplied data
*
- * @access public
* @param string the table name
* @param array the insert keys
* @param array the insert values
* @return string
*/
- function _insert($table, $keys, $values)
+ protected function _insert($table, $keys, $values)
{
return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")";
}
@@ -515,7 +461,6 @@ class CI_DB_sqlite_driver extends CI_DB {
*
* Generates a platform-specific update string from the supplied data
*
- * @access public
* @param string the table name
* @param array the update data
* @param array the where clause
@@ -523,7 +468,7 @@ class CI_DB_sqlite_driver extends CI_DB {
* @param array the limit clause
* @return string
*/
- function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
+ protected function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
{
foreach ($values as $key => $val)
{
@@ -553,11 +498,10 @@ class CI_DB_sqlite_driver extends CI_DB {
* If the database does not support the truncate() command
* This function maps to "DELETE FROM table"
*
- * @access public
* @param string the table name
* @return string
*/
- function _truncate($table)
+ protected function _truncate($table)
{
return $this->_delete($table);
}
@@ -569,13 +513,12 @@ class CI_DB_sqlite_driver extends CI_DB {
*
* Generates a platform-specific delete string from the supplied data
*
- * @access public
* @param string the table name
* @param array the where clause
* @param string the limit clause
* @return string
*/
- function _delete($table, $where = array(), $like = array(), $limit = FALSE)
+ protected function _delete($table, $where = array(), $like = array(), $limit = FALSE)
{
$conditions = '';
@@ -603,13 +546,12 @@ class CI_DB_sqlite_driver extends CI_DB {
*
* Generates a platform-specific LIMIT clause
*
- * @access public
* @param string the sql query string
- * @param integer the number of rows to limit the query to
- * @param integer the offset value
+ * @param int the number of rows to limit the query to
+ * @param int the offset value
* @return string
*/
- function _limit($sql, $limit, $offset)
+ protected function _limit($sql, $limit, $offset)
{
if ($offset == 0)
{
@@ -628,18 +570,15 @@ class CI_DB_sqlite_driver extends CI_DB {
/**
* Close DB Connection
*
- * @access public
* @param resource
* @return void
*/
- function _close($conn_id)
+ protected function _close($conn_id)
{
@sqlite_close($conn_id);
}
-
}
-
/* End of file sqlite_driver.php */
-/* Location: ./system/database/drivers/sqlite/sqlite_driver.php */
+/* Location: ./system/database/drivers/sqlite/sqlite_driver.php */ \ No newline at end of file
diff --git a/system/database/drivers/sqlite/sqlite_forge.php b/system/database/drivers/sqlite/sqlite_forge.php
index 7fc531463..068a556ed 100644
--- a/system/database/drivers/sqlite/sqlite_forge.php
+++ b/system/database/drivers/sqlite/sqlite_forge.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* SQLite Forge Class
*
@@ -39,11 +37,10 @@ class CI_DB_sqlite_forge extends CI_DB_forge {
/**
* Create database
*
- * @access public
* @param string the database name
* @return bool
*/
- function _create_database()
+ public function _create_database()
{
// In SQLite, a database is created when you connect to the database.
// We'll return TRUE so that an error isn't generated
@@ -55,11 +52,10 @@ class CI_DB_sqlite_forge extends CI_DB_forge {
/**
* Drop database
*
- * @access private
* @param string the database name
* @return bool
*/
- function _drop_database($name)
+ public function _drop_database($name)
{
if ( ! @file_exists($this->db->database) OR ! @unlink($this->db->database))
{
@@ -71,20 +67,20 @@ class CI_DB_sqlite_forge extends CI_DB_forge {
}
return TRUE;
}
+
// --------------------------------------------------------------------
/**
* Create Table
*
- * @access private
* @param string the table name
* @param array the fields
* @param mixed primary key(s)
* @param mixed key(s)
- * @param boolean should 'IF NOT EXISTS' be added to the SQL
+ * @param bool should 'IF NOT EXISTS' be added to the SQL
* @return bool
*/
- function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
+ public function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
{
$sql = 'CREATE TABLE ';
@@ -184,12 +180,9 @@ class CI_DB_sqlite_forge extends CI_DB_forge {
/**
* Drop Table
*
- * Unsupported feature in SQLite
- *
- * @access private
* @return bool
*/
- function _drop_table($table)
+ public function _drop_table($table)
{
if ($this->db->db_debug)
{
@@ -206,17 +199,16 @@ class CI_DB_sqlite_forge extends CI_DB_forge {
* Generates a platform-specific query so that a table can be altered
* Called by add_column(), drop_column(), and column_alter(),
*
- * @access private
* @param string the ALTER type (ADD, DROP, CHANGE)
* @param string the column name
* @param string the table name
* @param string the column definition
* @param string the default value
- * @param boolean should 'NOT NULL' be added
+ * @param bool should 'NOT NULL' be added
* @param string the field after which we should add the new field
- * @return object
+ * @return string
*/
- function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '')
+ public function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '')
{
$sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '.$this->db->protect_identifiers($column_name);
@@ -261,12 +253,11 @@ class CI_DB_sqlite_forge extends CI_DB_forge {
*
* Generates a platform-specific query so that a table can be renamed
*
- * @access private
* @param string the old table name
* @param string the new table name
* @return string
*/
- function _rename_table($table_name, $new_table_name)
+ public function _rename_table($table_name, $new_table_name)
{
return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name);
}
@@ -274,4 +265,4 @@ class CI_DB_sqlite_forge extends CI_DB_forge {
}
/* End of file sqlite_forge.php */
-/* Location: ./system/database/drivers/sqlite/sqlite_forge.php */
+/* Location: ./system/database/drivers/sqlite/sqlite_forge.php */ \ No newline at end of file
diff --git a/system/database/drivers/sqlite/sqlite_result.php b/system/database/drivers/sqlite/sqlite_result.php
index ac2235cbc..b002aeff1 100644
--- a/system/database/drivers/sqlite/sqlite_result.php
+++ b/system/database/drivers/sqlite/sqlite_result.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* SQLite Result Class
*
@@ -41,10 +39,9 @@ class CI_DB_sqlite_result extends CI_DB_result {
/**
* Number of rows in the result set
*
- * @access public
- * @return integer
+ * @return int
*/
- function num_rows()
+ public function num_rows()
{
return @sqlite_num_rows($this->result_id);
}
@@ -54,10 +51,9 @@ class CI_DB_sqlite_result extends CI_DB_result {
/**
* Number of fields in the result set
*
- * @access public
- * @return integer
+ * @return int
*/
- function num_fields()
+ public function num_fields()
{
return @sqlite_num_fields($this->result_id);
}
@@ -69,10 +65,9 @@ class CI_DB_sqlite_result extends CI_DB_result {
*
* Generates an array of column names
*
- * @access public
* @return array
*/
- function list_fields()
+ public function list_fields()
{
$field_names = array();
for ($i = 0; $i < $this->num_fields(); $i++)
@@ -90,10 +85,9 @@ class CI_DB_sqlite_result extends CI_DB_result {
*
* Generates an array of objects containing field meta-data
*
- * @access public
* @return array
*/
- function field_data()
+ public function field_data()
{
$retval = array();
for ($i = 0; $i < $this->num_fields(); $i++)
@@ -116,9 +110,9 @@ class CI_DB_sqlite_result extends CI_DB_result {
/**
* Free the result
*
- * @return null
+ * @return void
*/
- function free_result()
+ public function free_result()
{
// Not implemented in SQLite
}
@@ -128,14 +122,13 @@ class CI_DB_sqlite_result extends CI_DB_result {
/**
* Data Seek
*
- * Moves the internal pointer to the desired offset. We call
+ * Moves the internal pointer to the desired offset. We call
* this internally before fetching results to make sure the
* result set starts at zero
*
- * @access private
* @return array
*/
- function _data_seek($n = 0)
+ protected function _data_seek($n = 0)
{
return sqlite_seek($this->result_id, $n);
}
@@ -147,10 +140,9 @@ class CI_DB_sqlite_result extends CI_DB_result {
*
* Returns the result set as an array
*
- * @access private
* @return array
*/
- function _fetch_assoc()
+ protected function _fetch_assoc()
{
return sqlite_fetch_array($this->result_id);
}
@@ -162,10 +154,9 @@ class CI_DB_sqlite_result extends CI_DB_result {
*
* Returns the result set as an object
*
- * @access private
* @return object
*/
- function _fetch_object()
+ protected function _fetch_object()
{
if (function_exists('sqlite_fetch_object'))
{
@@ -186,6 +177,5 @@ class CI_DB_sqlite_result extends CI_DB_result {
}
-
/* End of file sqlite_result.php */
/* Location: ./system/database/drivers/sqlite/sqlite_result.php */ \ No newline at end of file
diff --git a/system/database/drivers/sqlite/sqlite_utility.php b/system/database/drivers/sqlite/sqlite_utility.php
index 9f9ddca44..c07004c54 100644
--- a/system/database/drivers/sqlite/sqlite_utility.php
+++ b/system/database/drivers/sqlite/sqlite_utility.php
@@ -94,4 +94,4 @@ class CI_DB_sqlite_utility extends CI_DB_utility {
}
/* End of file sqlite_utility.php */
-/* Location: ./system/database/drivers/sqlite/sqlite_utility.php */
+/* Location: ./system/database/drivers/sqlite/sqlite_utility.php */ \ No newline at end of file
diff --git a/system/database/drivers/sqlsrv/sqlsrv_driver.php b/system/database/drivers/sqlsrv/sqlsrv_driver.php
index 5e920cbe8..9f2f88699 100644
--- a/system/database/drivers/sqlsrv/sqlsrv_driver.php
+++ b/system/database/drivers/sqlsrv/sqlsrv_driver.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* SQLSRV Database Adapter Class
*
@@ -42,30 +40,29 @@
*/
class CI_DB_sqlsrv_driver extends CI_DB {
- var $dbdriver = 'sqlsrv';
+ public $dbdriver = 'sqlsrv';
// The character used for escaping
- var $_escape_char = '';
+ protected $_escape_char = '';
// clause and character used for LIKE escape sequences
- var $_like_escape_str = " ESCAPE '%s' ";
- var $_like_escape_chr = '!';
+ protected $_like_escape_str = " ESCAPE '%s' ";
+ protected $_like_escape_chr = '!';
/**
* The syntax to count rows is slightly different across different
* database engines, so this string appears in each driver and is
* used for the count_all() and count_all_results() functions.
*/
- var $_count_string = "SELECT COUNT(*) AS ";
- var $_random_keyword = ' ASC'; // not currently supported
+ protected $_count_string = 'SELECT COUNT(*) AS ';
+ protected $_random_keyword = ' ASC'; // not currently supported
/**
* Non-persistent database connection
*
- * @access private called by the base class
* @return resource
*/
- function db_connect($pooling = false)
+ public function db_connect($pooling = FALSE)
{
// Check for a UTF-8 charset being passed as CI's default 'utf8'.
$character_set = (0 === strcasecmp('utf8', $this->char_set)) ? 'UTF-8' : $this->char_set;
@@ -78,10 +75,11 @@ class CI_DB_sqlsrv_driver extends CI_DB {
'CharacterSet' => $character_set,
'ReturnDatesAsStrings' => 1
);
-
- // If the username and password are both empty, assume this is a
+
+ // If the username and password are both empty, assume this is a
// 'Windows Authentication Mode' connection.
- if(empty($connection['UID']) && empty($connection['PWD'])) {
+ if (empty($connection['UID']) && empty($connection['PWD']))
+ {
unset($connection['UID'], $connection['PWD']);
}
@@ -93,10 +91,9 @@ class CI_DB_sqlsrv_driver extends CI_DB {
/**
* Persistent database connection
*
- * @access private called by the base class
* @return resource
*/
- function db_pconnect()
+ public function db_pconnect()
{
return $this->db_connect(TRUE);
}
@@ -104,22 +101,6 @@ class CI_DB_sqlsrv_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * Reconnect
- *
- * Keep / reestablish the db connection if no queries have been
- * sent for a length of time exceeding the server's idle timeout
- *
- * @access public
- * @return void
- */
- function reconnect()
- {
- // not implemented in MSSQL
- }
-
- // --------------------------------------------------------------------
-
- /**
* Select the database
*
* @param string database name
@@ -146,33 +127,16 @@ class CI_DB_sqlsrv_driver extends CI_DB {
/**
* Execute the query
*
- * @access private called by the base class
* @param string an SQL query
* @return resource
*/
- function _execute($sql)
- {
- $sql = $this->_prep_query($sql);
- return sqlsrv_query($this->conn_id, $sql, null, array(
- 'Scrollable' => SQLSRV_CURSOR_STATIC,
- 'SendStreamParamsAtExec' => true
- ));
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Prep the query
- *
- * If needed, each database adapter can prep the query string
- *
- * @access private called by execute()
- * @param string an SQL query
- * @return string
- */
- function _prep_query($sql)
+ protected function _execute($sql)
{
- return $sql;
+ return sqlsrv_query($this->conn_id,
+ $sql,
+ NULL,
+ array('Scrollable'=> SQLSRV_CURSOR_STATIC, 'SendStreamParamsAtExec' => TRUE)
+ );
}
// --------------------------------------------------------------------
@@ -180,10 +144,9 @@ class CI_DB_sqlsrv_driver extends CI_DB {
/**
* Begin Transaction
*
- * @access public
* @return bool
*/
- function trans_begin($test_mode = FALSE)
+ public function trans_begin($test_mode = FALSE)
{
if ( ! $this->trans_enabled)
{
@@ -209,10 +172,9 @@ class CI_DB_sqlsrv_driver extends CI_DB {
/**
* Commit Transaction
*
- * @access public
* @return bool
*/
- function trans_commit()
+ public function trans_commit()
{
if ( ! $this->trans_enabled)
{
@@ -233,10 +195,9 @@ class CI_DB_sqlsrv_driver extends CI_DB {
/**
* Rollback Transaction
*
- * @access public
* @return bool
*/
- function trans_rollback()
+ public function trans_rollback()
{
if ( ! $this->trans_enabled)
{
@@ -257,12 +218,11 @@ class CI_DB_sqlsrv_driver extends CI_DB {
/**
* Escape String
*
- * @access public
* @param string
* @param bool whether or not the string will be used in a LIKE condition
* @return string
*/
- function escape_str($str, $like = FALSE)
+ public function escape_str($str, $like = FALSE)
{
// Escape single quotes
return str_replace("'", "''", $str);
@@ -273,10 +233,9 @@ class CI_DB_sqlsrv_driver extends CI_DB {
/**
* Affected Rows
*
- * @access public
- * @return integer
+ * @return int
*/
- function affected_rows()
+ public function affected_rows()
{
return @sqlrv_rows_affected($this->conn_id);
}
@@ -284,31 +243,31 @@ class CI_DB_sqlsrv_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * Insert ID
- *
- * Returns the last id created in the Identity column.
- *
- * @access public
- * @return integer
- */
- function insert_id()
+ * Insert ID
+ *
+ * Returns the last id created in the Identity column.
+ *
+ * @return string
+ */
+ public function insert_id()
{
- return $this->query('select @@IDENTITY as insert_id')->row('insert_id');
+ $query = $this->query('SELECT @@IDENTITY AS insert_id');
+ $query = $query->row();
+ return $query->insert_id;
}
// --------------------------------------------------------------------
/**
- * Parse major version
- *
- * Grabs the major version number from the
- * database server version string passed in.
- *
- * @access private
- * @param string $version
- * @return int16 major version number
- */
- function _parse_major_version($version)
+ * Parse major version
+ *
+ * Grabs the major version number from the
+ * database server version string passed in.
+ *
+ * @param string $version
+ * @return int major version number
+ */
+ protected function _parse_major_version($version)
{
preg_match('/([0-9]+)\.([0-9]+)\.([0-9]+)/', $version, $ver_info);
return $ver_info[1]; // return the major version b/c that's all we're interested in.
@@ -344,23 +303,25 @@ class CI_DB_sqlsrv_driver extends CI_DB {
* Generates a platform-specific query string that counts all records in
* the specified database
*
- * @access public
* @param string
- * @return string
+ * @return int
*/
- function count_all($table = '')
+ public function count_all($table = '')
{
if ($table == '')
- return '0';
-
+ {
+ return 0;
+ }
+
$query = $this->query("SELECT COUNT(*) AS numrows FROM " . $this->dbprefix . $table);
-
if ($query->num_rows() == 0)
- return '0';
+ {
+ return 0;
+ }
$row = $query->row();
$this->_reset_select();
- return $row->numrows;
+ return (int) $row->numrows;
}
// --------------------------------------------------------------------
@@ -370,11 +331,10 @@ class CI_DB_sqlsrv_driver extends CI_DB {
*
* Generates a platform-specific query string so that the table names can be fetched
*
- * @access private
- * @param boolean
+ * @param bool
* @return string
*/
- function _list_tables($prefix_limit = FALSE)
+ protected function _list_tables($prefix_limit = FALSE)
{
return "SELECT name FROM sysobjects WHERE type = 'U' ORDER BY name";
}
@@ -386,13 +346,12 @@ class CI_DB_sqlsrv_driver extends CI_DB {
*
* Generates a platform-specific query string so that the column names can be fetched
*
- * @access private
* @param string the table name
* @return string
*/
- function _list_columns($table = '')
+ protected function _list_columns($table = '')
{
- return "SELECT * FROM INFORMATION_SCHEMA.Columns WHERE TABLE_NAME = '".$this->_escape_table($table)."'";
+ return "SELECT * FROM INFORMATION_SCHEMA.Columns WHERE TABLE_NAME = '".$table."'";
}
// --------------------------------------------------------------------
@@ -402,13 +361,12 @@ class CI_DB_sqlsrv_driver extends CI_DB {
*
* Generates a platform-specific query so that the column data can be retrieved
*
- * @access public
* @param string the table name
- * @return object
+ * @return string
*/
- function _field_data($table)
+ protected function _field_data($table)
{
- return "SELECT TOP 1 * FROM " . $this->_escape_table($table);
+ return 'SELECT TOP 1 * FROM '.$table;
}
// --------------------------------------------------------------------
@@ -452,31 +410,14 @@ class CI_DB_sqlsrv_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * Escape Table Name
- *
- * This function adds backticks if the table name has a period
- * in it. Some DBs will get cranky unless periods are escaped
- *
- * @access private
- * @param string the table name
- * @return string
- */
- function _escape_table($table)
- {
- return $table;
- }
-
-
- /**
* Escape the SQL Identifiers
*
* This function escapes column and table names
*
- * @access private
* @param string
* @return string
*/
- function _escape_identifiers($item)
+ public function _escape_identifiers($item)
{
return $item;
}
@@ -489,11 +430,10 @@ class CI_DB_sqlsrv_driver extends CI_DB {
* This function implicitly groups FROM tables so there is no confusion
* about operator precedence in harmony with SQL standards
*
- * @access public
- * @param type
- * @return type
+ * @param array
+ * @return string
*/
- function _from_tables($tables)
+ protected function _from_tables($tables)
{
if ( ! is_array($tables))
{
@@ -510,15 +450,14 @@ class CI_DB_sqlsrv_driver extends CI_DB {
*
* Generates a platform-specific insert string from the supplied data
*
- * @access public
* @param string the table name
* @param array the insert keys
* @param array the insert values
* @return string
*/
- function _insert($table, $keys, $values)
- {
- return "INSERT INTO ".$this->_escape_table($table)." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")";
+ protected function _insert($table, $keys, $values)
+ {
+ return 'INSERT INTO '.$table.' ('.implode(', ', $keys).') VALUES ('.implode(', ', $values).')';
}
// --------------------------------------------------------------------
@@ -528,7 +467,6 @@ class CI_DB_sqlsrv_driver extends CI_DB {
*
* Generates a platform-specific update string from the supplied data
*
- * @access public
* @param string the table name
* @param array the update data
* @param array the where clause
@@ -536,16 +474,16 @@ class CI_DB_sqlsrv_driver extends CI_DB {
* @param array the limit clause
* @return string
*/
- function _update($table, $values, $where)
+ protected function _update($table, $values, $where)
{
foreach($values as $key => $val)
{
$valstr[] = $key." = ".$val;
}
-
- return "UPDATE ".$this->_escape_table($table)." SET ".implode(', ', $valstr)." WHERE ".implode(" ", $where);
+
+ return 'UPDATE '.$table.' SET '.implode(', ', $valstr).' WHERE '.implode(' ', $where);
}
-
+
// --------------------------------------------------------------------
/**
@@ -555,11 +493,10 @@ class CI_DB_sqlsrv_driver extends CI_DB {
* If the database does not support the truncate() command
* This function maps to "DELETE FROM table"
*
- * @access public
* @param string the table name
* @return string
*/
- function _truncate($table)
+ protected function _truncate($table)
{
return "TRUNCATE ".$table;
}
@@ -571,15 +508,14 @@ class CI_DB_sqlsrv_driver extends CI_DB {
*
* Generates a platform-specific delete string from the supplied data
*
- * @access public
* @param string the table name
* @param array the where clause
* @param string the limit clause
* @return string
*/
- function _delete($table, $where)
+ protected function _delete($table, $where)
{
- return "DELETE FROM ".$this->_escape_table($table)." WHERE ".implode(" ", $where);
+ return 'DELETE FROM '.$table.' WHERE '.implode(' ', $where);
}
// --------------------------------------------------------------------
@@ -589,17 +525,14 @@ class CI_DB_sqlsrv_driver extends CI_DB {
*
* Generates a platform-specific LIMIT clause
*
- * @access public
* @param string the sql query string
- * @param integer the number of rows to limit the query to
- * @param integer the offset value
+ * @param int the number of rows to limit the query to
+ * @param int the offset value
* @return string
*/
- function _limit($sql, $limit, $offset)
+ protected function _limit($sql, $limit, $offset)
{
- $i = $limit + $offset;
-
- return preg_replace('/(^\SELECT (DISTINCT)?)/i','\\1 TOP '.$i.' ', $sql);
+ return preg_replace('/(^\SELECT (DISTINCT)?)/i','\\1 TOP '.($limit + $offset).' ', $sql);
}
// --------------------------------------------------------------------
@@ -607,18 +540,15 @@ class CI_DB_sqlsrv_driver extends CI_DB {
/**
* Close DB Connection
*
- * @access public
* @param resource
* @return void
*/
- function _close($conn_id)
+ protected function _close($conn_id)
{
@sqlsrv_close($conn_id);
}
}
-
-
-/* End of file mssql_driver.php */
-/* Location: ./system/database/drivers/mssql/mssql_driver.php */
+/* End of file sqlsrv_driver.php */
+/* Location: ./system/database/drivers/sqlsrv/sqlsrv_driver.php */ \ No newline at end of file
diff --git a/system/database/drivers/sqlsrv/sqlsrv_forge.php b/system/database/drivers/sqlsrv/sqlsrv_forge.php
index cd061dd23..0dc7b5242 100644
--- a/system/database/drivers/sqlsrv/sqlsrv_forge.php
+++ b/system/database/drivers/sqlsrv/sqlsrv_forge.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* SQLSRV Forge Class
*
@@ -39,11 +37,10 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge {
/**
* Create database
*
- * @access private
* @param string the database name
- * @return bool
+ * @return string
*/
- function _create_database($name)
+ public function _create_database($name)
{
return "CREATE DATABASE ".$name;
}
@@ -53,11 +50,10 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge {
/**
* Drop database
*
- * @access private
* @param string the database name
* @return bool
*/
- function _drop_database($name)
+ public function _drop_database($name)
{
return "DROP DATABASE ".$name;
}
@@ -67,10 +63,9 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge {
/**
* Drop Table
*
- * @access private
* @return bool
*/
- function _drop_table($table)
+ public function _drop_table($table)
{
return "DROP TABLE ".$this->db->_escape_identifiers($table);
}
@@ -80,15 +75,14 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge {
/**
* Create Table
*
- * @access private
* @param string the table name
* @param array the fields
* @param mixed primary key(s)
* @param mixed key(s)
- * @param boolean should 'IF NOT EXISTS' be added to the SQL
+ * @param bool should 'IF NOT EXISTS' be added to the SQL
* @return bool
*/
- function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
+ public function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
{
$sql = 'CREATE TABLE ';
@@ -100,7 +94,7 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge {
$sql .= $this->db->_escape_identifiers($table)." (";
$current_field_count = 0;
- foreach ($fields as $field=>$attributes)
+ foreach ($fields as $field => $attributes)
{
// Numeric field names aren't allowed in databases, so if the key is
// numeric, we know it was assigned by PHP and the developer manually
@@ -190,17 +184,16 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge {
* Generates a platform-specific query so that a table can be altered
* Called by add_column(), drop_column(), and column_alter(),
*
- * @access private
* @param string the ALTER type (ADD, DROP, CHANGE)
* @param string the column name
* @param string the table name
* @param string the column definition
* @param string the default value
- * @param boolean should 'NOT NULL' be added
+ * @param bool should 'NOT NULL' be added
* @param string the field after which we should add the new field
- * @return object
+ * @return string
*/
- function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '')
+ public function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '')
{
$sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '.$this->db->protect_identifiers($column_name);
@@ -242,12 +235,11 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge {
*
* Generates a platform-specific query so that a table can be renamed
*
- * @access private
* @param string the old table name
* @param string the new table name
* @return string
*/
- function _rename_table($table_name, $new_table_name)
+ public function _rename_table($table_name, $new_table_name)
{
// I think this syntax will work, but can find little documentation on renaming tables in MSSQL
return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name);
@@ -256,4 +248,4 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge {
}
/* End of file sqlsrv_forge.php */
-/* Location: ./system/database/drivers/sqlsrv/sqlsrv_forge.php */
+/* Location: ./system/database/drivers/sqlsrv/sqlsrv_forge.php */ \ No newline at end of file
diff --git a/system/database/drivers/sqlsrv/sqlsrv_result.php b/system/database/drivers/sqlsrv/sqlsrv_result.php
index 52d338a30..10d790e4b 100644
--- a/system/database/drivers/sqlsrv/sqlsrv_result.php
+++ b/system/database/drivers/sqlsrv/sqlsrv_result.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* SQLSRV Result Class
*
@@ -41,10 +39,9 @@ class CI_DB_sqlsrv_result extends CI_DB_result {
/**
* Number of rows in the result set
*
- * @access public
- * @return integer
+ * @return int
*/
- function num_rows()
+ public function num_rows()
{
return @sqlsrv_num_rows($this->result_id);
}
@@ -54,10 +51,9 @@ class CI_DB_sqlsrv_result extends CI_DB_result {
/**
* Number of fields in the result set
*
- * @access public
- * @return integer
+ * @return int
*/
- function num_fields()
+ public function num_fields()
{
return @sqlsrv_num_fields($this->result_id);
}
@@ -69,17 +65,16 @@ class CI_DB_sqlsrv_result extends CI_DB_result {
*
* Generates an array of column names
*
- * @access public
* @return array
*/
- function list_fields()
+ public function list_fields()
{
$field_names = array();
- foreach(sqlsrv_field_metadata($this->result_id) as $offset => $field)
+ foreach (sqlsrv_field_metadata($this->result_id) as $offset => $field)
{
$field_names[] = $field['Name'];
}
-
+
return $field_names;
}
@@ -90,13 +85,12 @@ class CI_DB_sqlsrv_result extends CI_DB_result {
*
* Generates an array of objects containing field meta-data
*
- * @access public
* @return array
*/
- function field_data()
+ public function field_data()
{
$retval = array();
- foreach(sqlsrv_field_metadata($this->result_id) as $offset => $field)
+ foreach (sqlsrv_field_metadata($this->result_id) as $offset => $field)
{
$F = new stdClass();
$F->name = $field['Name'];
@@ -104,10 +98,10 @@ class CI_DB_sqlsrv_result extends CI_DB_result {
$F->max_length = $field['Size'];
$F->primary_key = 0;
$F->default = '';
-
+
$retval[] = $F;
}
-
+
return $retval;
}
@@ -116,9 +110,9 @@ class CI_DB_sqlsrv_result extends CI_DB_result {
/**
* Free the result
*
- * @return null
+ * @return void
*/
- function free_result()
+ public function free_result()
{
if (is_resource($this->result_id))
{
@@ -132,14 +126,13 @@ class CI_DB_sqlsrv_result extends CI_DB_result {
/**
* Data Seek
*
- * Moves the internal pointer to the desired offset. We call
+ * Moves the internal pointer to the desired offset. We call
* this internally before fetching results to make sure the
* result set starts at zero
*
- * @access private
- * @return array
+ * @return void
*/
- function _data_seek($n = 0)
+ protected function _data_seek($n = 0)
{
// Not implemented
}
@@ -151,10 +144,9 @@ class CI_DB_sqlsrv_result extends CI_DB_result {
*
* Returns the result set as an array
*
- * @access private
* @return array
*/
- function _fetch_assoc()
+ protected function _fetch_assoc()
{
return sqlsrv_fetch_array($this->result_id, SQLSRV_FETCH_ASSOC);
}
@@ -166,16 +158,14 @@ class CI_DB_sqlsrv_result extends CI_DB_result {
*
* Returns the result set as an object
*
- * @access private
* @return object
*/
- function _fetch_object()
+ protected function _fetch_object()
{
return sqlsrv_fetch_object($this->result_id);
}
}
-
-/* End of file mssql_result.php */
-/* Location: ./system/database/drivers/mssql/mssql_result.php */ \ No newline at end of file
+/* End of file sqlsrv_result.php */
+/* Location: ./system/database/drivers/sqlsrv/sqlsrv_result.php */ \ No newline at end of file
diff --git a/system/database/drivers/sqlsrv/sqlsrv_utility.php b/system/database/drivers/sqlsrv/sqlsrv_utility.php
index 44e6fafeb..5830c62de 100644
--- a/system/database/drivers/sqlsrv/sqlsrv_utility.php
+++ b/system/database/drivers/sqlsrv/sqlsrv_utility.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* SQLSRV Utility Class
*
@@ -39,10 +37,9 @@ class CI_DB_sqlsrv_utility extends CI_DB_utility {
/**
* List databases
*
- * @access private
- * @return bool
+ * @return string
*/
- function _list_databases()
+ public function _list_databases()
{
return "EXEC sp_helpdb"; // Can also be: EXEC sp_databases
}
@@ -54,11 +51,10 @@ class CI_DB_sqlsrv_utility extends CI_DB_utility {
*
* Generates a platform-specific query so that a table can be optimized
*
- * @access private
* @param string the table name
- * @return object
+ * @return bool
*/
- function _optimize_table($table)
+ public function _optimize_table($table)
{
return FALSE; // Is this supported in MS SQL?
}
@@ -70,11 +66,10 @@ class CI_DB_sqlsrv_utility extends CI_DB_utility {
*
* Generates a platform-specific query so that a table can be repaired
*
- * @access private
* @param string the table name
- * @return object
+ * @return bool
*/
- function _repair_table($table)
+ public function _repair_table($table)
{
return FALSE; // Is this supported in MS SQL?
}
@@ -84,11 +79,10 @@ class CI_DB_sqlsrv_utility extends CI_DB_utility {
/**
* MSSQL Export
*
- * @access private
* @param array Preferences
* @return mixed
*/
- function _backup($params = array())
+ public function _backup($params = array())
{
// Currently unsupported
return $this->db->display_error('db_unsuported_feature');
@@ -96,5 +90,5 @@ class CI_DB_sqlsrv_utility extends CI_DB_utility {
}
-/* End of file mssql_utility.php */
-/* Location: ./system/database/drivers/mssql/mssql_utility.php */ \ No newline at end of file
+/* End of file sqlsrv_utility.php */
+/* Location: ./system/database/drivers/sqlsrv/sqlsrv_utility.php */ \ No newline at end of file
diff --git a/system/libraries/Email.php b/system/libraries/Email.php
index f30fe40b6..8f383c939 100644
--- a/system/libraries/Email.php
+++ b/system/libraries/Email.php
@@ -59,6 +59,7 @@ class CI_Email {
public $crlf = "\n"; // The RFC 2045 compliant CRLF for quoted-printable is "\r\n". Apparently some servers,
// even on the receiving end think they need to muck with CRLFs, so using "\n", while
// distasteful, is the only thing that seems to work for all environments.
+ public $dsn = FALSE; // Delivery Status Notification
public $send_multipart = TRUE; // TRUE/FALSE - Yahoo does not like multipart alternative, so this is an override. Set to FALSE for Yahoo.
public $bcc_batch_mode = FALSE; // TRUE/FALSE - Turns on/off Bcc batch feature
public $bcc_batch_size = 200; // If bcc_batch_mode = TRUE, sets max number of Bccs in each batch
@@ -1567,9 +1568,15 @@ class CI_Email {
$resp = 250;
break;
case 'to' :
-
- $this->_send_data('RCPT TO:<'.$data.'>');
-
+
+ if ($this->dsn)
+ {
+ $this->_send_data('RCPT TO:<'.$data.'> NOTIFY=SUCCESS,DELAY,FAILURE ORCPT=rfc822;'.$data);
+ }
+ else
+ {
+ $this->_send_data('RCPT TO:<'.$data.'>');
+ }
$resp = 250;
break;
case 'data' :