summaryrefslogtreecommitdiffstats
path: root/system
diff options
context:
space:
mode:
authorAndrey Andreev <narf@bofh.bg>2012-03-20 14:40:56 +0100
committerAndrey Andreev <narf@bofh.bg>2012-03-20 14:40:56 +0100
commit84a3b25b11da0f5b69c9a128cd79b98bfb70dc30 (patch)
treea5fd16fe0ae7b0ab3e8ee9a56683da7c3cc7225a /system
parent75124a53cf54f2a8c094756f9189be9159957f28 (diff)
parent820999cb0d82c80d6dc5dde133568812c8113e29 (diff)
Merge branch 'develop' of github.com:EllisLab/CodeIgniter into develop-helpers-sst
Diffstat (limited to 'system')
-rwxr-xr-xsystem/core/Config.php2
-rwxr-xr-xsystem/core/Input.php13
-rwxr-xr-xsystem/core/Security.php10
-rwxr-xr-xsystem/core/URI.php18
-rw-r--r--system/database/DB_active_rec.php1
-rw-r--r--system/database/drivers/cubrid/cubrid_driver.php124
-rw-r--r--system/database/drivers/cubrid/cubrid_forge.php37
-rw-r--r--system/database/drivers/cubrid/cubrid_result.php38
-rw-r--r--system/database/drivers/cubrid/cubrid_utility.php24
-rw-r--r--system/database/drivers/mysql/mysql_forge.php2
-rw-r--r--system/database/drivers/mysqli/mysqli_forge.php2
-rw-r--r--system/database/drivers/odbc/odbc_driver.php114
-rw-r--r--system/database/drivers/odbc/odbc_forge.php34
-rw-r--r--system/database/drivers/odbc/odbc_result.php53
-rw-r--r--system/database/drivers/odbc/odbc_utility.php26
-rw-r--r--system/database/drivers/pdo/pdo_driver.php21
-rw-r--r--system/database/drivers/pdo/pdo_result.php43
-rw-r--r--system/database/drivers/postgre/postgre_driver.php111
-rw-r--r--system/database/drivers/postgre/postgre_forge.php39
-rw-r--r--system/database/drivers/postgre/postgre_result.php42
-rw-r--r--system/helpers/cookie_helper.php8
-rw-r--r--system/helpers/date_helper.php47
-rw-r--r--system/helpers/inflector_helper.php2
-rw-r--r--system/helpers/path_helper.php18
-rw-r--r--system/helpers/security_helper.php16
-rw-r--r--system/language/english/upload_lang.php2
-rw-r--r--system/libraries/Form_validation.php2
-rw-r--r--system/libraries/Session.php41
-rw-r--r--system/libraries/Table.php4
29 files changed, 434 insertions, 460 deletions
diff --git a/system/core/Config.php b/system/core/Config.php
index 1e149d005..91826bd41 100755
--- a/system/core/Config.php
+++ b/system/core/Config.php
@@ -76,7 +76,7 @@ class CI_Config {
log_message('debug', 'Config Class Initialized');
// Set the base_url automatically if none was provided
- if ($this->config['base_url'] == '')
+ if (empty($this->config['base_url']))
{
if (isset($_SERVER['HTTP_HOST']))
{
diff --git a/system/core/Input.php b/system/core/Input.php
index 901b4147e..6e6885992 100755
--- a/system/core/Input.php
+++ b/system/core/Input.php
@@ -228,7 +228,7 @@ class CI_Input {
/**
* Set cookie
*
- * Accepts six parameter, or you can submit an associative
+ * Accepts seven parameters, or you can submit an associative
* array in the first parameter containing all the values.
*
* @param mixed
@@ -238,14 +238,15 @@ class CI_Input {
* @param string the cookie path
* @param string the cookie prefix
* @param bool true makes the cookie secure
+ * @param bool true makes the cookie accessible via http(s) only (no javascript)
* @return void
*/
- public function set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = '/', $prefix = '', $secure = FALSE)
+ public function set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = '/', $prefix = '', $secure = FALSE, $httponly = FALSE)
{
if (is_array($name))
{
// always leave 'name' in last place, as the loop will break otherwise, due to $$item
- foreach (array('value', 'expire', 'domain', 'path', 'prefix', 'secure', 'name') as $item)
+ foreach (array('value', 'expire', 'domain', 'path', 'prefix', 'secure', 'httponly', 'name') as $item)
{
if (isset($name[$item]))
{
@@ -270,6 +271,10 @@ class CI_Input {
{
$secure = config_item('cookie_secure');
}
+ if ($httponly == FALSE && config_item('cookie_httponly') != FALSE)
+ {
+ $httponly = config_item('cookie_httponly');
+ }
if ( ! is_numeric($expire))
{
@@ -280,7 +285,7 @@ class CI_Input {
$expire = ($expire > 0) ? time() + $expire : 0;
}
- setcookie($prefix.$name, $value, $expire, $path, $domain, $secure);
+ setcookie($prefix.$name, $value, $expire, $path, $domain, $secure, $httponly);
}
// --------------------------------------------------------------------
diff --git a/system/core/Security.php b/system/core/Security.php
index cd8a61028..ac39ce97b 100755
--- a/system/core/Security.php
+++ b/system/core/Security.php
@@ -196,7 +196,15 @@ class CI_Security {
return FALSE;
}
- setcookie($this->_csrf_cookie_name, $this->_csrf_hash, $expire, config_item('cookie_path'), config_item('cookie_domain'), $secure_cookie);
+ setcookie(
+ $this->_csrf_cookie_name,
+ $this->_csrf_hash,
+ $expire,
+ config_item('cookie_path'),
+ config_item('cookie_domain'),
+ $secure_cookie,
+ config_item('cookie_httponly')
+ );
log_message('debug', 'CRSF cookie Set');
return $this;
diff --git a/system/core/URI.php b/system/core/URI.php
index 4a2e87c2a..48bb7ae3c 100755
--- a/system/core/URI.php
+++ b/system/core/URI.php
@@ -22,7 +22,6 @@
* @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* @link http://codeigniter.com
* @since Version 1.0
- * @filesource
*/
// ------------------------------------------------------------------------
@@ -93,7 +92,7 @@ class CI_URI {
if (strtoupper($this->config->item('uri_protocol')) === 'AUTO')
{
// Is the request coming from the command line?
- if (php_sapi_name() === 'cli' OR defined('STDIN'))
+ if ($this->_is_cli_request())
{
$this->_set_uri_string($this->_parse_cli_args());
return;
@@ -227,6 +226,21 @@ class CI_URI {
}
// --------------------------------------------------------------------
+
+ /**
+ * Is cli Request?
+ *
+ * Duplicate of function from the Input class to test to see if a request was made from the command line
+ *
+ * @return boolean
+ */
+ protected function _is_cli_request()
+ {
+ return (php_sapi_name() == 'cli') OR defined('STDIN');
+ }
+
+
+ // --------------------------------------------------------------------
/**
* Parse cli arguments
diff --git a/system/database/DB_active_rec.php b/system/database/DB_active_rec.php
index 756709698..35164a79c 100644
--- a/system/database/DB_active_rec.php
+++ b/system/database/DB_active_rec.php
@@ -214,6 +214,7 @@ class CI_DB_active_record extends CI_DB_driver {
$sql = $this->protect_identifiers($type.'('.trim($select).')').' AS '.$this->protect_identifiers(trim($alias));
$this->ar_select[] = $sql;
+ $this->ar_no_escape[] = NULL;
if ($this->ar_caching === TRUE)
{
diff --git a/system/database/drivers/cubrid/cubrid_driver.php b/system/database/drivers/cubrid/cubrid_driver.php
index 244707395..7b468bc5c 100644
--- a/system/database/drivers/cubrid/cubrid_driver.php
+++ b/system/database/drivers/cubrid/cubrid_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
*/
-// ------------------------------------------------------------------------
-
/**
* CUBRID Database Adapter Class
*
@@ -42,39 +40,35 @@
*/
class CI_DB_cubrid_driver extends CI_DB {
- // Default CUBRID Broker port. Will be used unless user
- // explicitly specifies another one.
- const DEFAULT_PORT = 33000;
-
- var $dbdriver = 'cubrid';
+ public $dbdriver = 'cubrid';
// The character used for escaping - no need in CUBRID
- var $_escape_char = '';
+ protected $_escape_char = '';
// clause and character used for LIKE escape sequences - not used in CUBRID
- 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 = ' RAND()'; // database specific random keyword
+ protected $_count_string = 'SELECT COUNT(*) AS ';
+ protected $_random_keyword = ' RAND()'; // 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 no port is defined by the user, use the default value
if ($this->port == '')
{
- $this->port = self::DEFAULT_PORT;
+ // Default CUBRID Broker port
+ $this->port = 33000;
}
$conn = cubrid_connect($this->hostname, $this->port, $this->database, $this->username, $this->password);
@@ -101,6 +95,7 @@ class CI_DB_cubrid_driver extends CI_DB {
/**
* Persistent database connection
+ *
* In CUBRID persistent DB connection is supported natively in CUBRID
* engine which can be configured in the CUBRID Broker configuration
* file by setting the CCI_PCONNECT parameter to ON. In that case, all
@@ -109,10 +104,9 @@ class CI_DB_cubrid_driver extends CI_DB {
* @cubrid_connect function will establish persisten connection
* considering that the CCI_PCONNECT is ON.
*
- * @access private called by the base class
* @return resource
*/
- function db_pconnect()
+ public function db_pconnect()
{
return $this->db_connect();
}
@@ -125,10 +119,9 @@ class CI_DB_cubrid_driver extends CI_DB {
* 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()
+ public function reconnect()
{
if (cubrid_ping($this->conn_id) === FALSE)
{
@@ -141,10 +134,9 @@ class CI_DB_cubrid_driver extends CI_DB {
/**
* Select the database
*
- * @access private called by the base class
* @return resource
*/
- function db_select()
+ public function db_select()
{
// In CUBRID there is no need to select a database as the database
// is chosen at the connection time.
@@ -172,11 +164,10 @@ class CI_DB_cubrid_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 @cubrid_query($sql, $this->conn_id);
@@ -189,11 +180,10 @@ class CI_DB_cubrid_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)
{
// No need to prepare
return $sql;
@@ -204,10 +194,9 @@ class CI_DB_cubrid_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)
{
@@ -238,10 +227,9 @@ class CI_DB_cubrid_driver extends CI_DB {
/**
* Commit Transaction
*
- * @access public
* @return bool
*/
- function trans_commit()
+ public function trans_commit()
{
if ( ! $this->trans_enabled)
{
@@ -269,10 +257,9 @@ class CI_DB_cubrid_driver extends CI_DB {
/**
* Rollback Transaction
*
- * @access public
* @return bool
*/
- function trans_rollback()
+ public function trans_rollback()
{
if ( ! $this->trans_enabled)
{
@@ -300,12 +287,11 @@ class CI_DB_cubrid_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))
{
@@ -352,10 +338,9 @@ class CI_DB_cubrid_driver extends CI_DB {
/**
* Insert ID
*
- * @access public
- * @return integer
+ * @return int
*/
- function insert_id()
+ public function insert_id()
{
return @cubrid_insert_id($this->conn_id);
}
@@ -368,11 +353,10 @@ class CI_DB_cubrid_driver extends CI_DB {
* Generates a platform-specific query string that counts all records in
* the specified table
*
- * @access public
* @param string
- * @return string
+ * @return int
*/
- function count_all($table = '')
+ public function count_all($table = '')
{
if ($table == '')
{
@@ -397,11 +381,10 @@ class CI_DB_cubrid_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 = "SHOW TABLES";
@@ -420,11 +403,10 @@ class CI_DB_cubrid_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->protect_identifiers($table, TRUE, NULL, FALSE);
}
@@ -436,11 +418,10 @@ class CI_DB_cubrid_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";
}
@@ -465,11 +446,10 @@ class CI_DB_cubrid_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 == '')
{
@@ -508,11 +488,10 @@ class CI_DB_cubrid_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))
{
@@ -529,13 +508,12 @@ class CI_DB_cubrid_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).")";
}
@@ -548,13 +526,12 @@ class CI_DB_cubrid_driver extends CI_DB {
*
* Generates a platform-specific replace 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 _replace($table, $keys, $values)
+ protected function _replace($table, $keys, $values)
{
return "REPLACE INTO ".$table." (\"".implode('", "', $keys)."\") VALUES (".implode(', ', $values).")";
}
@@ -566,13 +543,12 @@ class CI_DB_cubrid_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_batch($table, $keys, $values)
+ protected function _insert_batch($table, $keys, $values)
{
return "INSERT INTO ".$table." (\"".implode('", "', $keys)."\") VALUES ".implode(', ', $values);
}
@@ -585,7 +561,6 @@ class CI_DB_cubrid_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
@@ -593,7 +568,7 @@ class CI_DB_cubrid_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)
{
@@ -621,13 +596,12 @@ class CI_DB_cubrid_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 != '' AND count($where) >=1) ? implode(" ", $where).' AND ' : '';
@@ -668,7 +642,6 @@ class CI_DB_cubrid_driver extends CI_DB {
// --------------------------------------------------------------------
-
/**
* Truncate statement
*
@@ -676,11 +649,10 @@ class CI_DB_cubrid_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;
}
@@ -692,13 +664,12 @@ class CI_DB_cubrid_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 = '';
@@ -726,13 +697,12 @@ class CI_DB_cubrid_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)
{
@@ -751,17 +721,15 @@ class CI_DB_cubrid_driver extends CI_DB {
/**
* Close DB Connection
*
- * @access public
* @param resource
* @return void
*/
- function _close($conn_id)
+ protected function _close($conn_id)
{
@cubrid_close($conn_id);
}
}
-
/* End of file cubrid_driver.php */
/* Location: ./system/database/drivers/cubrid/cubrid_driver.php */
diff --git a/system/database/drivers/cubrid/cubrid_forge.php b/system/database/drivers/cubrid/cubrid_forge.php
index 7d606ea36..bbda484c4 100644
--- a/system/database/drivers/cubrid/cubrid_forge.php
+++ b/system/database/drivers/cubrid/cubrid_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
*/
-// ------------------------------------------------------------------------
-
/**
* CUBRID Forge Class
*
@@ -39,11 +37,10 @@ class CI_DB_cubrid_forge extends CI_DB_forge {
/**
* Create database
*
- * @access private
* @param string the database name
* @return bool
*/
- function _create_database($name)
+ public function _create_database($name)
{
// CUBRID does not allow to create a database in SQL. The GUI tools
// have to be used for this purpose.
@@ -55,11 +52,10 @@ class CI_DB_cubrid_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)
{
// CUBRID does not allow to drop a database in SQL. The GUI tools
// have to be used for this purpose.
@@ -71,16 +67,15 @@ class CI_DB_cubrid_forge extends CI_DB_forge {
/**
* Process Fields
*
- * @access private
* @param mixed the fields
* @return string
*/
- function _process_fields($fields)
+ protected function _process_fields($fields)
{
$current_field_count = 0;
$sql = '';
- 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
@@ -172,15 +167,14 @@ class CI_DB_cubrid_forge extends CI_DB_forge {
/**
* Create Table
*
- * @access private
* @param string the table name
* @param mixed 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 ';
@@ -232,10 +226,9 @@ class CI_DB_cubrid_forge extends CI_DB_forge {
/**
* Drop Table
*
- * @access private
* @return string
*/
- function _drop_table($table)
+ public function _drop_table($table)
{
return "DROP TABLE IF EXISTS ".$this->db->_escape_identifiers($table);
}
@@ -248,14 +241,13 @@ class CI_DB_cubrid_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 array fields
* @param string the field after which we should add the new field
- * @return object
+ * @return string
*/
- function _alter_table($alter_type, $table, $fields, $after_field = '')
+ public function _alter_table($alter_type, $table, $fields, $after_field = '')
{
$sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' ';
@@ -282,12 +274,11 @@ class CI_DB_cubrid_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 'RENAME TABLE '.$this->db->protect_identifiers($table_name).' AS '.$this->db->protect_identifiers($new_table_name);
}
@@ -295,4 +286,4 @@ class CI_DB_cubrid_forge extends CI_DB_forge {
}
/* End of file cubrid_forge.php */
-/* Location: ./system/database/drivers/cubrid/cubrid_forge.php */
+/* Location: ./system/database/drivers/cubrid/cubrid_forge.php */ \ No newline at end of file
diff --git a/system/database/drivers/cubrid/cubrid_result.php b/system/database/drivers/cubrid/cubrid_result.php
index a7eeb8a39..6a61a213d 100644
--- a/system/database/drivers/cubrid/cubrid_result.php
+++ b/system/database/drivers/cubrid/cubrid_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
*/
-// --------------------------------------------------------------------
-
/**
* CUBRID Result Class
*
@@ -41,10 +39,9 @@ class CI_DB_cubrid_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 @cubrid_num_rows($this->result_id);
}
@@ -54,10 +51,9 @@ class CI_DB_cubrid_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 @cubrid_num_fields($this->result_id);
}
@@ -69,10 +65,9 @@ class CI_DB_cubrid_result extends CI_DB_result {
*
* Generates an array of column names
*
- * @access public
* @return array
*/
- function list_fields()
+ public function list_fields()
{
return cubrid_column_names($this->result_id);
}
@@ -84,10 +79,9 @@ class CI_DB_cubrid_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();
@@ -147,9 +141,9 @@ class CI_DB_cubrid_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) ||
get_resource_type($this->result_id) == "Unknown" &&
@@ -169,10 +163,9 @@ class CI_DB_cubrid_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 cubrid_data_seek($this->result_id, $n);
}
@@ -184,10 +177,9 @@ class CI_DB_cubrid_result extends CI_DB_result {
*
* Returns the result set as an array
*
- * @access private
* @return array
*/
- function _fetch_assoc()
+ protected function _fetch_assoc()
{
return cubrid_fetch_assoc($this->result_id);
}
@@ -199,16 +191,14 @@ class CI_DB_cubrid_result extends CI_DB_result {
*
* Returns the result set as an object
*
- * @access private
* @return object
*/
- function _fetch_object()
+ protected function _fetch_object()
{
return cubrid_fetch_object($this->result_id);
}
}
-
/* End of file cubrid_result.php */
/* Location: ./system/database/drivers/cubrid/cubrid_result.php */ \ No newline at end of file
diff --git a/system/database/drivers/cubrid/cubrid_utility.php b/system/database/drivers/cubrid/cubrid_utility.php
index a13c0a5e4..dafd66146 100644
--- a/system/database/drivers/cubrid/cubrid_utility.php
+++ b/system/database/drivers/cubrid/cubrid_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
*/
-// ------------------------------------------------------------------------
-
/**
* CUBRID Utility Class
*
@@ -39,10 +37,9 @@ class CI_DB_cubrid_utility extends CI_DB_utility {
/**
* List databases
*
- * @access private
* @return array
*/
- function _list_databases()
+ public function _list_databases()
{
// CUBRID does not allow to see the list of all databases on the
// server. It is the way its architecture is designed. Every
@@ -66,12 +63,11 @@ class CI_DB_cubrid_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
* @link http://www.cubrid.org/manual/840/en/Optimize%20Database
*/
- function _optimize_table($table)
+ public function _optimize_table($table)
{
// No SQL based support in CUBRID as of version 8.4.0. Database or
// table optimization can be performed using CUBRID Manager
@@ -86,12 +82,11 @@ class CI_DB_cubrid_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
* @link http://www.cubrid.org/manual/840/en/Checking%20Database%20Consistency
*/
- function _repair_table($table)
+ public function _repair_table($table)
{
// Not supported in CUBRID as of version 8.4.0. Database or
// table consistency can be checked using CUBRID Manager
@@ -103,11 +98,10 @@ class CI_DB_cubrid_utility extends CI_DB_utility {
/**
* CUBRID Export
*
- * @access private
* @param array Preferences
* @return mixed
*/
- function _backup($params = array())
+ public function _backup($params = array())
{
// No SQL based support in CUBRID as of version 8.4.0. Database or
// table backup can be performed using CUBRID Manager
diff --git a/system/database/drivers/mysql/mysql_forge.php b/system/database/drivers/mysql/mysql_forge.php
index 004a5a103..d317ac3e0 100644
--- a/system/database/drivers/mysql/mysql_forge.php
+++ b/system/database/drivers/mysql/mysql_forge.php
@@ -66,7 +66,7 @@ class CI_DB_mysql_forge extends CI_DB_forge {
* @param mixed the fields
* @return string
*/
- private function _process_fields($fields)
+ protected function _process_fields($fields)
{
$current_field_count = 0;
$sql = '';
diff --git a/system/database/drivers/mysqli/mysqli_forge.php b/system/database/drivers/mysqli/mysqli_forge.php
index 9cb1a0c70..9ec4bf7aa 100644
--- a/system/database/drivers/mysqli/mysqli_forge.php
+++ b/system/database/drivers/mysqli/mysqli_forge.php
@@ -66,7 +66,7 @@ class CI_DB_mysqli_forge extends CI_DB_forge {
* @param mixed the fields
* @return string
*/
- public function _process_fields($fields)
+ protected function _process_fields($fields)
{
$current_field_count = 0;
$sql = '';
diff --git a/system/database/drivers/odbc/odbc_driver.php b/system/database/drivers/odbc/odbc_driver.php
index acc2838e3..cfa561c3d 100644
--- a/system/database/drivers/odbc/odbc_driver.php
+++ b/system/database/drivers/odbc/odbc_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
*/
-// ------------------------------------------------------------------------
-
/**
* ODBC Database Adapter Class
*
@@ -42,25 +40,25 @@
*/
class CI_DB_odbc_driver extends CI_DB {
- var $dbdriver = 'odbc';
+ public $dbdriver = 'odbc';
// the character used to excape - not necessary for ODBC
- 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;
+ protected $_count_string = 'SELECT COUNT(*) AS ';
+ protected $_random_keyword;
- function __construct($params)
+ public function __construct($params)
{
parent::__construct($params);
@@ -70,10 +68,9 @@ class CI_DB_odbc_driver extends CI_DB {
/**
* Non-persistent database connection
*
- * @access private called by the base class
* @return resource
*/
- function db_connect()
+ public function db_connect()
{
return @odbc_connect($this->hostname, $this->username, $this->password);
}
@@ -83,10 +80,9 @@ class CI_DB_odbc_driver extends CI_DB {
/**
* Persistent database connection
*
- * @access private called by the base class
* @return resource
*/
- function db_pconnect()
+ public function db_pconnect()
{
return @odbc_pconnect($this->hostname, $this->username, $this->password);
}
@@ -99,10 +95,9 @@ class CI_DB_odbc_driver extends CI_DB {
* 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()
+ public function reconnect()
{
// not implemented in odbc
}
@@ -112,10 +107,9 @@ class CI_DB_odbc_driver extends CI_DB {
/**
* Select the database
*
- * @access private called by the base class
* @return resource
*/
- function db_select()
+ public function db_select()
{
// Not needed for ODBC
return TRUE;
@@ -126,11 +120,10 @@ class CI_DB_odbc_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 @odbc_exec($this->conn_id, $sql);
@@ -143,11 +136,10 @@ class CI_DB_odbc_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)
{
return $sql;
}
@@ -157,10 +149,9 @@ class CI_DB_odbc_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)
{
@@ -186,10 +177,9 @@ class CI_DB_odbc_driver extends CI_DB {
/**
* Commit Transaction
*
- * @access public
* @return bool
*/
- function trans_commit()
+ public function trans_commit()
{
if ( ! $this->trans_enabled)
{
@@ -212,10 +202,9 @@ class CI_DB_odbc_driver extends CI_DB {
/**
* Rollback Transaction
*
- * @access public
* @return bool
*/
- function trans_rollback()
+ public function trans_rollback()
{
if ( ! $this->trans_enabled)
{
@@ -238,12 +227,11 @@ class CI_DB_odbc_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))
{
@@ -261,9 +249,9 @@ class CI_DB_odbc_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;
@@ -274,10 +262,9 @@ class CI_DB_odbc_driver extends CI_DB {
/**
* Affected Rows
*
- * @access public
- * @return integer
+ * @return int
*/
- function affected_rows()
+ public function affected_rows()
{
return @odbc_num_rows($this->conn_id);
}
@@ -302,11 +289,10 @@ class CI_DB_odbc_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 == '')
{
@@ -332,11 +318,10 @@ class CI_DB_odbc_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 = "SHOW TABLES FROM `".$this->database."`";
@@ -356,11 +341,10 @@ class CI_DB_odbc_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 ".$table;
}
@@ -372,11 +356,10 @@ class CI_DB_odbc_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;
}
@@ -403,11 +386,10 @@ class CI_DB_odbc_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 == '')
{
@@ -446,11 +428,10 @@ class CI_DB_odbc_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))
{
@@ -467,13 +448,12 @@ class CI_DB_odbc_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).")";
}
@@ -485,7 +465,6 @@ class CI_DB_odbc_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
@@ -493,7 +472,7 @@ class CI_DB_odbc_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)
{
@@ -523,11 +502,10 @@ class CI_DB_odbc_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);
}
@@ -539,13 +517,12 @@ class CI_DB_odbc_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 = '';
@@ -573,13 +550,12 @@ class CI_DB_odbc_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)
{
// Does ODBC doesn't use the LIMIT clause?
return $sql;
@@ -590,19 +566,15 @@ class CI_DB_odbc_driver extends CI_DB {
/**
* Close DB Connection
*
- * @access public
* @param resource
* @return void
*/
- function _close($conn_id)
+ protected function _close($conn_id)
{
@odbc_close($conn_id);
}
-
}
-
-
/* End of file odbc_driver.php */
/* Location: ./system/database/drivers/odbc/odbc_driver.php */
diff --git a/system/database/drivers/odbc/odbc_forge.php b/system/database/drivers/odbc/odbc_forge.php
index acc2cadee..26a524a64 100644
--- a/system/database/drivers/odbc/odbc_forge.php
+++ b/system/database/drivers/odbc/odbc_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
*/
-// ------------------------------------------------------------------------
-
/**
* ODBC Forge Class
*
@@ -39,11 +37,10 @@ class CI_DB_odbc_forge extends CI_DB_forge {
/**
* Create database
*
- * @access private
* @param string the database name
* @return bool
*/
- function _create_database()
+ public function _create_database()
{
// ODBC has no "create database" command since it's
// designed to connect to an existing database
@@ -59,11 +56,10 @@ class CI_DB_odbc_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)
{
// ODBC has no "drop database" command since it's
// designed to connect to an existing database
@@ -79,15 +75,14 @@ class CI_DB_odbc_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 ';
@@ -99,7 +94,7 @@ class CI_DB_odbc_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
@@ -186,10 +181,9 @@ class CI_DB_odbc_forge extends CI_DB_forge {
/**
* Drop Table
*
- * @access private
* @return bool
*/
- function _drop_table($table)
+ public function _drop_table($table)
{
// Not a supported ODBC feature
if ($this->db->db_debug)
@@ -207,17 +201,16 @@ class CI_DB_odbc_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);
@@ -260,12 +253,11 @@ class CI_DB_odbc_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);
}
diff --git a/system/database/drivers/odbc/odbc_result.php b/system/database/drivers/odbc/odbc_result.php
index d19fa247e..f6aee356f 100644
--- a/system/database/drivers/odbc/odbc_result.php
+++ b/system/database/drivers/odbc/odbc_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
*/
-// ------------------------------------------------------------------------
-
/**
* ODBC Result Class
*
@@ -128,9 +126,9 @@ class CI_DB_odbc_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))
{
@@ -148,10 +146,9 @@ class CI_DB_odbc_result extends CI_DB_result {
* 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;
}
@@ -163,12 +160,11 @@ class CI_DB_odbc_result extends CI_DB_result {
*
* Returns the result set as an array
*
- * @access private
* @return array
*/
- function _fetch_assoc()
+ protected function _fetch_assoc()
{
- if (function_exists('odbc_fetch_object'))
+ if (function_exists('odbc_fetch_array'))
{
return odbc_fetch_array($this->result_id);
}
@@ -185,10 +181,9 @@ class CI_DB_odbc_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('odbc_fetch_object'))
{
@@ -200,6 +195,7 @@ class CI_DB_odbc_result extends CI_DB_result {
}
}
+ // --------------------------------------------------------------------
/**
* Result - object
@@ -207,21 +203,24 @@ class CI_DB_odbc_result extends CI_DB_result {
* subsititutes the odbc_fetch_object function when
* not available (odbc_fetch_object requires unixODBC)
*
- * @access private
* @return object
*/
- function _odbc_fetch_object(& $odbc_result) {
+ protected function _odbc_fetch_object(& $odbc_result)
+ {
$rs = array();
$rs_obj = FALSE;
- if (odbc_fetch_into($odbc_result, $rs)) {
- foreach ($rs as $k=>$v) {
- $field_name= odbc_field_name($odbc_result, $k+1);
+ if (odbc_fetch_into($odbc_result, $rs))
+ {
+ foreach ($rs as $k => $v)
+ {
+ $field_name = odbc_field_name($odbc_result, $k+1);
$rs_obj->$field_name = $v;
}
}
return $rs_obj;
}
+ // --------------------------------------------------------------------
/**
* Result - array
@@ -229,16 +228,18 @@ class CI_DB_odbc_result extends CI_DB_result {
* subsititutes the odbc_fetch_array function when
* not available (odbc_fetch_array requires unixODBC)
*
- * @access private
* @return array
*/
- function _odbc_fetch_array(& $odbc_result) {
+ protected function _odbc_fetch_array(& $odbc_result)
+ {
$rs = array();
$rs_assoc = FALSE;
- if (odbc_fetch_into($odbc_result, $rs)) {
- $rs_assoc=array();
- foreach ($rs as $k=>$v) {
- $field_name= odbc_field_name($odbc_result, $k+1);
+ if (odbc_fetch_into($odbc_result, $rs))
+ {
+ $rs_assoc = array();
+ foreach ($rs as $k => $v)
+ {
+ $field_name = odbc_field_name($odbc_result, $k+1);
$rs_assoc[$field_name] = $v;
}
}
diff --git a/system/database/drivers/odbc/odbc_utility.php b/system/database/drivers/odbc/odbc_utility.php
index c146c1785..5244f084f 100644
--- a/system/database/drivers/odbc/odbc_utility.php
+++ b/system/database/drivers/odbc/odbc_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
*/
-// ------------------------------------------------------------------------
-
/**
* ODBC Utility Class
*
@@ -39,10 +37,9 @@ class CI_DB_odbc_utility extends CI_DB_utility {
/**
* List databases
*
- * @access private
* @return bool
*/
- function _list_databases()
+ public function _list_databases()
{
// Not sure if ODBC lets you list all databases...
if ($this->db->db_debug)
@@ -59,11 +56,10 @@ class CI_DB_odbc_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 ODBC feature
if ($this->db->db_debug)
@@ -80,11 +76,10 @@ class CI_DB_odbc_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 ODBC feature
if ($this->db->db_debug)
@@ -99,11 +94,10 @@ class CI_DB_odbc_utility extends CI_DB_utility {
/**
* ODBC 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');
@@ -112,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 */ \ No newline at end of file
+/* Location: ./system/database/drivers/odbc/odbc_utility.php */
diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php
index 09764779a..658a3d5a0 100644
--- a/system/database/drivers/pdo/pdo_driver.php
+++ b/system/database/drivers/pdo/pdo_driver.php
@@ -561,6 +561,11 @@ class CI_DB_pdo_driver extends CI_DB {
// Analog function to show all tables in postgre
$sql = "SELECT * FROM information_schema.tables WHERE table_schema = 'public'";
}
+ elseif ($this->pdodriver == 'sqlite')
+ {
+ // Analog function to show all tables in sqlite
+ $sql = "SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%'";
+ }
else
{
$sql = "SHOW TABLES FROM `".$this->database."`";
@@ -603,6 +608,22 @@ class CI_DB_pdo_driver extends CI_DB {
*/
function _field_data($table)
{
+ if ($this->pdodriver == 'mysql' or $this->pdodriver == 'pgsql')
+ {
+ // Analog function for mysql and postgre
+ return 'SELECT * FROM '.$this->_from_tables($table).' LIMIT 1';
+ }
+ elseif ($this->pdodriver == 'oci')
+ {
+ // Analog function for oci
+ return 'SELECT * FROM '.$this->_from_tables($table).' WHERE ROWNUM <= 1';
+ }
+ elseif ($this->pdodriver == 'sqlite')
+ {
+ // Analog function for sqlite
+ return 'PRAGMA table_info('.$this->_from_tables($table).')';
+ }
+
return 'SELECT TOP 1 FROM '.$this->_from_tables($table);
}
diff --git a/system/database/drivers/pdo/pdo_result.php b/system/database/drivers/pdo/pdo_result.php
index 309f1947d..384b753da 100644
--- a/system/database/drivers/pdo/pdo_result.php
+++ b/system/database/drivers/pdo/pdo_result.php
@@ -160,9 +160,48 @@ class CI_DB_pdo_result extends CI_DB_result {
try
{
- for($i = 0; $i < $this->num_fields(); $i++)
+ if (strpos($this->result_id->queryString, 'PRAGMA') !== FALSE)
{
- $data[] = $this->result_id->getColumnMeta($i);
+ foreach ($this->result_array() as $field)
+ {
+ preg_match('/([a-zA-Z]+)(\(\d+\))?/', $field['type'], $matches);
+
+ $F = new stdClass();
+ $F->name = $field['name'];
+ $F->type = ( ! empty($matches[1])) ? $matches[1] : NULL;
+ $F->default = NULL;
+ $F->max_length = ( ! empty($matches[2])) ? preg_replace('/[^\d]/', '', $matches[2]) : NULL;
+ $F->primary_key = (int) $field['pk'];
+ $F->pdo_type = NULL;
+
+ $data[] = $F;
+ }
+ }
+ else
+ {
+ for($i = 0, $max = $this->num_fields(); $i < $max; $i++)
+ {
+ $field = $this->result_id->getColumnMeta($i);
+
+ $F = new stdClass();
+ $F->name = $field['name'];
+ $F->type = $field['native_type'];
+ $F->default = NULL;
+ $F->pdo_type = $field['pdo_type'];
+
+ if ($field['precision'] < 0)
+ {
+ $F->max_length = NULL;
+ $F->primary_key = 0;
+ }
+ else
+ {
+ $F->max_length = ($field['len'] > 255) ? 0 : $field['len'];
+ $F->primary_key = (int) ( ! empty($field['flags']) && in_array('primary_key', $field['flags']));
+ }
+
+ $data[] = $F;
+ }
}
return $data;
diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php
index 5d22af2e6..8112cf9de 100644
--- a/system/database/drivers/postgre/postgre_driver.php
+++ b/system/database/drivers/postgre/postgre_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
*/
-// ------------------------------------------------------------------------
-
/**
* Postgre Database Adapter Class
*
@@ -42,29 +40,28 @@
*/
class CI_DB_postgre_driver extends CI_DB {
- var $dbdriver = 'postgre';
+ public $dbdriver = 'postgre';
- 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
/**
* Connection String
*
- * @access private
* @return string
*/
- function _connect_string()
+ protected function _connect_string()
{
$components = array(
'hostname' => 'host',
@@ -90,10 +87,9 @@ class CI_DB_postgre_driver extends CI_DB {
/**
* Non-persistent database connection
*
- * @access private called by the base class
* @return resource
*/
- function db_connect()
+ public function db_connect()
{
return @pg_connect($this->_connect_string());
}
@@ -103,10 +99,9 @@ class CI_DB_postgre_driver extends CI_DB {
/**
* Persistent database connection
*
- * @access private called by the base class
* @return resource
*/
- function db_pconnect()
+ public function db_pconnect()
{
return @pg_pconnect($this->_connect_string());
}
@@ -119,10 +114,9 @@ class CI_DB_postgre_driver extends CI_DB {
* 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()
+ public function reconnect()
{
if (pg_ping($this->conn_id) === FALSE)
{
@@ -135,10 +129,9 @@ class CI_DB_postgre_driver extends CI_DB {
/**
* Select the database
*
- * @access private called by the base class
* @return resource
*/
- function db_select()
+ public function db_select()
{
// Not needed for Postgre so we'll return TRUE
return TRUE;
@@ -191,11 +184,10 @@ class CI_DB_postgre_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 @pg_query($this->conn_id, $sql);
@@ -208,11 +200,10 @@ class CI_DB_postgre_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)
{
return $sql;
}
@@ -281,12 +272,11 @@ class CI_DB_postgre_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))
{
@@ -303,9 +293,9 @@ class CI_DB_postgre_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;
@@ -316,10 +306,9 @@ class CI_DB_postgre_driver extends CI_DB {
/**
* Affected Rows
*
- * @access public
- * @return integer
+ * @return int
*/
- function affected_rows()
+ public function affected_rows()
{
return @pg_affected_rows($this->result_id);
}
@@ -329,10 +318,9 @@ class CI_DB_postgre_driver extends CI_DB {
/**
* Insert ID
*
- * @access public
- * @return integer
+ * @return string
*/
- function insert_id()
+ public function insert_id()
{
$v = $this->version();
@@ -372,11 +360,10 @@ class CI_DB_postgre_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 == '')
{
@@ -401,11 +388,10 @@ class CI_DB_postgre_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 table_name FROM information_schema.tables WHERE table_schema = 'public'";
@@ -424,11 +410,10 @@ class CI_DB_postgre_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 "SELECT column_name FROM information_schema.columns WHERE table_name ='".$table."'";
}
@@ -440,11 +425,10 @@ class CI_DB_postgre_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
*/
- function _field_data($table)
+ protected function _field_data($table)
{
return "SELECT * FROM ".$table." LIMIT 1";
}
@@ -471,11 +455,10 @@ class CI_DB_postgre_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 == '')
{
@@ -514,11 +497,10 @@ class CI_DB_postgre_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))
{
@@ -535,13 +517,12 @@ class CI_DB_postgre_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).")";
}
@@ -553,13 +534,12 @@ class CI_DB_postgre_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_batch($table, $keys, $values)
+ protected function _insert_batch($table, $keys, $values)
{
return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES ".implode(', ', $values);
}
@@ -571,7 +551,6 @@ class CI_DB_postgre_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
@@ -579,7 +558,7 @@ class CI_DB_postgre_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)
{
@@ -602,11 +581,10 @@ class CI_DB_postgre_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;
}
@@ -618,13 +596,12 @@ class CI_DB_postgre_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 = '';
@@ -649,13 +626,12 @@ class CI_DB_postgre_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)
{
$sql .= "LIMIT ".$limit;
@@ -672,18 +648,15 @@ class CI_DB_postgre_driver extends CI_DB {
/**
* Close DB Connection
*
- * @access public
* @param resource
* @return void
*/
- function _close($conn_id)
+ protected function _close($conn_id)
{
@pg_close($conn_id);
}
-
}
-
/* End of file postgre_driver.php */
/* Location: ./system/database/drivers/postgre/postgre_driver.php */
diff --git a/system/database/drivers/postgre/postgre_forge.php b/system/database/drivers/postgre/postgre_forge.php
index 577100544..2a8fdd676 100644
--- a/system/database/drivers/postgre/postgre_forge.php
+++ b/system/database/drivers/postgre/postgre_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
*/
-// ------------------------------------------------------------------------
-
/**
* Postgre Forge Class
*
@@ -39,11 +37,10 @@ class CI_DB_postgre_forge extends CI_DB_forge {
/**
* Create database
*
- * @access private
* @param string the database name
* @return bool
*/
- function _create_database($name)
+ public function _create_database($name)
{
return "CREATE DATABASE ".$name;
}
@@ -53,29 +50,28 @@ class CI_DB_postgre_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;
}
// --------------------------------------------------------------------
-
+
/**
* Process Fields
*
* @param mixed the fields
* @return string
*/
- function _process_fields($fields, $primary_keys=array())
+ protected function _process_fields($fields, $primary_keys=array())
{
$sql = '';
$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
@@ -168,7 +164,7 @@ class CI_DB_postgre_forge extends CI_DB_forge {
$sql .= ',';
}
}
-
+
return $sql;
}
@@ -177,15 +173,14 @@ class CI_DB_postgre_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 ';
@@ -241,8 +236,10 @@ class CI_DB_postgre_forge extends CI_DB_forge {
/**
* Drop Table
+ *
+ * @return string
*/
- function _drop_table($table)
+ public function _drop_table($table)
{
return "DROP TABLE IF EXISTS ".$this->db->_escape_identifiers($table)." CASCADE";
}
@@ -255,7 +252,6 @@ class CI_DB_postgre_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
@@ -263,9 +259,9 @@ class CI_DB_postgre_forge extends CI_DB_forge {
* @param string the default value
* @param boolean 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, $fields, $after_field = '')
+ public function _alter_table($alter_type, $table, $fields, $after_field = '')
{
$sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' ';
@@ -292,12 +288,11 @@ class CI_DB_postgre_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);
}
diff --git a/system/database/drivers/postgre/postgre_result.php b/system/database/drivers/postgre/postgre_result.php
index 12d7547c5..b3eafb8f7 100644
--- a/system/database/drivers/postgre/postgre_result.php
+++ b/system/database/drivers/postgre/postgre_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
*/
-// ------------------------------------------------------------------------
-
/**
* Postgres Result Class
*
@@ -41,10 +39,9 @@ class CI_DB_postgre_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 @pg_num_rows($this->result_id);
}
@@ -54,10 +51,9 @@ class CI_DB_postgre_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 @pg_num_fields($this->result_id);
}
@@ -69,10 +65,9 @@ class CI_DB_postgre_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_postgre_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_postgre_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_postgre_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 pg_result_seek($this->result_id, $n);
}
@@ -151,10 +144,9 @@ class CI_DB_postgre_result extends CI_DB_result {
*
* Returns the result set as an array
*
- * @access private
* @return array
*/
- function _fetch_assoc()
+ protected function _fetch_assoc()
{
return pg_fetch_assoc($this->result_id);
}
@@ -166,16 +158,14 @@ class CI_DB_postgre_result extends CI_DB_result {
*
* Returns the result set as an object
*
- * @access private
* @return object
*/
- function _fetch_object()
+ protected function _fetch_object()
{
return pg_fetch_object($this->result_id);
}
}
-
/* End of file postgre_result.php */
-/* Location: ./system/database/drivers/postgre/postgre_result.php */ \ No newline at end of file
+/* Location: ./system/database/drivers/postgre/postgre_result.php */
diff --git a/system/helpers/cookie_helper.php b/system/helpers/cookie_helper.php
index 38a2f78fc..ec8aa3250 100644
--- a/system/helpers/cookie_helper.php
+++ b/system/helpers/cookie_helper.php
@@ -40,7 +40,7 @@
/**
* Set cookie
*
- * Accepts six parameter, or you can submit an associative
+ * Accepts seven parameters, or you can submit an associative
* array in the first parameter containing all the values.
*
* @param mixed
@@ -49,15 +49,17 @@
* @param string the cookie domain. Usually: .yourdomain.com
* @param string the cookie path
* @param string the cookie prefix
+ * @param bool true makes the cookie secure
+ * @param bool true makes the cookie accessible via http(s) only (no javascript)
* @return void
*/
if ( ! function_exists('set_cookie'))
{
- function set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = '/', $prefix = '', $secure = FALSE)
+ function set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = '/', $prefix = '', $secure = FALSE, $httponly = FALSE)
{
// Set the config file options
$CI =& get_instance();
- $CI->input->set_cookie($name, $value, $expire, $domain, $path, $prefix, $secure);
+ $CI->input->set_cookie($name, $value, $expire, $domain, $path, $prefix, $secure, $httponly);
}
}
diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php
index 2a34cf93e..d54553292 100644
--- a/system/helpers/date_helper.php
+++ b/system/helpers/date_helper.php
@@ -128,15 +128,16 @@ if ( ! function_exists('standard_date'))
function standard_date($fmt = 'DATE_RFC822', $time = '')
{
$formats = array(
- 'DATE_ATOM' => '%Y-%m-%dT%H:%i:%s%Q',
+ 'DATE_ATOM' => '%Y-%m-%dT%H:%i:%s%O',
'DATE_COOKIE' => '%l, %d-%M-%y %H:%i:%s UTC',
- 'DATE_ISO8601' => '%Y-%m-%dT%H:%i:%s%Q',
+ 'DATE_ISO8601' => '%Y-%m-%dT%H:%i:%s%O',
'DATE_RFC822' => '%D, %d %M %y %H:%i:%s %O',
'DATE_RFC850' => '%l, %d-%M-%y %H:%i:%s UTC',
'DATE_RFC1036' => '%D, %d %M %y %H:%i:%s %O',
'DATE_RFC1123' => '%D, %d %M %Y %H:%i:%s %O',
+ 'DATE_RFC2822' => '%D, %d %M %Y %H:%i:%s %O',
'DATE_RSS' => '%D, %d %M %Y %H:%i:%s %O',
- 'DATE_W3C' => '%Y-%m-%dT%H:%i:%s%Q'
+ 'DATE_W3C' => '%Y-%m-%dT%H:%i:%s%O'
);
if ( ! isset($formats[$fmt]))
@@ -159,11 +160,12 @@ if ( ! function_exists('standard_date'))
* @access public
* @param integer a number of seconds
* @param integer Unix timestamp
- * @return integer
+ * @param integer a number of display units
+ * @return string
*/
if ( ! function_exists('timespan'))
{
- function timespan($seconds = 1, $time = '')
+ function timespan($seconds = 1, $time = '', $units = 7)
{
$CI =& get_instance();
$CI->lang->load('date');
@@ -178,24 +180,29 @@ if ( ! function_exists('timespan'))
$time = time();
}
+ if ( ! is_numeric($units))
+ {
+ $units = 7;
+ }
+
$seconds = ($time <= $seconds) ? 1 : $time - $seconds;
- $str = '';
+ $str = array();
$years = floor($seconds / 31557600);
if ($years > 0)
{
- $str .= $years.' '.$CI->lang->line((($years > 1) ? 'date_years' : 'date_year')).', ';
+ $str[] = $years.' '.$CI->lang->line((($years > 1) ? 'date_years' : 'date_year'));
}
$seconds -= $years * 31557600;
$months = floor($seconds / 2629743);
- if ($years > 0 OR $months > 0)
+ if (count($str) < $units && ($years > 0 OR $months > 0))
{
if ($months > 0)
{
- $str .= $months.' '.$CI->lang->line((($months > 1) ? 'date_months' : 'date_month')).', ';
+ $str[] = $months.' '.$CI->lang->line((($months > 1) ? 'date_months' : 'date_month'));
}
$seconds -= $months * 2629743;
@@ -203,11 +210,11 @@ if ( ! function_exists('timespan'))
$weeks = floor($seconds / 604800);
- if ($years > 0 OR $months > 0 OR $weeks > 0)
+ if (count($str) < $units && ($years > 0 OR $months > 0 OR $weeks > 0))
{
if ($weeks > 0)
{
- $str .= $weeks.' '.$CI->lang->line((($weeks > 1) ? 'date_weeks' : 'date_week')).', ';
+ $str[] = $weeks.' '.$CI->lang->line((($weeks > 1) ? 'date_weeks' : 'date_week'));
}
$seconds -= $weeks * 604800;
@@ -215,11 +222,11 @@ if ( ! function_exists('timespan'))
$days = floor($seconds / 86400);
- if ($months > 0 OR $weeks > 0 OR $days > 0)
+ if (count($str) < $units && ($months > 0 OR $weeks > 0 OR $days > 0))
{
if ($days > 0)
{
- $str .= $days.' '.$CI->lang->line((($days > 1) ? 'date_days' : 'date_day')).', ';
+ $str[] = $days.' '.$CI->lang->line((($days > 1) ? 'date_days' : 'date_day'));
}
$seconds -= $days * 86400;
@@ -227,11 +234,11 @@ if ( ! function_exists('timespan'))
$hours = floor($seconds / 3600);
- if ($days > 0 OR $hours > 0)
+ if (count($str) < $units && ($days > 0 OR $hours > 0))
{
if ($hours > 0)
{
- $str .= $hours.' '.$CI->lang->line((($hours > 1) ? 'date_hours' : 'date_hour')).', ';
+ $str[] = $hours.' '.$CI->lang->line((($hours > 1) ? 'date_hours' : 'date_hour'));
}
$seconds -= $hours * 3600;
@@ -239,22 +246,22 @@ if ( ! function_exists('timespan'))
$minutes = floor($seconds / 60);
- if ($days > 0 OR $hours > 0 OR $minutes > 0)
+ if (count($str) < $units && ($days > 0 OR $hours > 0 OR $minutes > 0))
{
if ($minutes > 0)
{
- $str .= $minutes.' '.$CI->lang->line((($minutes > 1) ? 'date_minutes' : 'date_minute')).', ';
+ $str[] = $minutes.' '.$CI->lang->line((($minutes > 1) ? 'date_minutes' : 'date_minute'));
}
$seconds -= $minutes * 60;
}
- if ($str == '')
+ if (count($str) === 0)
{
- $str .= $seconds.' '.$CI->lang->line((($seconds > 1) ? 'date_seconds' : 'date_second')).', ';
+ $str[] = $seconds.' '.$CI->lang->line((($seconds > 1) ? 'date_seconds' : 'date_second'));
}
- return substr(trim($str), 0, -1);
+ return implode(', ', $str);
}
}
diff --git a/system/helpers/inflector_helper.php b/system/helpers/inflector_helper.php
index 9cf015d2b..485806b20 100644
--- a/system/helpers/inflector_helper.php
+++ b/system/helpers/inflector_helper.php
@@ -170,7 +170,7 @@ if ( ! function_exists('camelize'))
{
function camelize($str)
{
- return str_replace(' ', '', ucwords(preg_replace('/[\s_]+/', ' ', strtolower($str))));
+ return strtolower($str[0]).substr(str_replace(' ', '', ucwords(preg_replace('/[\s_]+/', ' ', $str))), 1);
}
}
diff --git a/system/helpers/path_helper.php b/system/helpers/path_helper.php
index 2eb85fefa..c31f0bdc5 100644
--- a/system/helpers/path_helper.php
+++ b/system/helpers/path_helper.php
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter Path Helpers
*
@@ -51,28 +49,24 @@ if ( ! function_exists('set_realpath'))
{
function set_realpath($path, $check_existance = FALSE)
{
- // Security check to make sure the path is NOT a URL. No remote file inclusion!
- if (preg_match("#^(http:\/\/|https:\/\/|www\.|ftp|[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})#i", $path))
+ // Security check to make sure the path is NOT a URL. No remote file inclusion!
+ if (preg_match('#^(http:\/\/|https:\/\/|www\.|ftp|[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})#i', $path))
{
show_error('The path you submitted must be a local server path, not a URL');
}
// Resolve the path
- if (function_exists('realpath') AND @realpath($path) !== FALSE)
+ if (function_exists('realpath') && @realpath($path) !== FALSE)
{
$path = realpath($path);
}
-
- // Add a trailing slash
- $path = rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR;
-
- // Make sure the path exists
- if ($check_existance == TRUE && ! is_dir($path))
+ elseif ($check_existance && ! is_dir($path) && ! is_file($path))
{
show_error('Not a valid path: '.$path);
}
- return $path;
+ // Add a trailing slash, if this is a directory
+ return is_dir($path) ? rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR : $path;
}
}
diff --git a/system/helpers/security_helper.php b/system/helpers/security_helper.php
index e05e947a5..8c7adea46 100644
--- a/system/helpers/security_helper.php
+++ b/system/helpers/security_helper.php
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter Security Helpers
*
@@ -42,7 +40,6 @@
/**
* XSS Filtering
*
- * @access public
* @param string
* @param bool whether or not the content is an image file
* @return string
@@ -61,7 +58,6 @@ if ( ! function_exists('xss_clean'))
/**
* Sanitize Filename
*
- * @access public
* @param string
* @return string
*/
@@ -79,7 +75,6 @@ if ( ! function_exists('sanitize_filename'))
/**
* Hash encode a string
*
- * @access public
* @param string
* @return string
*/
@@ -87,7 +82,12 @@ if ( ! function_exists('do_hash'))
{
function do_hash($str, $type = 'sha1')
{
- return ($type === 'sha1') ? sha1($str) : md5($str);
+ if ( ! in_array(strtolower($type), hash_algos()))
+ {
+ $type = 'md5';
+ }
+
+ return hash($type, $str);
}
}
@@ -96,7 +96,6 @@ if ( ! function_exists('do_hash'))
/**
* Strip Image Tags
*
- * @access public
* @param string
* @return string
*/
@@ -104,7 +103,7 @@ if ( ! function_exists('strip_image_tags'))
{
function strip_image_tags($str)
{
- return preg_replace(array("#<img\s+.*?src\s*=\s*[\"'](.+?)[\"'].*?\>#", "#<img\s+.*?src\s*=\s*(.+?).*?\>#"), "\\1", $str);
+ return preg_replace(array('#<img\s+.*?src\s*=\s*["\'](.+?)["\'].*?\>#', '#<img\s+.*?src\s*=\s*(.+?).*?\>#'), '\\1', $str);
}
}
@@ -113,7 +112,6 @@ if ( ! function_exists('strip_image_tags'))
/**
* Convert PHP tags to entities
*
- * @access public
* @param string
* @return string
*/
diff --git a/system/language/english/upload_lang.php b/system/language/english/upload_lang.php
index ec5de1e6b..4fa8394ec 100644
--- a/system/language/english/upload_lang.php
+++ b/system/language/english/upload_lang.php
@@ -35,7 +35,7 @@ $lang['upload_stopped_by_extension'] = "The file upload was stopped by extension
$lang['upload_no_file_selected'] = "You did not select a file to upload.";
$lang['upload_invalid_filetype'] = "The filetype you are attempting to upload is not allowed.";
$lang['upload_invalid_filesize'] = "The file you are attempting to upload is larger than the permitted size.";
-$lang['upload_invalid_dimensions'] = "The image you are attempting to upload exceedes the maximum height or width.";
+$lang['upload_invalid_dimensions'] = "The image you are attempting to upload exceeds the maximum height or width.";
$lang['upload_destination_error'] = "A problem was encountered while attempting to move the uploaded file to the final destination.";
$lang['upload_no_filepath'] = "The upload path does not appear to be valid.";
$lang['upload_no_file_types'] = "You have not specified any allowed file types.";
diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php
index 9491f354c..3e0c72e84 100644
--- a/system/libraries/Form_validation.php
+++ b/system/libraries/Form_validation.php
@@ -101,7 +101,7 @@ class CI_Form_validation {
return $this;
}
- // If an array was passed via the first parameter instead of indidual string
+ // If an array was passed via the first parameter instead of individual string
// values we cycle through it and recursively call this function.
if (is_array($field))
{
diff --git a/system/libraries/Session.php b/system/libraries/Session.php
index 0b9d45b2a..3a80c1626 100644
--- a/system/libraries/Session.php
+++ b/system/libraries/Session.php
@@ -48,6 +48,7 @@ class CI_Session {
public $cookie_path = '';
public $cookie_domain = '';
public $cookie_secure = FALSE;
+ public $cookie_httponly = FALSE;
public $sess_time_to_update = 300;
public $encryption_key = '';
public $flashdata_key = 'flash';
@@ -72,7 +73,7 @@ class CI_Session {
// Set all the session preferences, which can either be set
// manually via the $params array above or via the config file
- foreach (array('sess_encrypt_cookie', 'sess_use_database', 'sess_table_name', 'sess_expiration', 'sess_expire_on_close', 'sess_match_ip', 'sess_match_useragent', 'sess_cookie_name', 'cookie_path', 'cookie_domain', 'cookie_secure', 'sess_time_to_update', 'time_reference', 'cookie_prefix', 'encryption_key') as $key)
+ foreach (array('sess_encrypt_cookie', 'sess_use_database', 'sess_table_name', 'sess_expiration', 'sess_expire_on_close', 'sess_match_ip', 'sess_match_useragent', 'sess_cookie_name', 'cookie_path', 'cookie_domain', 'cookie_secure', 'cookie_httponly', 'sess_time_to_update', 'time_reference', 'cookie_prefix', 'encryption_key') as $key)
{
$this->$key = (isset($params[$key])) ? $params[$key] : $this->CI->config->item($key);
}
@@ -468,6 +469,29 @@ class CI_Session {
{
return $this->userdata;
}
+
+ // --------------------------------------------------------------------------
+
+ /**
+ * Fetch all flashdata
+ *
+ * @return array
+ */
+ public function all_flashdata()
+ {
+ $out = array();
+
+ // loop through all userdata
+ foreach ($this->all_userdata() as $key => $val)
+ {
+ // if it contains flashdata, add it
+ if (strpos($key, 'flash:old:') !== FALSE)
+ {
+ $out[$key] = $val;
+ }
+ }
+ return $out;
+ }
// --------------------------------------------------------------------
@@ -666,13 +690,14 @@ class CI_Session {
// Set the cookie
setcookie(
- $this->sess_cookie_name,
- $cookie_data,
- $expire,
- $this->cookie_path,
- $this->cookie_domain,
- $this->cookie_secure
- );
+ $this->sess_cookie_name,
+ $cookie_data,
+ $expire,
+ $this->cookie_path,
+ $this->cookie_domain,
+ $this->cookie_secure,
+ $this->cookie_httponly
+ );
}
// --------------------------------------------------------------------
diff --git a/system/libraries/Table.php b/system/libraries/Table.php
index 99d001ce5..11a4858a9 100644
--- a/system/libraries/Table.php
+++ b/system/libraries/Table.php
@@ -112,7 +112,7 @@ class CI_Table {
*/
public function make_columns($array = array(), $col_limit = 0)
{
- if ( ! is_array($array) OR count($array) === 0)
+ if ( ! is_array($array) OR count($array) === 0 OR ! is_int($col_limit))
{
return FALSE;
}
@@ -405,7 +405,7 @@ class CI_Table {
// First generate the headings from the table column names
if (count($this->heading) === 0)
{
- if ( ! method_exists($query, 'list_fields'))
+ if ( ! is_callable(array($query, 'list_fields')))
{
return FALSE;
}