summaryrefslogtreecommitdiffstats
path: root/system
diff options
context:
space:
mode:
Diffstat (limited to 'system')
-rwxr-xr-xsystem/core/Benchmark.php2
-rwxr-xr-xsystem/core/CodeIgniter.php2
-rw-r--r--system/core/Common.php2
-rwxr-xr-xsystem/core/Config.php2
-rw-r--r--system/core/Controller.php2
-rwxr-xr-xsystem/core/Exceptions.php2
-rwxr-xr-xsystem/core/Hooks.php2
-rwxr-xr-xsystem/core/Input.php50
-rwxr-xr-xsystem/core/Lang.php2
-rw-r--r--system/core/Loader.php15
-rwxr-xr-xsystem/core/Model.php2
-rwxr-xr-xsystem/core/Output.php2
-rwxr-xr-xsystem/core/Router.php2
-rwxr-xr-xsystem/core/Security.php45
-rwxr-xr-xsystem/core/URI.php6
-rw-r--r--system/core/Utf8.php2
-rwxr-xr-xsystem/database/DB.php2
-rw-r--r--system/database/DB_active_rec.php66
-rw-r--r--system/database/DB_cache.php2
-rw-r--r--system/database/DB_driver.php387
-rw-r--r--system/database/DB_forge.php2
-rw-r--r--system/database/DB_result.php8
-rw-r--r--system/database/DB_utility.php2
-rw-r--r--system/database/drivers/cubrid/cubrid_driver.php46
-rw-r--r--system/database/drivers/cubrid/cubrid_forge.php32
-rw-r--r--system/database/drivers/cubrid/cubrid_result.php2
-rw-r--r--system/database/drivers/cubrid/cubrid_utility.php2
-rw-r--r--system/database/drivers/interbase/index.html10
-rw-r--r--system/database/drivers/interbase/interbase_driver.php626
-rw-r--r--system/database/drivers/interbase/interbase_forge.php243
-rw-r--r--system/database/drivers/interbase/interbase_result.php294
-rw-r--r--system/database/drivers/interbase/interbase_utility.php115
-rw-r--r--system/database/drivers/mssql/mssql_driver.php38
-rw-r--r--system/database/drivers/mssql/mssql_forge.php19
-rw-r--r--system/database/drivers/mssql/mssql_result.php2
-rw-r--r--system/database/drivers/mssql/mssql_utility.php2
-rw-r--r--system/database/drivers/mysql/mysql_driver.php80
-rw-r--r--system/database/drivers/mysql/mysql_forge.php10
-rw-r--r--system/database/drivers/mysql/mysql_result.php20
-rw-r--r--system/database/drivers/mysql/mysql_utility.php2
-rw-r--r--system/database/drivers/mysqli/mysqli_driver.php84
-rw-r--r--system/database/drivers/mysqli/mysqli_forge.php33
-rw-r--r--system/database/drivers/mysqli/mysqli_result.php21
-rw-r--r--system/database/drivers/mysqli/mysqli_utility.php2
-rw-r--r--system/database/drivers/oci8/oci8_driver.php51
-rw-r--r--system/database/drivers/oci8/oci8_forge.php74
-rw-r--r--system/database/drivers/oci8/oci8_result.php17
-rw-r--r--system/database/drivers/oci8/oci8_utility.php2
-rw-r--r--system/database/drivers/odbc/odbc_driver.php47
-rw-r--r--system/database/drivers/odbc/odbc_forge.php20
-rw-r--r--system/database/drivers/odbc/odbc_result.php73
-rw-r--r--system/database/drivers/odbc/odbc_utility.php2
-rw-r--r--system/database/drivers/pdo/pdo_driver.php53
-rw-r--r--system/database/drivers/pdo/pdo_forge.php19
-rw-r--r--system/database/drivers/pdo/pdo_result.php2
-rw-r--r--system/database/drivers/pdo/pdo_utility.php2
-rw-r--r--system/database/drivers/postgre/postgre_driver.php116
-rw-r--r--system/database/drivers/postgre/postgre_forge.php23
-rw-r--r--system/database/drivers/postgre/postgre_result.php2
-rw-r--r--system/database/drivers/postgre/postgre_utility.php37
-rw-r--r--system/database/drivers/sqlite/sqlite_driver.php39
-rw-r--r--system/database/drivers/sqlite/sqlite_forge.php22
-rw-r--r--system/database/drivers/sqlite/sqlite_result.php2
-rw-r--r--system/database/drivers/sqlite/sqlite_utility.php43
-rw-r--r--system/database/drivers/sqlsrv/sqlsrv_driver.php73
-rw-r--r--system/database/drivers/sqlsrv/sqlsrv_forge.php21
-rw-r--r--system/database/drivers/sqlsrv/sqlsrv_result.php2
-rw-r--r--system/database/drivers/sqlsrv/sqlsrv_utility.php2
-rw-r--r--system/helpers/array_helper.php49
-rw-r--r--system/helpers/captcha_helper.php15
-rw-r--r--system/helpers/cookie_helper.php26
-rw-r--r--system/helpers/date_helper.php2
-rw-r--r--system/helpers/directory_helper.php20
-rw-r--r--system/helpers/download_helper.php30
-rw-r--r--system/helpers/email_helper.php2
-rw-r--r--system/helpers/file_helper.php2
-rw-r--r--system/helpers/form_helper.php29
-rw-r--r--system/helpers/html_helper.php2
-rw-r--r--system/helpers/inflector_helper.php15
-rw-r--r--system/helpers/language_helper.php2
-rw-r--r--system/helpers/number_helper.php2
-rw-r--r--system/helpers/path_helper.php2
-rw-r--r--system/helpers/security_helper.php2
-rw-r--r--system/helpers/smiley_helper.php2
-rw-r--r--system/helpers/string_helper.php2
-rw-r--r--system/helpers/text_helper.php2
-rw-r--r--system/helpers/typography_helper.php2
-rw-r--r--system/helpers/url_helper.php36
-rw-r--r--system/helpers/xml_helper.php2
-rw-r--r--system/language/english/calendar_lang.php2
-rw-r--r--system/language/english/date_lang.php2
-rw-r--r--system/language/english/db_lang.php2
-rw-r--r--system/language/english/email_lang.php2
-rw-r--r--system/language/english/form_validation_lang.php52
-rw-r--r--system/language/english/ftp_lang.php2
-rw-r--r--system/language/english/imglib_lang.php2
-rw-r--r--system/language/english/migration_lang.php2
-rw-r--r--system/language/english/number_lang.php2
-rw-r--r--system/language/english/profiler_lang.php2
-rw-r--r--system/language/english/unit_test_lang.php2
-rw-r--r--system/language/english/upload_lang.php2
-rw-r--r--system/libraries/Cache/Cache.php23
-rw-r--r--system/libraries/Cache/drivers/Cache_apc.php2
-rw-r--r--system/libraries/Cache/drivers/Cache_dummy.php2
-rw-r--r--system/libraries/Cache/drivers/Cache_file.php2
-rw-r--r--system/libraries/Cache/drivers/Cache_memcached.php2
-rw-r--r--system/libraries/Cache/drivers/Cache_wincache.php165
-rw-r--r--system/libraries/Calendar.php2
-rw-r--r--system/libraries/Cart.php2
-rw-r--r--system/libraries/Driver.php2
-rw-r--r--system/libraries/Email.php9
-rw-r--r--system/libraries/Encrypt.php2
-rw-r--r--system/libraries/Form_validation.php141
-rw-r--r--system/libraries/Ftp.php2
-rw-r--r--system/libraries/Image_lib.php2
-rw-r--r--system/libraries/Javascript.php2
-rw-r--r--system/libraries/Log.php2
-rw-r--r--system/libraries/Migration.php2
-rw-r--r--system/libraries/Pagination.php2
-rw-r--r--system/libraries/Parser.php2
-rw-r--r--system/libraries/Profiler.php14
-rw-r--r--system/libraries/Session.php14
-rw-r--r--system/libraries/Table.php20
-rw-r--r--system/libraries/Trackback.php4
-rw-r--r--system/libraries/Typography.php2
-rw-r--r--system/libraries/Unit_test.php2
-rw-r--r--system/libraries/Upload.php4
-rw-r--r--system/libraries/User_agent.php2
-rw-r--r--system/libraries/Xmlrpc.php2
-rw-r--r--system/libraries/Xmlrpcs.php2
-rw-r--r--system/libraries/Zip.php2
-rw-r--r--system/libraries/javascript/Jquery.php2
132 files changed, 2603 insertions, 1191 deletions
diff --git a/system/core/Benchmark.php b/system/core/Benchmark.php
index f4dfd3dab..f6b634deb 100755
--- a/system/core/Benchmark.php
+++ b/system/core/Benchmark.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php
index 7af3c485d..a79a69590 100755
--- a/system/core/CodeIgniter.php
+++ b/system/core/CodeIgniter.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/core/Common.php b/system/core/Common.php
index 491979350..f20acafd4 100644
--- a/system/core/Common.php
+++ b/system/core/Common.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/core/Config.php b/system/core/Config.php
index 68417435d..1e149d005 100755
--- a/system/core/Config.php
+++ b/system/core/Config.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/core/Controller.php b/system/core/Controller.php
index 0dc131701..05e1bf5bf 100644
--- a/system/core/Controller.php
+++ b/system/core/Controller.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/core/Exceptions.php b/system/core/Exceptions.php
index bf9901252..d7282b1f3 100755
--- a/system/core/Exceptions.php
+++ b/system/core/Exceptions.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/core/Hooks.php b/system/core/Hooks.php
index e1ac58e6e..493822f36 100755
--- a/system/core/Hooks.php
+++ b/system/core/Hooks.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/core/Input.php b/system/core/Input.php
index ee15f4013..901b4147e 100755
--- a/system/core/Input.php
+++ b/system/core/Input.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
@@ -366,36 +366,7 @@ class CI_Input {
*/
public function valid_ip($ip)
{
- // if php version >= 5.2, use filter_var to check validate ip.
- if (function_exists('filter_var'))
- {
- return (bool) filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4);
- }
-
- $ip_segments = explode('.', $ip);
-
- // Always 4 segments needed
- if (count($ip_segments) !== 4)
- {
- return FALSE;
- }
- // IP can not start with 0
- if ($ip_segments[0][0] == '0')
- {
- return FALSE;
- }
- // Check each segment
- foreach ($ip_segments as $segment)
- {
- // IP segments must be digits and can not be
- // longer than 3 digits or greater then 255
- if ($segment == '' OR preg_match('/[^0-9]/', $segment) OR $segment > 255 OR strlen($segment) > 3)
- {
- return FALSE;
- }
- }
-
- return TRUE;
+ return (bool) filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4);
}
// --------------------------------------------------------------------
@@ -699,6 +670,23 @@ class CI_Input {
return (php_sapi_name() === 'cli' OR defined('STDIN'));
}
+ // --------------------------------------------------------------------
+
+ /**
+ * Get Request Method
+ *
+ * Return the Request Method
+ *
+ * @param bool uppercase or lowercase
+ * @return bool
+ */
+ public function method($upper = FALSE)
+ {
+ return ($upper)
+ ? strtoupper($this->server('REQUEST_METHOD'))
+ : strtolower($this->server('REQUEST_METHOD'));
+ }
+
}
/* End of file Input.php */
diff --git a/system/core/Lang.php b/system/core/Lang.php
index c40a6856e..9ef76f4d6 100755
--- a/system/core/Lang.php
+++ b/system/core/Lang.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/core/Loader.php b/system/core/Loader.php
index 12daaa928..9b9cc2fef 100644
--- a/system/core/Loader.php
+++ b/system/core/Loader.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
@@ -615,13 +615,22 @@ class CI_Loader {
*
* Loads a driver library
*
- * @param string the name of the class
+ * @param mixed the name of the class or array of classes
* @param mixed the optional parameters
* @param string an optional object name
* @return void
*/
public function driver($library = '', $params = NULL, $object_name = NULL)
{
+ if (is_array($library))
+ {
+ foreach ($library as $driver)
+ {
+ $this->driver($driver);
+ }
+ return FALSE;
+ }
+
if ( ! class_exists('CI_Driver_Library'))
{
// we aren't instantiating an object here, that'll be done by the Library itself
@@ -833,7 +842,7 @@ class CI_Loader {
// If the PHP installation does not support short tags we'll
// do a little string replacement, changing the short tags
// to standard PHP echo statements.
- if ((bool) @ini_get('short_open_tag') === FALSE AND config_item('rewrite_short_tags') == TRUE)
+ if ( ! is_php('5.4') && (bool) @ini_get('short_open_tag') === FALSE && config_item('rewrite_short_tags') == TRUE)
{
echo eval('?>'.preg_replace('/;*\s*\?>/', '; ?>', str_replace('<?=', '<?php echo ', file_get_contents($_ci_path))));
}
diff --git a/system/core/Model.php b/system/core/Model.php
index a595a6ae2..49b8d34e4 100755
--- a/system/core/Model.php
+++ b/system/core/Model.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/core/Output.php b/system/core/Output.php
index abd8a0ea9..faebbbe72 100755
--- a/system/core/Output.php
+++ b/system/core/Output.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/core/Router.php b/system/core/Router.php
index d21319565..b251abb4b 100755
--- a/system/core/Router.php
+++ b/system/core/Router.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/core/Security.php b/system/core/Security.php
index 1007f61f4..cd8a61028 100755
--- a/system/core/Security.php
+++ b/system/core/Security.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* Security Class
*
@@ -106,23 +104,27 @@ class CI_Security {
public function __construct()
{
- // CSRF config
- foreach(array('csrf_expire', 'csrf_token_name', 'csrf_cookie_name') as $key)
+ // Is CSRF protection enabled?
+ if (config_item('csrf_protection') === TRUE)
{
- if (FALSE !== ($val = config_item($key)))
+ // CSRF config
+ foreach (array('csrf_expire', 'csrf_token_name', 'csrf_cookie_name') as $key)
{
- $this->{'_'.$key} = $val;
+ if (FALSE !== ($val = config_item($key)))
+ {
+ $this->{'_'.$key} = $val;
+ }
}
- }
- // Append application specific cookie prefix
- if (config_item('cookie_prefix'))
- {
- $this->_csrf_cookie_name = config_item('cookie_prefix').$this->_csrf_cookie_name;
- }
+ // Append application specific cookie prefix
+ if (config_item('cookie_prefix'))
+ {
+ $this->_csrf_cookie_name = config_item('cookie_prefix').$this->_csrf_cookie_name;
+ }
- // Set the CSRF hash
- $this->_csrf_set_hash();
+ // Set the CSRF hash
+ $this->_csrf_set_hash();
+ }
log_message('debug', 'Security Class Initialized');
}
@@ -136,8 +138,8 @@ class CI_Security {
*/
public function csrf_verify()
{
- // If no POST data exists we will set the CSRF cookie
- if (count($_POST) === 0)
+ // If it's not a POST request we will set the CSRF cookie
+ if (strtoupper($_SERVER['REQUEST_METHOD']) !== 'POST')
{
return $this->csrf_set_cookie();
}
@@ -189,7 +191,7 @@ class CI_Security {
$expire = time() + $this->_csrf_expire;
$secure_cookie = (bool) config_item('cookie_secure');
- if ($secure_cookie && ( ! isset($_SERVER['HTTPS']) OR $_SERVER['HTTPS'] == 'off' OR ! $_SERVER['HTTPS']))
+ if ($secure_cookie && (empty($_SERVER['HTTPS']) OR strtolower($_SERVER['HTTPS']) === 'off'))
{
return FALSE;
}
@@ -358,7 +360,7 @@ class CI_Security {
foreach ($words as $word)
{
- $word = implode("\s*", str_split($word)) . "\s*";
+ $word = implode('\s*', str_split($word)).'\s*';
// We only want to do this when it is followed by a non-word character
// That way valid stuff like "dealer to" does not become "dealerto"
@@ -425,7 +427,6 @@ class CI_Security {
'\\1\\2&#40;\\3&#41;',
$str);
-
// Final clean up
// This adds a bit of extra precaution in case
// something got through the above filters
@@ -601,7 +602,7 @@ class CI_Security {
}
// find occurrences of illegal attribute strings with quotes (042 and 047 are octal quotes)
- preg_match_all('/('.implode('|', $evil_attributes).')\s*=\s*(\042|\047)([^\\2]*?)(\\2)/is', $str, $matches, PREG_SET_ORDER);
+ preg_match_all('/('.implode('|', $evil_attributes).')\s*=\s*(\042|\047)([^\\2]*?)(\\2)/is', $str, $matches, PREG_SET_ORDER);
foreach ($matches as $attr)
{
@@ -633,7 +634,7 @@ class CI_Security {
{
return '&lt;'.$matches[1].$matches[2].$matches[3] // encode opening brace
// encode captured opening or closing brace to prevent recursive vectors:
- . str_replace(array('>', '<'), array('&gt;', '&lt;'), $matches[4]);
+ .str_replace(array('>', '<'), array('&gt;', '&lt;'), $matches[4]);
}
// --------------------------------------------------------------------
diff --git a/system/core/URI.php b/system/core/URI.php
index b28ee198b..4a2e87c2a 100755
--- a/system/core/URI.php
+++ b/system/core/URI.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
@@ -444,9 +444,7 @@ class CI_URI {
return array();
}
- return function_exists('array_fill_keys')
- ? array_fill_keys($default, FALSE)
- : array_combine($default, array_fill(0, count($default), FALSE));
+ return array_fill_keys($default, FALSE);
}
$segments = array_slice($this->$segment_array(), ($n - 1));
diff --git a/system/core/Utf8.php b/system/core/Utf8.php
index 0e180d36f..ba3567453 100644
--- a/system/core/Utf8.php
+++ b/system/core/Utf8.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/database/DB.php b/system/database/DB.php
index d06ffb40e..116116bf4 100755
--- a/system/database/DB.php
+++ b/system/database/DB.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/database/DB_active_rec.php b/system/database/DB_active_rec.php
index eaae23f30..756709698 100644
--- a/system/database/DB_active_rec.php
+++ b/system/database/DB_active_rec.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
@@ -212,7 +212,7 @@ class CI_DB_active_record extends CI_DB_driver {
$alias = $this->_create_alias_from_table(trim($select));
}
- $sql = $this->_protect_identifiers($type.'('.trim($select).')').' AS '.$this->_protect_identifiers(trim($alias));
+ $sql = $this->protect_identifiers($type.'('.trim($select).')').' AS '.$this->protect_identifiers(trim($alias));
$this->ar_select[] = $sql;
if ($this->ar_caching === TRUE)
@@ -279,7 +279,7 @@ class CI_DB_active_record extends CI_DB_driver {
{
$v = trim($v);
$this->_track_aliases($v);
- $v = $this->ar_from[] = $this->_protect_identifiers($v, TRUE, NULL, FALSE);
+ $v = $this->ar_from[] = $this->protect_identifiers($v, TRUE, NULL, FALSE);
if ($this->ar_caching === TRUE)
{
@@ -295,7 +295,7 @@ class CI_DB_active_record extends CI_DB_driver {
// Extract any aliases that might exist. We use this information
// in the _protect_identifiers to know whether to add a table prefix
$this->_track_aliases($val);
- $this->ar_from[] = $val = $this->_protect_identifiers($val, TRUE, NULL, FALSE);
+ $this->ar_from[] = $val = $this->protect_identifiers($val, TRUE, NULL, FALSE);
if ($this->ar_caching === TRUE)
{
@@ -341,13 +341,13 @@ class CI_DB_active_record extends CI_DB_driver {
$this->_track_aliases($table);
// Strip apart the condition and protect the identifiers
- if (preg_match('/([\w\.]+)([\W\s]+)(.+)/', $cond, $match))
+ if (preg_match('/([\[\w\.]+)([\W\s]+)(.+)/', $cond, $match))
{
- $cond = $this->_protect_identifiers($match[1]).$match[2].$this->_protect_identifiers($match[3]);
+ $cond = $this->protect_identifiers($match[1]).$match[2].$this->protect_identifiers($match[3]);
}
// Assemble the JOIN statement
- $this->ar_join[] = $join = $type.'JOIN '.$this->_protect_identifiers($table, TRUE, NULL, FALSE).' ON '.$cond;
+ $this->ar_join[] = $join = $type.'JOIN '.$this->protect_identifiers($table, TRUE, NULL, FALSE).' ON '.$cond;
if ($this->ar_caching === TRUE)
{
@@ -433,7 +433,7 @@ class CI_DB_active_record extends CI_DB_driver {
{
if ($escape === TRUE)
{
- $k = $this->_protect_identifiers($k, FALSE, $escape);
+ $k = $this->protect_identifiers($k, FALSE, $escape);
$v = ' '.$this->escape($v);
}
@@ -444,7 +444,7 @@ class CI_DB_active_record extends CI_DB_driver {
}
else
{
- $k = $this->_protect_identifiers($k, FALSE, $escape);
+ $k = $this->protect_identifiers($k, FALSE, $escape);
}
$this->ar_where[] = $prefix.$k.$v;
@@ -562,7 +562,7 @@ class CI_DB_active_record extends CI_DB_driver {
}
$prefix = (count($this->ar_where) === 0) ? '' : $type;
- $this->ar_where[] = $where_in = $prefix.$this->_protect_identifiers($key).$not.' IN ('.implode(', ', $this->ar_wherein).') ';
+ $this->ar_where[] = $where_in = $prefix.$this->protect_identifiers($key).$not.' IN ('.implode(', ', $this->ar_wherein).') ';
if ($this->ar_caching === TRUE)
{
@@ -666,7 +666,7 @@ class CI_DB_active_record extends CI_DB_driver {
foreach ($field as $k => $v)
{
- $k = $this->_protect_identifiers($k);
+ $k = $this->protect_identifiers($k);
$prefix = (count($this->ar_like) === 0) ? '' : $type;
$v = $this->escape_like_str($v);
@@ -827,7 +827,7 @@ class CI_DB_active_record extends CI_DB_driver {
if ($val != '')
{
- $this->ar_groupby[] = $val = $this->_protect_identifiers($val);
+ $this->ar_groupby[] = $val = $this->protect_identifiers($val);
if ($this->ar_caching === TRUE)
{
@@ -896,7 +896,7 @@ class CI_DB_active_record extends CI_DB_driver {
if ($escape === TRUE)
{
- $k = $this->_protect_identifiers($k);
+ $k = $this->protect_identifiers($k);
}
if ( ! $this->_has_operator($k))
@@ -951,7 +951,7 @@ class CI_DB_active_record extends CI_DB_driver {
$part = trim($part);
if ( ! in_array($part, $this->ar_aliased_tables))
{
- $part = $this->_protect_identifiers(trim($part));
+ $part = $this->protect_identifiers(trim($part));
}
$temp[] = $part;
@@ -963,7 +963,7 @@ class CI_DB_active_record extends CI_DB_driver {
{
if ($escape === TRUE)
{
- $orderby = $this->_protect_identifiers($orderby);
+ $orderby = $this->protect_identifiers($orderby);
}
}
@@ -1036,11 +1036,11 @@ class CI_DB_active_record extends CI_DB_driver {
{
if ($escape === FALSE)
{
- $this->ar_set[$this->_protect_identifiers($k)] = $v;
+ $this->ar_set[$this->protect_identifiers($k)] = $v;
}
else
{
- $this->ar_set[$this->_protect_identifiers($k, FALSE, TRUE)] = $this->escape($v);
+ $this->ar_set[$this->protect_identifiers($k, FALSE, TRUE)] = $this->escape($v);
}
}
@@ -1125,7 +1125,7 @@ class CI_DB_active_record extends CI_DB_driver {
$this->from($table);
}
- $result = $this->query($this->_compile_select($this->_count_string.$this->_protect_identifiers('numrows')));
+ $result = $this->query($this->_compile_select($this->_count_string.$this->protect_identifiers('numrows')));
$this->_reset_select();
if ($result->num_rows() === 0)
@@ -1211,7 +1211,7 @@ class CI_DB_active_record extends CI_DB_driver {
// Batch this baby
for ($i = 0, $total = count($this->ar_set); $i < $total; $i += 100)
{
- $this->query($this->_insert_batch($this->_protect_identifiers($table, TRUE, NULL, FALSE), $this->ar_keys, array_slice($this->ar_set, $i, 100)));
+ $this->query($this->_insert_batch($this->protect_identifiers($table, TRUE, NULL, FALSE), $this->ar_keys, array_slice($this->ar_set, $i, 100)));
}
$this->_reset_write();
@@ -1269,7 +1269,7 @@ class CI_DB_active_record extends CI_DB_driver {
foreach ($keys as $k)
{
- $this->ar_keys[] = $this->_protect_identifiers($k);
+ $this->ar_keys[] = $this->protect_identifiers($k);
}
return $this;
@@ -1295,9 +1295,7 @@ class CI_DB_active_record extends CI_DB_driver {
}
$sql = $this->_insert(
- $this->_protect_identifiers(
- $this->ar_from[0], TRUE, NULL, FALSE
- ),
+ $this->protect_identifiers($this->ar_from[0], TRUE, NULL, FALSE),
array_keys($this->ar_set),
array_values($this->ar_set)
);
@@ -1335,9 +1333,7 @@ class CI_DB_active_record extends CI_DB_driver {
}
$sql = $this->_insert(
- $this->_protect_identifiers(
- $this->ar_from[0], TRUE, NULL, FALSE
- ),
+ $this->protect_identifiers($this->ar_from[0], TRUE, NULL, FALSE),
array_keys($this->ar_set),
array_values($this->ar_set)
);
@@ -1414,7 +1410,7 @@ class CI_DB_active_record extends CI_DB_driver {
$table = $this->ar_from[0];
}
- $sql = $this->_replace($this->_protect_identifiers($table, TRUE, NULL, FALSE), array_keys($this->ar_set), array_values($this->ar_set));
+ $sql = $this->_replace($this->protect_identifiers($table, TRUE, NULL, FALSE), array_keys($this->ar_set), array_values($this->ar_set));
$this->_reset_write();
return $this->query($sql);
}
@@ -1441,7 +1437,7 @@ class CI_DB_active_record extends CI_DB_driver {
return FALSE;
}
- $sql = $this->_update($this->_protect_identifiers($this->ar_from[0], TRUE, NULL, FALSE), $this->ar_set, $this->ar_where, $this->ar_orderby, $this->ar_limit);
+ $sql = $this->_update($this->protect_identifiers($this->ar_from[0], TRUE, NULL, FALSE), $this->ar_set, $this->ar_where, $this->ar_orderby, $this->ar_limit);
if ($reset === TRUE)
{
@@ -1488,7 +1484,7 @@ class CI_DB_active_record extends CI_DB_driver {
$this->limit($limit);
}
- $sql = $this->_update($this->_protect_identifiers($this->ar_from[0], TRUE, NULL, FALSE), $this->ar_set, $this->ar_where, $this->ar_orderby, $this->ar_limit, $this->ar_like);
+ $sql = $this->_update($this->protect_identifiers($this->ar_from[0], TRUE, NULL, FALSE), $this->ar_set, $this->ar_where, $this->ar_orderby, $this->ar_limit, $this->ar_like);
$this->_reset_write();
return $this->query($sql);
}
@@ -1573,7 +1569,7 @@ class CI_DB_active_record extends CI_DB_driver {
// Batch this baby
for ($i = 0, $total = count($this->ar_set); $i < $total; $i += 100)
{
- $this->query($this->_update_batch($this->_protect_identifiers($table, TRUE, NULL, FALSE), array_slice($this->ar_set, $i, 100), $this->_protect_identifiers($index), $this->ar_where));
+ $this->query($this->_update_batch($this->protect_identifiers($table, TRUE, NULL, FALSE), array_slice($this->ar_set, $i, 100), $this->protect_identifiers($index), $this->ar_where));
}
$this->_reset_write();
@@ -1614,7 +1610,7 @@ class CI_DB_active_record extends CI_DB_driver {
$not[] = $k.'-'.$v;
}
- $clean[$this->_protect_identifiers($k2)] = ($escape === FALSE) ? $v2 : $this->escape($v2);
+ $clean[$this->protect_identifiers($k2)] = ($escape === FALSE) ? $v2 : $this->escape($v2);
}
if ($index_set == FALSE)
@@ -1651,7 +1647,7 @@ class CI_DB_active_record extends CI_DB_driver {
}
else
{
- $table = $this->_protect_identifiers($table, TRUE, NULL, FALSE);
+ $table = $this->protect_identifiers($table, TRUE, NULL, FALSE);
}
$sql = $this->_delete($table);
@@ -1684,7 +1680,7 @@ class CI_DB_active_record extends CI_DB_driver {
}
else
{
- $table = $this->_protect_identifiers($table, TRUE, NULL, FALSE);
+ $table = $this->protect_identifiers($table, TRUE, NULL, FALSE);
}
$sql = $this->_truncate($table);
@@ -1751,7 +1747,7 @@ class CI_DB_active_record extends CI_DB_driver {
}
else
{
- $table = $this->_protect_identifiers($table, TRUE, NULL, FALSE);
+ $table = $this->protect_identifiers($table, TRUE, NULL, FALSE);
}
if ($where != '')
@@ -1894,7 +1890,7 @@ class CI_DB_active_record extends CI_DB_driver {
foreach ($this->ar_select as $key => $val)
{
$no_escape = isset($this->ar_no_escape[$key]) ? $this->ar_no_escape[$key] : NULL;
- $this->ar_select[$key] = $this->_protect_identifiers($val, FALSE, $no_escape);
+ $this->ar_select[$key] = $this->protect_identifiers($val, FALSE, $no_escape);
}
$sql .= implode(', ', $this->ar_select);
diff --git a/system/database/DB_cache.php b/system/database/DB_cache.php
index 79651fcb0..fb0cfa89a 100644
--- a/system/database/DB_cache.php
+++ b/system/database/DB_cache.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php
index 5f435e363..bcff43392 100644
--- a/system/database/DB_driver.php
+++ b/system/database/DB_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.1.6 or newer
+ * 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
*/
-// ------------------------------------------------------------------------
-
/**
* Database Driver Class
*
@@ -42,54 +40,44 @@
*/
class CI_DB_driver {
- var $username;
- var $password;
- var $hostname;
- var $database;
- var $dbdriver = 'mysql';
- var $dbprefix = '';
- var $char_set = 'utf8';
- var $dbcollat = 'utf8_general_ci';
- var $autoinit = TRUE; // Whether to automatically initialize the DB
- var $swap_pre = '';
- var $port = '';
- var $pconnect = FALSE;
- var $conn_id = FALSE;
- var $result_id = FALSE;
- var $db_debug = FALSE;
- var $benchmark = 0;
- var $query_count = 0;
- var $bind_marker = '?';
- var $save_queries = TRUE;
- var $queries = array();
- var $query_times = array();
- var $data_cache = array();
- var $trans_enabled = TRUE;
- var $trans_strict = TRUE;
- var $_trans_depth = 0;
- var $_trans_status = TRUE; // Used with transactions to determine if a rollback should occur
- var $cache_on = FALSE;
- var $cachedir = '';
- var $cache_autodel = FALSE;
- var $CACHE; // The cache class object
-
- // Private variables
- var $_protect_identifiers = TRUE;
- var $_reserved_identifiers = array('*'); // Identifiers that should NOT be escaped
-
- // These are use with Oracle
- var $stmt_id;
- var $curs_id;
- var $limit_used;
-
-
- /**
- * Constructor. Accepts one parameter containing the database
- * connection settings.
- *
- * @param array
- */
- function __construct($params)
+ public $dsn;
+ public $username;
+ public $password;
+ public $hostname;
+ public $database;
+ public $dbdriver = 'mysql';
+ public $dbprefix = '';
+ public $char_set = 'utf8';
+ public $dbcollat = 'utf8_general_ci';
+ public $autoinit = TRUE; // Whether to automatically initialize the DB
+ public $swap_pre = '';
+ public $port = '';
+ public $pconnect = FALSE;
+ public $conn_id = FALSE;
+ public $result_id = FALSE;
+ public $db_debug = FALSE;
+ public $benchmark = 0;
+ public $query_count = 0;
+ public $bind_marker = '?';
+ public $save_queries = TRUE;
+ public $queries = array();
+ public $query_times = array();
+ public $data_cache = array();
+
+ public $trans_enabled = TRUE;
+ public $trans_strict = TRUE;
+ protected $_trans_depth = 0;
+ protected $_trans_status = TRUE; // Used with transactions to determine if a rollback should occur
+
+ public $cache_on = FALSE;
+ public $cachedir = '';
+ public $cache_autodel = FALSE;
+ public $CACHE; // The cache class object
+
+ protected $_protect_identifiers = TRUE;
+ protected $_reserved_identifiers = array('*'); // Identifiers that should NOT be escaped
+
+ public function __construct($params)
{
if (is_array($params))
{
@@ -177,7 +165,7 @@ class CI_DB_driver {
}
// Now we set the character set and that's all
- return $this->db_set_charset($this->char_set, $this->dbcollat);
+ return $this->db_set_charset($this->char_set);
}
// --------------------------------------------------------------------
@@ -189,9 +177,9 @@ class CI_DB_driver {
* @param string
* @return bool
*/
- public function db_set_charset($charset, $collation = '')
+ public function db_set_charset($charset)
{
- if (method_exists($this, '_db_set_charset') && ! $this->_db_set_charset($charset, $collation))
+ if (method_exists($this, '_db_set_charset') && ! $this->_db_set_charset($charset))
{
log_message('error', 'Unable to set database connection charset: '.$charset);
@@ -211,10 +199,9 @@ class CI_DB_driver {
/**
* The name of the platform in use (mysql, mssql, etc...)
*
- * @access public
* @return string
*/
- function platform()
+ public function platform()
{
return $this->dbdriver;
}
@@ -222,36 +209,40 @@ class CI_DB_driver {
// --------------------------------------------------------------------
/**
- * Database Version Number. Returns a string containing the
- * version of the database being used
+ * Database version number
+ *
+ * Returns a string containing the version of the database being used.
+ * Most drivers will override this method.
*
- * @access public
* @return string
*/
- function version()
+ public function version()
{
- if (FALSE === ($sql = $this->_version()))
+ if (isset($this->data_cache['version']))
{
- if ($this->db_debug)
- {
- return $this->display_error('db_unsupported_function');
- }
- return FALSE;
+ return $this->data_cache['version'];
}
- // Some DBs have functions that return the version, and don't run special
- // SQL queries per se. In these instances, just return the result.
- $driver_version_exceptions = array('oci8', 'sqlite', 'cubrid', 'pdo', 'mysqli');
-
- if (in_array($this->dbdriver, $driver_version_exceptions))
- {
- return $sql;
- }
- else
+ if (FALSE === ($sql = $this->_version()))
{
- $query = $this->query($sql);
- return $query->row('ver');
+ return ($this->db_debug) ? $this->display_error('db_unsupported_function') : FALSE;
}
+
+ $query = $this->query($sql);
+ $query = $query->row();
+ return $this->data_cache['version'] = $query->ver;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Version number query string
+ *
+ * @return string
+ */
+ protected function _version()
+ {
+ return 'SELECT VERSION() AS ver';
}
// --------------------------------------------------------------------
@@ -260,17 +251,16 @@ class CI_DB_driver {
* Execute the query
*
* Accepts an SQL string as input and returns a result object upon
- * successful execution of a "read" type query. Returns boolean TRUE
+ * successful execution of a "read" type query. Returns boolean TRUE
* upon successful execution of a "write" type query. Returns boolean
* FALSE upon failure, and if the $db_debug variable is set to TRUE
* will raise an error.
*
- * @access public
* @param string An SQL query string
* @param array An array of binding data
* @return mixed
*/
- function query($sql, $binds = FALSE, $return_object = TRUE)
+ public function query($sql, $binds = FALSE, $return_object = TRUE)
{
if ($sql == '')
{
@@ -289,7 +279,13 @@ class CI_DB_driver {
$sql = preg_replace("/(\W)".$this->swap_pre."(\S+?)/", "\\1".$this->dbprefix."\\2", $sql);
}
- // Is query caching enabled? If the query is a "read type"
+ // Compile binds if needed
+ if ($binds !== FALSE)
+ {
+ $sql = $this->compile_binds($sql, $binds);
+ }
+
+ // Is query caching enabled? If the query is a "read type"
// we will load the caching class and return the previously
// cached query if it exists
if ($this->cache_on == TRUE AND stristr($sql, 'SELECT'))
@@ -304,12 +300,6 @@ class CI_DB_driver {
}
}
- // Compile binds if needed
- if ($binds !== FALSE)
- {
- $sql = $this->compile_binds($sql, $binds);
- }
-
// Save the query for debugging
if ($this->save_queries == TRUE)
{
@@ -330,30 +320,28 @@ class CI_DB_driver {
// This will trigger a rollback if transactions are being used
$this->_trans_status = FALSE;
- // Grab the error number and message now, as we might run some
- // additional queries before displaying the error
- $error_no = $this->_error_number();
- $error_msg = $this->_error_message();
+ // Grab the error now, as we might run some additional queries before displaying the error
+ $error = $this->error();
// Log errors
- log_message('error', 'Query error: '.$error_msg);
+ log_message('error', 'Query error: '.$error['message']);
if ($this->db_debug)
{
// We call this function in order to roll-back queries
- // if transactions are enabled. If we don't call this here
+ // if transactions are enabled. If we don't call this here
// the error message will trigger an exit, causing the
// transactions to remain in limbo.
$this->trans_complete();
// Display errors
return $this->display_error(
- array(
- 'Error Number: '.$error_no,
- $error_msg,
- $sql
- )
- );
+ array(
+ 'Error Number: '.$error['code'],
+ $error['message'],
+ $sql
+ )
+ );
}
return FALSE;
@@ -394,21 +382,9 @@ class CI_DB_driver {
}
// Load and instantiate the result driver
+ $driver = $this->load_rdriver();
+ $RES = new $driver($this);
- $driver = $this->load_rdriver();
- $RES = new $driver();
- $RES->conn_id = $this->conn_id;
- $RES->result_id = $this->result_id;
-
- if ($this->dbdriver == 'oci8')
- {
- $RES->stmt_id = $this->stmt_id;
- $RES->curs_id = NULL;
- $RES->limit_used = $this->limit_used;
- $this->stmt_id = FALSE;
- }
-
- // oci8 vars must be set before calling this
$RES->num_rows = $RES->num_rows();
// Is query caching enabled? If so, we'll serialize the
@@ -441,10 +417,9 @@ class CI_DB_driver {
/**
* Load the result drivers
*
- * @access public
* @return string the name of the result class
*/
- function load_rdriver()
+ public function load_rdriver()
{
$driver = 'CI_DB_'.$this->dbdriver.'_result';
@@ -461,15 +436,14 @@ class CI_DB_driver {
/**
* Simple Query
- * This is a simplified version of the query() function. Internally
+ * This is a simplified version of the query() function. Internally
* we only use it when running transaction commands since they do
* not require all the features of the main query() function.
*
- * @access public
* @param string the sql query
* @return mixed
*/
- function simple_query($sql)
+ public function simple_query($sql)
{
if ( ! $this->conn_id)
{
@@ -485,10 +459,9 @@ class CI_DB_driver {
* Disable Transactions
* This permits transactions to be disabled at run-time.
*
- * @access public
* @return void
*/
- function trans_off()
+ public function trans_off()
{
$this->trans_enabled = FALSE;
}
@@ -502,10 +475,9 @@ class CI_DB_driver {
* If strict mode is disabled, each group is treated autonomously, meaning
* a failure of one group will not affect any others
*
- * @access public
* @return void
*/
- function trans_strict($mode = TRUE)
+ public function trans_strict($mode = TRUE)
{
$this->trans_strict = is_bool($mode) ? $mode : TRUE;
}
@@ -515,10 +487,9 @@ class CI_DB_driver {
/**
* Start Transaction
*
- * @access public
* @return void
*/
- function trans_start($test_mode = FALSE)
+ public function trans_start($test_mode = FALSE)
{
if ( ! $this->trans_enabled)
{
@@ -541,10 +512,9 @@ class CI_DB_driver {
/**
* Complete Transaction
*
- * @access public
* @return bool
*/
- function trans_complete()
+ public function trans_complete()
{
if ( ! $this->trans_enabled)
{
@@ -588,10 +558,9 @@ class CI_DB_driver {
/**
* Lets you retrieve the transaction flag to determine if it has failed
*
- * @access public
* @return bool
*/
- function trans_status()
+ public function trans_status()
{
return $this->_trans_status;
}
@@ -601,12 +570,11 @@ class CI_DB_driver {
/**
* Compile Bindings
*
- * @access public
* @param string the sql statement
* @param array an array of bind data
* @return string
*/
- function compile_binds($sql, $binds)
+ public function compile_binds($sql, $binds)
{
if (strpos($sql, $this->bind_marker) === FALSE)
{
@@ -649,7 +617,7 @@ class CI_DB_driver {
*/
public function is_write_type($sql)
{
- return (bool) preg_match('/^\s*"?(SET|INSERT|UPDATE|DELETE|REPLACE|CREATE|DROP|TRUNCATE|LOAD DATA|COPY|ALTER|RENAME|GRANT|REVOKE|LOCK|UNLOCK|OPTIMIZE)\s+/i', $sql);
+ return (bool) preg_match('/^\s*"?(SET|INSERT|UPDATE|DELETE|REPLACE|CREATE|DROP|TRUNCATE|LOAD DATA|COPY|ALTER|RENAME|GRANT|REVOKE|LOCK|UNLOCK|OPTIMIZE|REINDEX)\s+/i', $sql);
}
// --------------------------------------------------------------------
@@ -657,11 +625,10 @@ class CI_DB_driver {
/**
* Calculate the aggregate query elapsed time
*
- * @access public
- * @param integer The number of decimal places
- * @return integer
+ * @param int The number of decimal places
+ * @return int
*/
- function elapsed_time($decimals = 6)
+ public function elapsed_time($decimals = 6)
{
return number_format($this->benchmark, $decimals);
}
@@ -671,10 +638,9 @@ class CI_DB_driver {
/**
* Returns the total number of queries
*
- * @access public
- * @return integer
+ * @return int
*/
- function total_queries()
+ public function total_queries()
{
return $this->query_count;
}
@@ -684,10 +650,9 @@ class CI_DB_driver {
/**
* Returns the last query that was executed
*
- * @access public
- * @return void
+ * @return string
*/
- function last_query()
+ public function last_query()
{
return end($this->queries);
}
@@ -700,13 +665,12 @@ class CI_DB_driver {
* Escapes data based on type
* Sets boolean and null types
*
- * @access public
* @param string
* @return mixed
*/
- function escape($str)
+ public function escape($str)
{
- if (is_string($str))
+ if (is_string($str) OR method_exists($str, '__toString'))
{
$str = "'".$this->escape_str($str)."'";
}
@@ -730,11 +694,10 @@ class CI_DB_driver {
* Calls the individual driver for platform
* specific escaping for LIKE conditions
*
- * @access public
* @param string
* @return mixed
*/
- function escape_like_str($str)
+ public function escape_like_str($str)
{
return $this->escape_str($str, TRUE);
}
@@ -744,14 +707,13 @@ class CI_DB_driver {
/**
* Primary
*
- * Retrieves the primary key. It assumes that the row in the first
+ * Retrieves the primary key. It assumes that the row in the first
* position is the primary key
*
- * @access public
* @param string the table name
* @return string
*/
- function primary($table = '')
+ public function primary($table = '')
{
$fields = $this->list_fields($table);
@@ -768,10 +730,9 @@ class CI_DB_driver {
/**
* Returns an array of table names
*
- * @access public
* @return array
*/
- function list_tables($constrain_by_prefix = FALSE)
+ public function list_tables($constrain_by_prefix = FALSE)
{
// Is there a cached result?
if (isset($this->data_cache['table_names']))
@@ -809,7 +770,7 @@ class CI_DB_driver {
}
$this->data_cache['table_names'] = $retval;
-
+
return $this->data_cache['table_names'];
}
@@ -817,12 +778,12 @@ class CI_DB_driver {
/**
* Determine if a particular table exists
- * @access public
- * @return boolean
+ *
+ * @return bool
*/
- function table_exists($table_name)
+ public function table_exists($table_name)
{
- return ( ! in_array($this->_protect_identifiers($table_name, TRUE, FALSE, FALSE), $this->list_tables())) ? FALSE : TRUE;
+ return in_array($this->protect_identifiers($table_name, TRUE, FALSE, FALSE), $this->list_tables());
}
// --------------------------------------------------------------------
@@ -830,11 +791,10 @@ class CI_DB_driver {
/**
* Fetch MySQL Field Names
*
- * @access public
* @param string the table name
* @return array
*/
- function list_fields($table = '')
+ public function list_fields($table = '')
{
// Is there a cached result?
if (isset($this->data_cache['field_names'][$table]))
@@ -883,12 +843,12 @@ class CI_DB_driver {
/**
* Determine if a particular field exists
- * @access public
+ *
* @param string
* @param string
- * @return boolean
+ * @return bool
*/
- function field_exists($field_name, $table_name)
+ public function field_exists($field_name, $table_name)
{
return ( ! in_array($field_name, $this->list_fields($table_name))) ? FALSE : TRUE;
}
@@ -898,11 +858,10 @@ class CI_DB_driver {
/**
* Returns an object with field data
*
- * @access public
* @param string the table name
* @return object
*/
- function field_data($table = '')
+ public function field_data($table = '')
{
if ($table == '')
{
@@ -913,7 +872,7 @@ class CI_DB_driver {
return FALSE;
}
- $query = $this->query($this->_field_data($this->_protect_identifiers($table, TRUE, NULL, FALSE)));
+ $query = $this->query($this->_field_data($this->protect_identifiers($table, TRUE, NULL, FALSE)));
return $query->field_data();
}
@@ -923,12 +882,11 @@ class CI_DB_driver {
/**
* Generate an insert string
*
- * @access public
* @param string the table upon which the query will be performed
* @param array an associative array data of key/values
* @return string
*/
- function insert_string($table, $data)
+ public function insert_string($table, $data)
{
$fields = array();
$values = array();
@@ -939,7 +897,7 @@ class CI_DB_driver {
$values[] = $this->escape($val);
}
- return $this->_insert($this->_protect_identifiers($table, TRUE, NULL, FALSE), $fields, $values);
+ return $this->_insert($this->protect_identifiers($table, TRUE, NULL, FALSE), $fields, $values);
}
// --------------------------------------------------------------------
@@ -947,23 +905,22 @@ class CI_DB_driver {
/**
* Generate an update string
*
- * @access public
* @param string the table upon which the query will be performed
* @param array an associative array data of key/values
* @param mixed the "where" statement
* @return string
*/
- function update_string($table, $data, $where)
+ public function update_string($table, $data, $where)
{
if ($where == '')
{
- return false;
+ return FALSE;
}
$fields = array();
foreach ($data as $key => $val)
{
- $fields[$this->_protect_identifiers($key)] = $this->escape($val);
+ $fields[$this->protect_identifiers($key)] = $this->escape($val);
}
if ( ! is_array($where))
@@ -976,7 +933,7 @@ class CI_DB_driver {
foreach ($where as $key => $val)
{
$prefix = (count($dest) == 0) ? '' : ' AND ';
- $key = $this->_protect_identifiers($key);
+ $key = $this->protect_identifiers($key);
if ($val !== '')
{
@@ -992,7 +949,7 @@ class CI_DB_driver {
}
}
- return $this->_update($this->_protect_identifiers($table, TRUE, NULL, FALSE), $fields, $dest);
+ return $this->_update($this->protect_identifiers($table, TRUE, NULL, FALSE), $fields, $dest);
}
// --------------------------------------------------------------------
@@ -1000,11 +957,10 @@ class CI_DB_driver {
/**
* Tests whether the string has an SQL operator
*
- * @access private
* @param string
* @return bool
*/
- function _has_operator($str)
+ protected function _has_operator($str)
{
$str = trim($str);
if ( ! preg_match("/(\s|<|>|!|=|is null|is not null)/i", $str))
@@ -1020,12 +976,11 @@ class CI_DB_driver {
/**
* Enables a native PHP function to be run, using a platform agnostic wrapper.
*
- * @access public
* @param string the function name
* @param mixed any parameters needed by the function
* @return mixed
*/
- function call_function($function)
+ public function call_function($function)
{
$driver = ($this->dbdriver == 'postgre') ? 'pg_' : $this->dbdriver.'_';
@@ -1062,11 +1017,10 @@ class CI_DB_driver {
/**
* Set Cache Directory Path
*
- * @access public
* @param string the path to the cache directory
* @return void
*/
- function cache_set_path($path = '')
+ public function cache_set_path($path = '')
{
$this->cachedir = $path;
}
@@ -1076,10 +1030,9 @@ class CI_DB_driver {
/**
* Enable Query Caching
*
- * @access public
- * @return void
+ * @return bool cache_on value
*/
- function cache_on()
+ public function cache_on()
{
$this->cache_on = TRUE;
return TRUE;
@@ -1090,10 +1043,9 @@ class CI_DB_driver {
/**
* Disable Query Caching
*
- * @access public
- * @return void
+ * @return bool cache_on value
*/
- function cache_off()
+ public function cache_off()
{
$this->cache_on = FALSE;
return FALSE;
@@ -1105,10 +1057,9 @@ class CI_DB_driver {
/**
* Delete the cache files associated with a particular URI
*
- * @access public
- * @return void
+ * @return bool
*/
- function cache_delete($segment_one = '', $segment_two = '')
+ public function cache_delete($segment_one = '', $segment_two = '')
{
if ( ! $this->_cache_init())
{
@@ -1122,10 +1073,9 @@ class CI_DB_driver {
/**
* Delete All cache files
*
- * @access public
- * @return void
+ * @return bool
*/
- function cache_delete_all()
+ public function cache_delete_all()
{
if ( ! $this->_cache_init())
{
@@ -1140,10 +1090,9 @@ class CI_DB_driver {
/**
* Initialize the Cache Class
*
- * @access private
- * @return void
+ * @return bool
*/
- function _cache_init()
+ protected function _cache_init()
{
if (is_object($this->CACHE) AND class_exists('CI_DB_Cache'))
{
@@ -1167,10 +1116,9 @@ class CI_DB_driver {
/**
* Close DB Connection
*
- * @access public
* @return void
*/
- function close()
+ public function close()
{
if (is_resource($this->conn_id) OR is_object($this->conn_id))
{
@@ -1184,13 +1132,12 @@ class CI_DB_driver {
/**
* Display an error message
*
- * @access public
* @param string the error message
* @param string any "swap" values
- * @param boolean whether to localize the message
+ * @param bool whether to localize the message
* @return string sends the application/error_db.php template
*/
- function display_error($error = '', $swap = '', $native = FALSE)
+ public function display_error($error = '', $swap = '', $native = FALSE)
{
$LANG =& load_class('Lang', 'core');
$LANG->load('db');
@@ -1234,27 +1181,11 @@ class CI_DB_driver {
/**
* Protect Identifiers
*
- * This function adds backticks if appropriate based on db type
- *
- * @access private
- * @param mixed the item to escape
- * @return mixed the item with backticks
- */
- function protect_identifiers($item, $prefix_single = FALSE)
- {
- return $this->_protect_identifiers($item, $prefix_single);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Protect Identifiers
- *
* This function is used extensively by the Active Record class, and by
* a couple functions in this class.
* It takes a column or table name (optionally with an alias) and inserts
* the table prefix onto it. Some logic is necessary in order to deal with
- * column names that include the path. Consider a query like this:
+ * column names that include the path. Consider a query like this:
*
* SELECT * FROM hostname.database.table.column AS c FROM hostname.database.table
*
@@ -1267,14 +1198,13 @@ class CI_DB_driver {
* insert the table prefix (if it exists) in the proper position, and escape only
* the correct identifiers.
*
- * @access private
* @param string
* @param bool
* @param mixed
* @param bool
* @return string
*/
- function _protect_identifiers($item, $prefix_single = FALSE, $protect_identifiers = NULL, $field_exists = TRUE)
+ public function protect_identifiers($item, $prefix_single = FALSE, $protect_identifiers = NULL, $field_exists = TRUE)
{
if ( ! is_bool($protect_identifiers))
{
@@ -1284,10 +1214,9 @@ class CI_DB_driver {
if (is_array($item))
{
$escaped_array = array();
-
foreach ($item as $k => $v)
{
- $escaped_array[$this->_protect_identifiers($k)] = $this->_protect_identifiers($v);
+ $escaped_array[$this->protect_identifiers($k)] = $this->protect_identifiers($v);
}
return $escaped_array;
@@ -1307,7 +1236,7 @@ class CI_DB_driver {
// This is basically a bug fix for queries that use MAX, MIN, etc.
// If a parenthesis is found we know that we do not need to
- // escape the data or add a prefix. There's probably a more graceful
+ // escape the data or add a prefix. There's probably a more graceful
// way to deal with this, but I'm not thinking of it -- Rick
if (strpos($item, '(') !== FALSE)
{
@@ -1322,7 +1251,7 @@ class CI_DB_driver {
$parts = explode('.', $item);
// Does the first segment of the exploded item match
- // one of the aliases previously identified? If so,
+ // one of the aliases previously identified? If so,
// we have nothing more to do other than escape the item
if (in_array($parts[0], $this->ar_aliased_tables))
{
@@ -1341,7 +1270,7 @@ class CI_DB_driver {
return $item.$alias;
}
- // Is there a table prefix defined in the config file? If not, no need to do anything
+ // Is there a table prefix defined in the config file? If not, no need to do anything
if ($this->dbprefix != '')
{
// We now add the table prefix based on some logic.
@@ -1395,7 +1324,7 @@ class CI_DB_driver {
return $item.$alias;
}
- // Is there a table prefix? If not, no need to insert it
+ // Is there a table prefix? If not, no need to insert it
if ($this->dbprefix != '')
{
// Verify table prefix and replace if necessary
@@ -1418,7 +1347,7 @@ class CI_DB_driver {
return $item.$alias;
}
-
+
// --------------------------------------------------------------------
/**
@@ -1426,12 +1355,10 @@ class CI_DB_driver {
*
* This function is used extensively by every db driver.
*
- * @access private
* @return void
*/
protected function _reset_select()
{
-
}
}
diff --git a/system/database/DB_forge.php b/system/database/DB_forge.php
index 336e9497d..fe2a67728 100644
--- a/system/database/DB_forge.php
+++ b/system/database/DB_forge.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/database/DB_result.php b/system/database/DB_result.php
index 730443222..c3cdd24ff 100644
--- a/system/database/DB_result.php
+++ b/system/database/DB_result.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
@@ -47,6 +47,12 @@ class CI_DB_result {
public $num_rows = 0;
public $row_data = NULL;
+ public function __construct(&$driver_object)
+ {
+ $this->conn_id = $driver_object->conn_id;
+ $this->result_id = $driver_object->result_id;
+ }
+
/**
* Query result. Acts as a wrapper function for the following functions.
*
diff --git a/system/database/DB_utility.php b/system/database/DB_utility.php
index 4c881d8a1..c94f93e5e 100644
--- a/system/database/DB_utility.php
+++ b/system/database/DB_utility.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/database/drivers/cubrid/cubrid_driver.php b/system/database/drivers/cubrid/cubrid_driver.php
index 42f08fbf6..244707395 100644
--- a/system/database/drivers/cubrid/cubrid_driver.php
+++ b/system/database/drivers/cubrid/cubrid_driver.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
@@ -156,19 +156,15 @@ class CI_DB_cubrid_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * Version number query string
+ * Database version number
*
- * @access public
* @return string
*/
- function _version()
+ public function version()
{
- // To obtain the CUBRID Server version, no need to run the SQL query.
- // CUBRID PHP API provides a function to determin this value.
- // This is why we also need to add 'cubrid' value to the list of
- // $driver_version_exceptions array in DB_driver class in
- // version() function.
- return cubrid_get_server_info($this->conn_id);
+ return isset($this->data_cache['version'])
+ ? $this->data_cache['version']
+ : $this->data_cache['version'] = cubrid_get_server_info($this->conn_id);
}
// --------------------------------------------------------------------
@@ -382,9 +378,8 @@ class CI_DB_cubrid_driver extends CI_DB {
{
return 0;
}
-
- $query = $this->query($this->_count_string . $this->_protect_identifiers('numrows') . " FROM " . $this->_protect_identifiers($table, TRUE, NULL, FALSE));
+ $query = $this->query($this->_count_string.$this->protect_identifiers('numrows').' FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE));
if ($query->num_rows() == 0)
{
return 0;
@@ -431,7 +426,7 @@ class CI_DB_cubrid_driver extends CI_DB {
*/
function _list_columns($table = '')
{
- return "SHOW COLUMNS FROM ".$this->_protect_identifiers($table, TRUE, NULL, FALSE);
+ return 'SHOW COLUMNS FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE);
}
// --------------------------------------------------------------------
@@ -453,31 +448,18 @@ class CI_DB_cubrid_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * The error message string
+ * Error
*
- * @access private
- * @return string
- */
- function _error_message()
- {
- return cubrid_error($this->conn_id);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * The error message number
+ * Returns an array containing code and message of the last
+ * database error that has occured.
*
- * @access private
- * @return integer
+ * @return array
*/
- function _error_number()
+ public function error()
{
- return cubrid_errno($this->conn_id);
+ return array('code' => cubrid_errno($this->conn_id), 'message' => cubrid_error($this->conn_id));
}
- // --------------------------------------------------------------------
-
/**
* Escape the SQL Identifiers
*
diff --git a/system/database/drivers/cubrid/cubrid_forge.php b/system/database/drivers/cubrid/cubrid_forge.php
index 85e740057..7d606ea36 100644
--- a/system/database/drivers/cubrid/cubrid_forge.php
+++ b/system/database/drivers/cubrid/cubrid_forge.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
@@ -93,11 +93,11 @@ class CI_DB_cubrid_forge extends CI_DB_forge {
{
$attributes = array_change_key_case($attributes, CASE_UPPER);
- $sql .= "\n\t\"" . $this->db->_protect_identifiers($field) . "\"";
+ $sql .= "\n\t\"".$this->db->protect_identifiers($field).'"';
if (array_key_exists('NAME', $attributes))
{
- $sql .= ' '.$this->db->_protect_identifiers($attributes['NAME']).' ';
+ $sql .= ' '.$this->db->protect_identifiers($attributes['NAME']).' ';
}
if (array_key_exists('TYPE', $attributes))
@@ -197,10 +197,9 @@ class CI_DB_cubrid_forge extends CI_DB_forge {
// If there is a PK defined
if (count($primary_keys) > 0)
{
- $key_name = "pk_" . $table . "_" .
- $this->db->_protect_identifiers(implode('_', $primary_keys));
-
- $primary_keys = $this->db->_protect_identifiers($primary_keys);
+ $key_name = 'pk_'.$table.'_'.$this->db->protect_identifiers(implode('_', $primary_keys));
+
+ $primary_keys = $this->db->protect_identifiers($primary_keys);
$sql .= ",\n\tCONSTRAINT " . $key_name . " PRIMARY KEY(" . implode(', ', $primary_keys) . ")";
}
@@ -210,15 +209,15 @@ class CI_DB_cubrid_forge extends CI_DB_forge {
{
if (is_array($key))
{
- $key_name = $this->db->_protect_identifiers(implode('_', $key));
- $key = $this->db->_protect_identifiers($key);
+ $key_name = $this->db->protect_identifiers(implode('_', $key));
+ $key = $this->db->protect_identifiers($key);
}
else
{
- $key_name = $this->db->_protect_identifiers($key);
+ $key_name = $this->db->protect_identifiers($key);
$key = array($key_name);
}
-
+
$sql .= ",\n\tKEY \"{$key_name}\" (" . implode(', ', $key) . ")";
}
}
@@ -258,19 +257,19 @@ class CI_DB_cubrid_forge extends CI_DB_forge {
*/
function _alter_table($alter_type, $table, $fields, $after_field = '')
{
- $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table)." $alter_type ";
+ $sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' ';
// DROP has everything it needs now.
if ($alter_type == 'DROP')
{
- return $sql.$this->db->_protect_identifiers($fields);
+ return $sql.$this->db->protect_identifiers($fields);
}
$sql .= $this->_process_fields($fields);
if ($after_field != '')
{
- $sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field);
+ return $sql.' AFTER '.$this->db->protect_identifiers($after_field);
}
return $sql;
@@ -290,11 +289,10 @@ class CI_DB_cubrid_forge extends CI_DB_forge {
*/
function _rename_table($table_name, $new_table_name)
{
- $sql = 'RENAME TABLE '.$this->db->_protect_identifiers($table_name)." AS ".$this->db->_protect_identifiers($new_table_name);
- return $sql;
+ return 'RENAME TABLE '.$this->db->protect_identifiers($table_name).' AS '.$this->db->protect_identifiers($new_table_name);
}
}
/* End of file cubrid_forge.php */
-/* Location: ./system/database/drivers/cubrid/cubrid_forge.php */ \ No newline at end of file
+/* Location: ./system/database/drivers/cubrid/cubrid_forge.php */
diff --git a/system/database/drivers/cubrid/cubrid_result.php b/system/database/drivers/cubrid/cubrid_result.php
index 4c0fede10..a7eeb8a39 100644
--- a/system/database/drivers/cubrid/cubrid_result.php
+++ b/system/database/drivers/cubrid/cubrid_result.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/database/drivers/cubrid/cubrid_utility.php b/system/database/drivers/cubrid/cubrid_utility.php
index 750c0d8dd..a13c0a5e4 100644
--- a/system/database/drivers/cubrid/cubrid_utility.php
+++ b/system/database/drivers/cubrid/cubrid_utility.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/database/drivers/interbase/index.html b/system/database/drivers/interbase/index.html
new file mode 100644
index 000000000..c942a79ce
--- /dev/null
+++ b/system/database/drivers/interbase/index.html
@@ -0,0 +1,10 @@
+<html>
+<head>
+ <title>403 Forbidden</title>
+</head>
+<body>
+
+<p>Directory access is forbidden.</p>
+
+</body>
+</html> \ No newline at end of file
diff --git a/system/database/drivers/interbase/interbase_driver.php b/system/database/drivers/interbase/interbase_driver.php
new file mode 100644
index 000000000..a9a647202
--- /dev/null
+++ b/system/database/drivers/interbase/interbase_driver.php
@@ -0,0 +1,626 @@
+<?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:
+ * http://opensource.org/licenses/OSL-3.0
+ * If you did not receive a copy of the license and are unable to obtain it
+ * through the world wide web, please send an email to
+ * licensing@ellislab.com so we can send you a copy immediately.
+ *
+ * @package CodeIgniter
+ * @author EllisLab Dev Team
+ * @copyright Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/)
+ * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
+ * @link http://codeigniter.com
+ * @since Version 3.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Firebird/Interbase Database Adapter Class
+ *
+ * Note: _DB is an extender class that the app controller
+ * creates dynamically based on whether the active record
+ * class is being used or not.
+ *
+ * @package CodeIgniter
+ * @subpackage Drivers
+ * @category Database
+ * @author EllisLab Dev Team
+ * @link http://codeigniter.com/user_guide/database/
+ */
+class CI_DB_interbase_driver extends CI_DB {
+
+ public $dbdriver = 'interbase';
+
+ // The character used to escape with
+ protected $_escape_char = '"';
+
+ // clause and character used for LIKE escape sequences
+ 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.
+ */
+ 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;
+
+ /**
+ * Non-persistent database connection
+ *
+ * @return resource
+ */
+ public function db_connect()
+ {
+ return @ibase_connect($this->hostname.':'.$this->database, $this->username, $this->password, $this->char_set);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Persistent database connection
+ *
+ * @return resource
+ */
+ public function db_pconnect()
+ {
+ return @ibase_pconnect($this->hostname.':'.$this->database, $this->username, $this->password, $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
+ *
+ * @return void
+ */
+ public function reconnect()
+ {
+ // not implemented in Interbase/Firebird
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Select the database
+ *
+ * @return bool
+ */
+ public function db_select()
+ {
+ // Connection selects the database
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Database version number
+ *
+ * @return string
+ */
+ public function version()
+ {
+ if (isset($this->data_cache['version']))
+ {
+ return $this->data_cache['version'];
+ }
+
+ if (($service = ibase_service_attach($this->hostname, $this->username, $this->password)))
+ {
+ $this->data_cache['version'] = ibase_server_info($service, IBASE_SVC_SERVER_VERSION);
+
+ // Don't keep the service open
+ ibase_service_detach($service);
+ return $this->data_cache['version'];
+ }
+
+ return FALSE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Execute the query
+ *
+ * @param string an SQL query
+ * @return resource
+ */
+ 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)
+ {
+ return TRUE;
+ }
+
+ // 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 = @ibase_trans($this->conn_id);
+
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Commit Transaction
+ *
+ * @return bool
+ */
+ 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)
+ {
+ return TRUE;
+ }
+
+ return @ibase_commit($this->trans);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Rollback Transaction
+ *
+ * @return bool
+ */
+ 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)
+ {
+ return TRUE;
+ }
+
+ return @ibase_rollback($this->trans);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Escape String
+ *
+ * @param string
+ * @param bool whether or not the string will be used in a LIKE condition
+ * @return string
+ */
+ public function escape_str($str, $like = FALSE)
+ {
+ if (is_array($str))
+ {
+ foreach ($str as $key => $val)
+ {
+ $str[$key] = $this->escape_str($val, $like);
+ }
+
+ return $str;
+ }
+
+ // 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;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Affected Rows
+ *
+ * @return integer
+ */
+ public function affected_rows()
+ {
+ return @ibase_affected_rows($this->conn_id);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Insert ID
+ *
+ * @param string $generator_name
+ * @param integer $inc_by
+ * @return integer
+ */
+ public function insert_id($generator_name, $inc_by=0)
+ {
+ //If a generator hasn't been used before it will return 0
+ return ibase_gen_id('"'.$generator_name.'"', $inc_by);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * "Count All" query
+ *
+ * Generates a platform-specific query string that counts all records in
+ * the specified database
+ *
+ * @param string
+ * @return string
+ */
+ public function count_all($table = '')
+ {
+ if ($table == '')
+ {
+ return 0;
+ }
+
+ $query = $this->query($this->_count_string.$this->protect_identifiers('numrows').' FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE));
+ if ($query->num_rows() == 0)
+ {
+ return 0;
+ }
+
+ $row = $query->row();
+ $this->_reset_select();
+ return (int) $row->numrows;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * List table query
+ *
+ * Generates a platform-specific query string so that the table names can be fetched
+ *
+ * @param boolean
+ * @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;
+
+ if ($prefix_limit !== FALSE AND $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;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Show column query
+ *
+ * Generates a platform-specific query string so that the column names can be fetched
+ *
+ * @param string the table name
+ * @return string
+ */
+ protected function _list_columns($table = '')
+ {
+ return <<<SQL
+ SELECT "RDB\$FIELD_NAME" FROM "RDB\$RELATION_FIELDS"
+ WHERE "RDB\$RELATION_NAME"='{$table}';
+SQL;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Field data query
+ *
+ * Generates a platform-specific query so that the column data can be retrieved
+ *
+ * @param string the table name
+ * @return object
+ */
+ 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}";
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Error
+ *
+ * Returns an array containing code and message of the last
+ * database error that has occured.
+ *
+ * @return array
+ */
+ public function error()
+ {
+ return array('code' => ibase_errcode(), 'message' => ibase_errmsg());
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Escape the SQL Identifiers
+ *
+ * This public function escapes column and table names
+ *
+ * @param string
+ * @return string
+ */
+ protected function _escape_identifiers($item)
+ {
+ foreach ($this->_reserved_identifiers as $id)
+ {
+ if (strpos($item, '.'.$id) !== FALSE)
+ {
+ $str = $this->_escape_char. 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);
+ }
+ }
+
+ 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;
+ }
+
+ // remove duplicates if the user already included the escape
+ return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * From Tables
+ *
+ * This public function implicitly groups FROM tables so there is no confusion
+ * about operator precedence in harmony with SQL standards
+ *
+ * @param type
+ * @return type
+ */
+ protected function _from_tables($tables)
+ {
+ if ( ! is_array($tables))
+ {
+ $tables = array($tables);
+ }
+
+ //Interbase/Firebird doesn't like grouped tables
+ return implode(', ', $tables);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Insert statement
+ *
+ * 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
+ */
+ protected function _insert($table, $keys, $values)
+ {
+ return "INSERT INTO {$table} (".implode(', ', $keys).') VALUES ('.implode(', ', $values).')';
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Update statement
+ *
+ * Generates a platform-specific update string from the supplied data
+ *
+ * @param string the table name
+ * @param array the update data
+ * @param array the where clause
+ * @param array the orderby clause
+ * @param array the limit clause
+ * @return string
+ */
+ protected function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
+ {
+ foreach ($values as $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;
+ }
+
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Truncate statement
+ *
+ * Generates a platform-specific truncate string from the supplied data
+ * If the database does not support the truncate() command
+ * This public function maps to "DELETE FROM table"
+ *
+ * @param string the table name
+ * @return string
+ */
+ protected function _truncate($table)
+ {
+ return $this->_delete($table);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Delete statement
+ *
+ * Generates a platform-specific delete string from the supplied data
+ *
+ * @param string the table name
+ * @param array the where clause
+ * @param string the limit clause
+ * @return string
+ */
+ 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);
+ }
+
+ //$limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
+
+ return "DELETE FROM {$table}{$conditions}";
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Limit string
+ *
+ * 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
+ * @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;
+ }
+ }
+ else
+ {
+ $sql = 'ROWS ' . (int) $limit;
+
+ if ($offset > 0)
+ {
+ $sql = 'ROWS '. (int) $offset . ' TO ' . ($limit + $offset);
+ }
+ }
+
+ return preg_replace('`SELECT`i', "SELECT {$sql}", $orig_sql);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Close DB Connection
+ *
+ * @param resource
+ * @return void
+ */
+ protected function _close($conn_id)
+ {
+ @ibase_close($conn_id);
+ }
+
+}
+
+/* End of file interbase_driver.php */
+/* Location: ./system/database/drivers/interbase/interbase_driver.php */
diff --git a/system/database/drivers/interbase/interbase_forge.php b/system/database/drivers/interbase/interbase_forge.php
new file mode 100644
index 000000000..f46043569
--- /dev/null
+++ b/system/database/drivers/interbase/interbase_forge.php
@@ -0,0 +1,243 @@
+<?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:
+ * http://opensource.org/licenses/OSL-3.0
+ * If you did not receive a copy of the license and are unable to obtain it
+ * through the world wide web, please send an email to
+ * licensing@ellislab.com so we can send you a copy immediately.
+ *
+ * @package CodeIgniter
+ * @author EllisLab Dev Team
+ * @copyright Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/)
+ * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
+ * @link http://codeigniter.com
+ * @since Version 3.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Interbase/Firebird Forge Class
+ *
+ * @category Database
+ * @author EllisLab Dev Team
+ * @link http://codeigniter.com/user_guide/database/
+ */
+class CI_DB_interbase_forge extends CI_DB_forge {
+
+ /**
+ * Create database
+ *
+ * @param string the database name
+ * @return string
+ */
+ protected function _create_database($filename='')
+ {
+ // Firebird databases are flat files, so a path is required
+ // Hostname is needed for remote access
+ return 'CREATE DATABASE "'.$this->hostname.':'.$filename.'"';
+
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Drop database
+ *
+ * @param string the database name - not used in this driver
+ * - the current db is dropped
+ * @return bool
+ */
+ protected function _drop_database($name='')
+ {
+ return ibase_drop_db($this->conn_id);
+ }
+ // --------------------------------------------------------------------
+
+ /**
+ * Create Table
+ *
+ * @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 string
+ */
+ protected function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
+ {
+ $sql = 'CREATE TABLE ';
+
+ $sql .= $this->db->protect_identifiers($table)."(";
+ $current_field_count = 0;
+
+ 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
+ // entered the field information, so we'll simply add it to the list
+ if (is_numeric($field))
+ {
+ $sql .= "\n\t$attributes";
+ }
+ else
+ {
+ $attributes = array_change_key_case($attributes, CASE_UPPER);
+
+ $sql .= "\n\t".$this->db->protect_identifiers($field);
+
+ $sql .= ' '.$attributes['TYPE'];
+
+ if (array_key_exists('CONSTRAINT', $attributes))
+ {
+ $sql .= '('.$attributes['CONSTRAINT'].')';
+ }
+
+ if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE)
+ {
+ $sql .= ' UNSIGNED';
+ }
+
+ if (array_key_exists('DEFAULT', $attributes))
+ {
+ $sql .= ' DEFAULT \''.$attributes['DEFAULT'].'\'';
+ }
+
+ if (array_key_exists('NULL', $attributes) && $attributes['NULL'] === TRUE)
+ {
+ $sql .= ' NULL';
+ }
+ else
+ {
+ $sql .= ' NOT NULL';
+ }
+
+ if (array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE)
+ {
+ $sql .= ' AUTO_INCREMENT';
+ }
+ }
+
+ // don't add a comma on the end of the last field
+ if (++$current_field_count < count($fields))
+ {
+ $sql .= ',';
+ }
+ }
+
+ if (count($primary_keys) > 0)
+ {
+ $primary_keys = $this->db->protect_identifiers($primary_keys);
+ $sql .= ",\n\tPRIMARY KEY (" . implode(', ', $primary_keys) . ")";
+ }
+
+ if (is_array($keys) && count($keys) > 0)
+ {
+ foreach ($keys as $key)
+ {
+ if (is_array($key))
+ {
+ $key = $this->db->protect_identifiers($key);
+ }
+ else
+ {
+ $key = array($this->db->protect_identifiers($key));
+ }
+
+ $sql .= ",\n\tUNIQUE (" . implode(', ', $key) . ")";
+ }
+ }
+
+ $sql .= "\n)";
+
+ return $sql;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Drop Table
+ *
+ * @return string
+ */
+ protected function _drop_table($table)
+ {
+ return 'DROP TABLE '.$name;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Alter table query
+ *
+ * Generates a platform-specific query so that a table can be altered
+ * Called by add_column(), drop_column(), and column_alter(),
+ *
+ * @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 string the field after which we should add the new field
+ * @return string
+ */
+ protected 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);
+
+ $sql .= " {$column_definition}";
+
+ if ($default_value != '')
+ {
+ $sql .= " DEFAULT \"{$default_value}\"";
+ }
+
+ if ($null === NULL)
+ {
+ $sql .= ' NULL';
+ }
+ else
+ {
+ $sql .= ' NOT NULL';
+ }
+
+ if ($after_field != '')
+ {
+ $sql .= ' AFTER ' . $this->db->protect_identifiers($after_field);
+ }
+
+ return $sql;
+
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Rename a table
+ *
+ * Generates a platform-specific query so that a table can be renamed
+ *
+ * @param string the old table name
+ * @param string the new table name
+ * @return string
+ */
+ protected 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);
+ }
+}
+
+/* End of file interbase_forge.php */
+/* Location: ./system/database/drivers/interbase/interbase_forge.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
new file mode 100644
index 000000000..5bf0c902d
--- /dev/null
+++ b/system/database/drivers/interbase/interbase_result.php
@@ -0,0 +1,294 @@
+<?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:
+ * http://opensource.org/licenses/OSL-3.0
+ * If you did not receive a copy of the license and are unable to obtain it
+ * through the world wide web, please send an email to
+ * licensing@ellislab.com so we can send you a copy immediately.
+ *
+ * @package CodeIgniter
+ * @author EllisLab Dev Team
+ * @copyright Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/)
+ * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
+ * @link http://codeigniter.com
+ * @since Version 3.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Interbase/Firebird Result Class
+ *
+ * This class extends the parent result class: CI_DB_result
+ *
+ * @category Database
+ * @author EllisLab Dev Team
+ * @link http://codeigniter.com/user_guide/database/
+ */
+class CI_DB_interbase_result extends CI_DB_result {
+
+ public $num_rows;
+
+ /**
+ * Number of rows in the result set
+ *
+ * @return integer
+ */
+ public function num_rows()
+ {
+ if( ! is_null($this->num_rows))
+ {
+ return $this->num_rows;
+ }
+
+ //Get the results so that you can get an accurate rowcount
+ $this->result();
+
+ return $this->num_rows;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Number of fields in the result set
+ *
+ * @return integer
+ */
+ public function num_fields()
+ {
+ return @ibase_num_fields($this->result_id);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Fetch Field Names
+ *
+ * Generates an array of column names
+ *
+ * @return array
+ */
+ public function list_fields()
+ {
+ $field_names = array();
+ for ($i = 0, $num_fields = $this->num_fields(); $i < $num_fields; $i++)
+ {
+ $info = ibase_field_info($this->result_id, $i);
+ $field_names[] = $info['name'];
+ }
+
+ return $field_names;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Field data
+ *
+ * Generates an array of objects containing field meta-data
+ *
+ * @return array
+ */
+ public function field_data()
+ {
+
+ $retval = array();
+ for ($i = 0, $num_fields = $this->num_fields(); $i < $num_fields; $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;
+ }
+
+ return $retval;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Free the result
+ *
+ * @return null
+ */
+ public function free_result()
+ {
+ @ibase_free_result($this->result_id);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Data Seek
+ *
+ * Moves the internal pointer to the desired offset. We call
+ * this internally before fetching results to make sure the
+ * result set starts at zero
+ *
+ * @return array
+ */
+ 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;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Result - associative array
+ *
+ * Returns the result set as an array
+ *
+ * @return array
+ */
+ protected function _fetch_assoc()
+ {
+ if (($row = @ibase_fetch_assoc($this->result_id, IBASE_FETCH_BLOBS)) !== FALSE)
+ {
+ //Increment row count
+ $this->num_rows++;
+ }
+
+ return $row;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Result - object
+ *
+ * Returns the result set as an object
+ *
+ * @return object
+ */
+ protected function _fetch_object()
+ {
+ if (($row = @ibase_fetch_object($this->result_id, IBASE_FETCH_BLOBS)) !== FALSE)
+ {
+ //Increment row count
+ $this->num_rows++;
+ }
+
+ return $row;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Query result. "object" version.
+ *
+ * @return object
+ */
+ public function result_object()
+ {
+ if (count($this->result_object) > 0)
+ {
+ return $this->result_object;
+ }
+
+ // Convert result array to object so that
+ // We don't have to get the result again
+ if (count($this->result_array) > 0)
+ {
+ $i = 0;
+
+ foreach ($this->result_array as $array)
+ {
+ $this->result_object[$i] = new StdClass();
+
+ foreach ($array as $key => $val)
+ {
+ $this->result_object[$i]->{$key} = $val;
+ }
+
+ ++$i;
+ }
+
+ return $this->result_object;
+ }
+
+ // In the event that query caching is on the result_id variable
+ // will return FALSE since there isn't a valid SQL resource so
+ // we'll simply return an empty array.
+ if ($this->result_id === FALSE)
+ {
+ return array();
+ }
+
+ $this->num_rows = 0;
+ while ($row = $this->_fetch_object())
+ {
+ $this->result_object[] = $row;
+ }
+
+ return $this->result_object;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Query result. "array" version.
+ *
+ * @return array
+ */
+ public function result_array()
+ {
+ if (count($this->result_array) > 0)
+ {
+ 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)
+ {
+ foreach ($this->result_object as $obj)
+ {
+ $this->result_array[] = (array) $obj;
+ }
+
+ return $this->result_array;
+ }
+
+ // In the event that query caching is on the result_id variable
+ // will return FALSE since there isn't a valid SQL resource so
+ // we'll simply return an empty array.
+ if ($this->result_id === FALSE)
+ {
+ return array();
+ }
+
+ $this->num_rows = 0;
+ while ($row = $this->_fetch_assoc())
+ {
+ $this->result_array[] = $row;
+ }
+
+ return $this->result_array;
+ }
+
+}
+
+/* End of file interbase_result.php */
+/* Location: ./system/database/drivers/interbase/interbase_result.php */ \ No newline at end of file
diff --git a/system/database/drivers/interbase/interbase_utility.php b/system/database/drivers/interbase/interbase_utility.php
new file mode 100644
index 000000000..a88055ee0
--- /dev/null
+++ b/system/database/drivers/interbase/interbase_utility.php
@@ -0,0 +1,115 @@
+<?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:
+ * http://opensource.org/licenses/OSL-3.0
+ * If you did not receive a copy of the license and are unable to obtain it
+ * through the world wide web, please send an email to
+ * licensing@ellislab.com so we can send you a copy immediately.
+ *
+ * @package CodeIgniter
+ * @author EllisLab Dev Team
+ * @copyright Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/)
+ * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
+ * @link http://codeigniter.com
+ * @since Version 3.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Interbase/Firebird Utility Class
+ *
+ * @category Database
+ * @author EllisLab Dev Team
+ * @link http://codeigniter.com/user_guide/database/
+ */
+class CI_DB_interbase_utility extends CI_DB_utility {
+
+ /**
+ * List databases
+ *
+ * I don't believe you can do a database listing with Firebird
+ * since each database is its own file. I suppose we could
+ * try reading a directory looking for Firebird files, but
+ * that doesn't seem like a terribly good idea
+ *
+ * @return bool
+ */
+ public function _list_databases()
+ {
+ if ($this->db_debug)
+ {
+ return $this->db->display_error('db_unsuported_feature');
+ }
+ return FALSE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Optimize table query
+ *
+ * Is optimization even supported in Interbase/Firebird?
+ *
+ * @param string the table name
+ * @return object
+ */
+ public function _optimize_table($table)
+ {
+ return FALSE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Repair table query
+ *
+ * Table repairs are not supported in Interbase/Firebird
+ *
+ * @param string the table name
+ * @return object
+ */
+ public function _repair_table($table)
+ {
+ return FALSE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Interbase/Firebird Export
+ *
+ * @param string $filename
+ * @return mixed
+ */
+ public function backup($filename)
+ {
+ if ($service = ibase_service_attach($this->db->hostname, $this->db->username, $this->db->password))
+ {
+ $res = ibase_backup($service, $this->db->database, $filename.'.fbk');
+
+ //Close the service connection
+ ibase_service_detach($service);
+
+ return $res;
+ }
+ else
+ {
+ return FALSE;
+ }
+ }
+}
+
+/* End of file interbase_utility.php */
+/* Location: ./system/database/drivers/interbase/interbase_utility.php */ \ No newline at end of file
diff --git a/system/database/drivers/mssql/mssql_driver.php b/system/database/drivers/mssql/mssql_driver.php
index 2a4f2b575..b6b64cc44 100644
--- a/system/database/drivers/mssql/mssql_driver.php
+++ b/system/database/drivers/mssql/mssql_driver.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
@@ -339,12 +339,11 @@ class CI_DB_mssql_driver extends CI_DB {
/**
* Version number query string
*
- * @access public
- * @return string
+ * @return string
*/
- function _version()
+ protected function _version()
{
- return "SELECT @@VERSION AS ver";
+ return 'SELECT @@VERSION AS ver';
}
// --------------------------------------------------------------------
@@ -366,8 +365,7 @@ class CI_DB_mssql_driver extends CI_DB {
return 0;
}
- $query = $this->query($this->_count_string . $this->_protect_identifiers('numrows') . " FROM " . $this->_protect_identifiers($table, TRUE, NULL, FALSE));
-
+ $query = $this->query($this->_count_string.$this->protect_identifiers('numrows').' FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE));
if ($query->num_rows() == 0)
{
return 0;
@@ -438,28 +436,18 @@ class CI_DB_mssql_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * The error message string
+ * Error
*
- * @access private
- * @return string
- */
- function _error_message()
- {
- return mssql_get_last_message();
- }
-
- // --------------------------------------------------------------------
-
- /**
- * The error message number
+ * Returns an array containing code and message of the last
+ * database error that has occured.
*
- * @access private
- * @return integer
+ * @return array
*/
- function _error_number()
+ public function error()
{
- // Are error numbers supported?
- return '';
+ $query = $this->query('SELECT @@ERROR AS code');
+ $query = $query->row();
+ return array('code' => $query->code, 'message' => mssql_get_last_message());
}
// --------------------------------------------------------------------
diff --git a/system/database/drivers/mssql/mssql_forge.php b/system/database/drivers/mssql/mssql_forge.php
index dd8aa3448..4a8089bb1 100644
--- a/system/database/drivers/mssql/mssql_forge.php
+++ b/system/database/drivers/mssql/mssql_forge.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
@@ -113,7 +113,7 @@ class CI_DB_mssql_forge extends CI_DB_forge {
{
$attributes = array_change_key_case($attributes, CASE_UPPER);
- $sql .= "\n\t".$this->db->_protect_identifiers($field);
+ $sql .= "\n\t".$this->db->protect_identifiers($field);
$sql .= ' '.$attributes['TYPE'];
@@ -156,7 +156,7 @@ class CI_DB_mssql_forge extends CI_DB_forge {
if (count($primary_keys) > 0)
{
- $primary_keys = $this->db->_protect_identifiers($primary_keys);
+ $primary_keys = $this->db->protect_identifiers($primary_keys);
$sql .= ",\n\tPRIMARY KEY (" . implode(', ', $primary_keys) . ")";
}
@@ -166,11 +166,11 @@ class CI_DB_mssql_forge extends CI_DB_forge {
{
if (is_array($key))
{
- $key = $this->db->_protect_identifiers($key);
+ $key = $this->db->protect_identifiers($key);
}
else
{
- $key = array($this->db->_protect_identifiers($key));
+ $key = array($this->db->protect_identifiers($key));
}
$sql .= ",\n\tFOREIGN KEY (" . implode(', ', $key) . ")";
@@ -202,7 +202,7 @@ class CI_DB_mssql_forge extends CI_DB_forge {
*/
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);
+ $sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '.$this->db->protect_identifiers($column_name);
// DROP has everything it needs now.
if ($alter_type == 'DROP')
@@ -228,7 +228,7 @@ class CI_DB_mssql_forge extends CI_DB_forge {
if ($after_field != '')
{
- $sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field);
+ return $sql.' AFTER '.$this->db->protect_identifiers($after_field);
}
return $sql;
@@ -250,11 +250,10 @@ class CI_DB_mssql_forge extends CI_DB_forge {
function _rename_table($table_name, $new_table_name)
{
// I think this syntax will work, but can find little documentation on renaming tables in MSSQL
- $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table_name)." RENAME TO ".$this->db->_protect_identifiers($new_table_name);
- return $sql;
+ return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name);
}
}
/* End of file mssql_forge.php */
-/* Location: ./system/database/drivers/mssql/mssql_forge.php */ \ No newline at end of file
+/* Location: ./system/database/drivers/mssql/mssql_forge.php */
diff --git a/system/database/drivers/mssql/mssql_result.php b/system/database/drivers/mssql/mssql_result.php
index bba2e6243..b205ce2d1 100644
--- a/system/database/drivers/mssql/mssql_result.php
+++ b/system/database/drivers/mssql/mssql_result.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/database/drivers/mssql/mssql_utility.php b/system/database/drivers/mssql/mssql_utility.php
index be6ed5bb0..28f34b999 100644
--- a/system/database/drivers/mssql/mssql_utility.php
+++ b/system/database/drivers/mssql/mssql_utility.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php
index c88a8a766..ba646d226 100644
--- a/system/database/drivers/mysql/mysql_driver.php
+++ b/system/database/drivers/mysql/mysql_driver.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
@@ -144,26 +144,25 @@ class CI_DB_mysql_driver extends CI_DB {
* Set client character set
*
* @param string
- * @param string
* @return bool
*/
- public function db_set_charset($charset, $collation)
+ protected function _db_set_charset($charset)
{
- return function_exists('mysql_set_charset')
- ? @mysql_set_charset($charset, $this->conn_id)
- : @mysql_query("SET NAMES '".$this->escape_str($charset)."' COLLATE '".$this->escape_str($collation)."'", $this->conn_id);
+ return @mysql_set_charset($charset, $this->conn_id);
}
// --------------------------------------------------------------------
/**
- * Version number query string
+ * Database version number
*
* @return string
*/
- protected function _version()
+ public function version()
{
- return 'SELECT version() AS ver';
+ return isset($this->data_cache['version'])
+ ? $this->data_cache['version']
+ : $this->data_cache['version'] = @mysql_get_server_info($this->conn_id);
}
// --------------------------------------------------------------------
@@ -287,18 +286,7 @@ class CI_DB_mysql_driver extends CI_DB {
return $str;
}
- if (function_exists('mysql_real_escape_string') && is_resource($this->conn_id))
- {
- $str = mysql_real_escape_string($str, $this->conn_id);
- }
- elseif (function_exists('mysql_escape_string'))
- {
- $str = mysql_escape_string($str);
- }
- else
- {
- $str = addslashes($str);
- }
+ $str = is_resource($this->conn_id) ? mysql_real_escape_string($str, $this->conn_id) : addslashes($str);
// escape LIKE condition wildcards
if ($like === TRUE)
@@ -402,40 +390,50 @@ class CI_DB_mysql_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * Field data query
- *
- * Generates a platform-specific query so that the column data can be retrieved
+ * Returns an object with field data
*
* @param string the table name
- * @return string
+ * @return object
*/
- public function _field_data($table)
+ public function field_data($table = '')
{
- return 'DESCRIBE '.$table;
- }
+ if ($table == '')
+ {
+ return ($this->db_debug) ? $this->display_error('db_field_param_missing') : FALSE;
+ }
- // --------------------------------------------------------------------
+ $query = $this->query('DESCRIBE '.$this->protect_identifiers($table, TRUE, NULL, FALSE));
+ $query = $query->result_object();
- /**
- * The error message string
- *
- * @return string
- */
- protected function _error_message()
- {
- return mysql_error($this->conn_id);
+ $retval = array();
+ for ($i = 0, $c = count($query); $i < $c; $i++)
+ {
+ preg_match('/([a-z]+)(\(\d+\))?/', $query[$i]->Type, $matches);
+
+ $retval[$i] = new stdClass();
+ $retval[$i]->name = $query[$i]->Field;
+ $retval[$i]->type = empty($matches[1]) ? NULL : $matches[1];
+ $retval[$i]->default = $query[$i]->Default;
+ $retval[$i]->max_length = empty($matches[2]) ? NULL : preg_replace('/[^\d]/', '', $matches[2]);
+ $retval[$i]->primary_key = (int) ($query[$i]->Key === 'PRI');
+ }
+
+ return $retval;
}
// --------------------------------------------------------------------
/**
- * The error message number
+ * Error
*
- * @return int
+ * Returns an array containing code and message of the last
+ * database error that has occured.
+ *
+ * @return array
*/
- protected function _error_number()
+ public function error()
{
- return mysql_errno($this->conn_id);
+ return array('code' => mysql_errno($this->conn_id), 'message' => mysql_error($this->conn_id));
}
// --------------------------------------------------------------------
diff --git a/system/database/drivers/mysql/mysql_forge.php b/system/database/drivers/mysql/mysql_forge.php
index 0f251b086..004a5a103 100644
--- a/system/database/drivers/mysql/mysql_forge.php
+++ b/system/database/drivers/mysql/mysql_forge.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
@@ -151,7 +151,7 @@ class CI_DB_mysql_forge extends CI_DB_forge {
if (count($primary_keys) > 0)
{
- $key_name = $this->db->_protect_identifiers(implode('_', $primary_keys));
+ $key_name = $this->db->protect_identifiers(implode('_', $primary_keys));
$sql .= ",\n\tPRIMARY KEY ".$key_name.' ('.implode(', ', $this->db->protect_identifiers($primary_keys)).')';
}
@@ -161,12 +161,12 @@ class CI_DB_mysql_forge extends CI_DB_forge {
{
if (is_array($key))
{
- $key_name = $this->db->_protect_identifiers(implode('_', $key));
- $key = $this->db->_protect_identifiers($key);
+ $key_name = $this->db->protect_identifiers(implode('_', $key));
+ $key = $this->db->protect_identifiers($key);
}
else
{
- $key_name = $this->db->_protect_identifiers($key);
+ $key_name = $this->db->protect_identifiers($key);
$key = array($key_name);
}
diff --git a/system/database/drivers/mysql/mysql_result.php b/system/database/drivers/mysql/mysql_result.php
index 8f04a936d..cec28dc2d 100644
--- a/system/database/drivers/mysql/mysql_result.php
+++ b/system/database/drivers/mysql/mysql_result.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
@@ -90,18 +90,14 @@ class CI_DB_mysql_result extends CI_DB_result {
public function field_data()
{
$retval = array();
- while ($field = mysql_fetch_object($this->result_id))
+ for ($i = 0, $c = $this->num_fields(); $i < $c; $i++)
{
- preg_match('/([a-zA-Z]+)(\(\d+\))?/', $field->Type, $matches);
-
- $F = new stdClass();
- $F->name = $field->Field;
- $F->type = ( ! empty($matches[1])) ? $matches[1] : NULL;
- $F->default = $field->Default;
- $F->max_length = ( ! empty($matches[2])) ? preg_replace('/[^\d]/', '', $matches[2]) : NULL;
- $F->primary_key = (int) ($field->Key === 'PRI');
-
- $retval[] = $F;
+ $retval[$i] = new stdClass();
+ $retval[$i]->name = mysql_field_name($this->result_id, $i);
+ $retval[$i]->type = mysql_field_type($this->result_id, $i);
+ $retval[$i]->max_length = mysql_field_len($this->result_id, $i);
+ $retval[$i]->primary_key = (strpos(mysql_field_flags($this->result_id, $i), 'primary_key') === FALSE) ? 0 : 1;
+ $retval[$i]->default = '';
}
return $retval;
diff --git a/system/database/drivers/mysql/mysql_utility.php b/system/database/drivers/mysql/mysql_utility.php
index 952f887fe..d716b004a 100644
--- a/system/database/drivers/mysql/mysql_utility.php
+++ b/system/database/drivers/mysql/mysql_utility.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php
index dbba12e15..f38b94c13 100644
--- a/system/database/drivers/mysqli/mysqli_driver.php
+++ b/system/database/drivers/mysqli/mysqli_driver.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
@@ -144,26 +144,25 @@ class CI_DB_mysqli_driver extends CI_DB {
* Set client character set
*
* @param string
- * @param string
* @return bool
*/
- protected function _db_set_charset($charset, $collation)
+ protected function _db_set_charset($charset)
{
- return function_exists('mysqli_set_charset')
- ? @mysqli_set_charset($this->conn_id, $charset)
- : @mysqli_query($this->conn_id, "SET NAMES '".$this->escape_str($charset)."' COLLATE '".$this->escape_str($collation)."'");
+ return @mysqli_set_charset($this->conn_id, $charset);
}
// --------------------------------------------------------------------
/**
- * Version number query string
+ * Database version number
*
* @return string
*/
- protected function _version()
+ public function version()
{
- return @mysqli_get_server_info($this->conn_id);
+ return isset($this->data_cache['version'])
+ ? $this->data_cache['version']
+ : $this->data_cache['version'] = @mysqli_get_server_info($this->conn_id);
}
// --------------------------------------------------------------------
@@ -287,18 +286,7 @@ class CI_DB_mysqli_driver extends CI_DB {
return $str;
}
- if (function_exists('mysqli_real_escape_string') && is_object($this->conn_id))
- {
- $str = mysqli_real_escape_string($this->conn_id, $str);
- }
- elseif (function_exists('mysql_escape_string'))
- {
- $str = mysql_escape_string($str);
- }
- else
- {
- $str = addslashes($str);
- }
+ $str = is_object($this->conn_id) ? mysqli_real_escape_string($this->conn_id, $str) : addslashes($str);
// escape LIKE condition wildcards
if ($like === TRUE)
@@ -351,7 +339,7 @@ class CI_DB_mysqli_driver extends CI_DB {
return 0;
}
- $query = $this->query($this->_count_string.$this->_protect_identifiers('numrows').' FROM '.$this->_protect_identifiers($table, TRUE, NULL, FALSE));
+ $query = $this->query($this->_count_string.$this->protect_identifiers('numrows').' FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE));
if ($query->num_rows() == 0)
{
return 0;
@@ -397,46 +385,56 @@ class CI_DB_mysqli_driver extends CI_DB {
*/
protected function _list_columns($table = '')
{
- return 'SHOW COLUMNS FROM '.$this->_protect_identifiers($table, TRUE, NULL, FALSE);
+ return 'SHOW COLUMNS FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE);
}
// --------------------------------------------------------------------
/**
- * Field data query
- *
- * Generates a platform-specific query so that the column data can be retrieved
+ * Returns an object with field data
*
* @param string the table name
- * @return string
+ * @return object
*/
- protected function _field_data($table)
+ public function field_data($table = '')
{
- return 'DESCRIBE '.$table;
- }
+ if ($table == '')
+ {
+ return ($this->db_debug) ? $this->display_error('db_field_param_missing') : FALSE;
+ }
- // --------------------------------------------------------------------
+ $query = $this->query('DESCRIBE '.$this->protect_identifiers($table, TRUE, NULL, FALSE));
+ $query = $query->result_object();
- /**
- * The error message string
- *
- * @return string
- */
- protected function _error_message()
- {
- return mysqli_error($this->conn_id);
+ $retval = array();
+ for ($i = 0, $c = count($query); $i < $c; $i++)
+ {
+ preg_match('/([a-z]+)(\(\d+\))?/', $query[$i]->Type, $matches);
+
+ $retval[$i] = new stdClass();
+ $retval[$i]->name = $query[$i]->Field;
+ $retval[$i]->type = empty($matches[1]) ? NULL : $matches[1];
+ $retval[$i]->default = $query[$i]->Default;
+ $retval[$i]->max_length = empty($matches[2]) ? NULL : preg_replace('/[^\d]/', '', $matches[2]);
+ $retval[$i]->primary_key = (int) ($query[$i]->Key === 'PRI');
+ }
+
+ return $retval;
}
// --------------------------------------------------------------------
/**
- * The error message number
+ * Error
*
- * @return int
+ * Returns an array containing code and message of the last
+ * database error that has occured.
+ *
+ * @return array
*/
- protected function _error_number()
+ public function error()
{
- return mysqli_errno($this->conn_id);
+ return array('code' => mysqli_errno($this->conn_id), 'message' => mysqli_error($this->conn_id));
}
// --------------------------------------------------------------------
diff --git a/system/database/drivers/mysqli/mysqli_forge.php b/system/database/drivers/mysqli/mysqli_forge.php
index 7de036127..9cb1a0c70 100644
--- a/system/database/drivers/mysqli/mysqli_forge.php
+++ b/system/database/drivers/mysqli/mysqli_forge.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
@@ -86,9 +86,32 @@ class CI_DB_mysqli_forge extends CI_DB_forge {
$sql .= "\n\t".$this->db->protect_identifiers($field)
.( ! empty($attributes['NAME']) ? ' '.$this->db->protect_identifiers($attributes['NAME']).' ' : '')
- .( ! empty($attributes['TYPE']) ? ' '.$attributes['TYPE'] : '')
- .( ! empty($attributes['CONSTRAINT']) ? '('.$attributes['CONSTRAINT'].')' : '')
- .(( ! empty($attributes['UNSIGNED']) && $attributes['UNSIGNED'] === TRUE) ? ' UNSIGNED' : '')
+ ;
+
+ if ( ! empty($attributes['TYPE']))
+ {
+ $sql .= ' '.$attributes['TYPE'];
+
+ if ( ! empty($attributes['CONSTRAINT']))
+ {
+ switch (strtolower($attributes['TYPE']))
+ {
+ case 'decimal':
+ case 'float':
+ case 'numeric':
+ $sql .= '('.implode(',', $attributes['CONSTRAINT']).')';
+ break;
+ case 'enum':
+ case 'set':
+ $sql .= '("'.implode('","', $attributes['CONSTRAINT']).'")';
+ break;
+ default:
+ $sql .= '('.$attributes['CONSTRAINT'].')';
+ }
+ }
+ }
+
+ $sql .= (( ! empty($attributes['UNSIGNED']) && $attributes['UNSIGNED'] === TRUE) ? ' UNSIGNED' : '')
.(isset($attributes['DEFAULT']) ? " DEFAULT '".$attributes['DEFAULT']."'" : '')
.(( ! empty($attributes['NULL']) && $attributes['NULL'] === TRUE) ? ' NULL' : ' NOT NULL')
.(( ! empty($attributes['AUTO_INCREMENT']) && $attributes['AUTO_INCREMENT'] === TRUE) ? ' AUTO_INCREMENT' : '');
@@ -183,7 +206,7 @@ class CI_DB_mysqli_forge extends CI_DB_forge {
*/
public function _alter_table($alter_type, $table, $fields, $after_field = '')
{
- $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table).' '.$alter_type.' ';
+ $sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' ';
// DROP has everything it needs now.
if ($alter_type === 'DROP')
diff --git a/system/database/drivers/mysqli/mysqli_result.php b/system/database/drivers/mysqli/mysqli_result.php
index 0a50cccac..f135f4d46 100644
--- a/system/database/drivers/mysqli/mysqli_result.php
+++ b/system/database/drivers/mysqli/mysqli_result.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
@@ -90,18 +90,15 @@ class CI_DB_mysqli_result extends CI_DB_result {
public function field_data()
{
$retval = array();
- while ($field = mysqli_fetch_object($this->result_id))
+ $field_data = mysqli_fetch_fields($this->result_id);
+ for ($i = 0, $c = count($field_data); $i < $c; $i++)
{
- preg_match('/([a-zA-Z]+)(\(\d+\))?/', $field->Type, $matches);
-
- $F = new stdClass();
- $F->name = $field->Field;
- $F->type = ( ! empty($matches[1])) ? $matches[1] : NULL;
- $F->default = $field->Default;
- $F->max_length = ( ! empty($matches[2])) ? preg_replace('/[^\d]/', '', $matches[2]) : NULL;
- $F->primary_key = (int) ($field->Key === 'PRI');
-
- $retval[] = $F;
+ $retval[$i] = new stdClass();
+ $retval[$i]->name = $field_data[$i]->name;
+ $retval[$i]->type = $field_data[$i]->type;
+ $retval[$i]->max_length = $field_data[$i]->max_length;
+ $retval[$i]->primary_key = (int) ($field_data[$i]->flags & 2);
+ $retval[$i]->default = '';
}
return $retval;
diff --git a/system/database/drivers/mysqli/mysqli_utility.php b/system/database/drivers/mysqli/mysqli_utility.php
index 3fdc5c723..650ddfd18 100644
--- a/system/database/drivers/mysqli/mysqli_utility.php
+++ b/system/database/drivers/mysqli/mysqli_utility.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php
index 6da6dc724..070d58a34 100644
--- a/system/database/drivers/oci8/oci8_driver.php
+++ b/system/database/drivers/oci8/oci8_driver.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
@@ -139,14 +139,15 @@ class CI_DB_oci8_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * Version number query string
+ * Database version number
*
- * @access protected
- * @return string
+ * @return string
*/
- protected function _version()
+ public function version()
{
- return oci_server_version($this->conn_id);
+ return isset($this->data_cache['version'])
+ ? $this->data_cache['version']
+ : $this->data_cache['version'] = oci_server_version($this->conn_id);
}
// --------------------------------------------------------------------
@@ -457,8 +458,7 @@ class CI_DB_oci8_driver extends CI_DB {
return 0;
}
- $query = $this->query($this->_count_string . $this->_protect_identifiers('numrows') . " FROM " . $this->_protect_identifiers($table, TRUE, NULL, FALSE));
-
+ $query = $this->query($this->_count_string.$this->protect_identifiers('numrows').' FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE));
if ($query == FALSE)
{
return 0;
@@ -527,39 +527,18 @@ class CI_DB_oci8_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * The error message string
+ * Error
*
- * @return string
- */
- protected function _error_message()
- {
- $error = $this->_oci8_error_data();
- return $error['message'];
- }
-
- // --------------------------------------------------------------------
-
- /**
- * The error message number
- *
- * @return string
- */
- protected function _error_number()
- {
- $error = $this->_oci8_error_data();
- return $error['code'];
- }
-
- // --------------------------------------------------------------------
-
- /**
- * OCI8-specific method to get errors.
- * Used by _error_message() and _error_code().
+ * Returns an array containing code and message of the last
+ * database error that has occured.
*
* @return array
*/
- protected function _oci8_error_data()
+ public function error()
{
+ /* oci_error() returns an array that already contains the
+ * 'code' and 'message' keys, so we can just return it.
+ */
if (is_resource($this->curs_id))
{
return oci_error($this->curs_id);
diff --git a/system/database/drivers/oci8/oci8_forge.php b/system/database/drivers/oci8/oci8_forge.php
index b4a24cdca..7fcc8094d 100644
--- a/system/database/drivers/oci8/oci8_forge.php
+++ b/system/database/drivers/oci8/oci8_forge.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
@@ -67,15 +67,14 @@ class CI_DB_oci8_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 ';
@@ -84,54 +83,27 @@ class CI_DB_oci8_forge extends CI_DB_forge {
$sql .= 'IF NOT EXISTS ';
}
- $sql .= $this->db->_escape_identifiers($table)." (";
+ $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
// entered the field information, so we'll simply add it to the list
if (is_numeric($field))
{
- $sql .= "\n\t$attributes";
+ $sql .= "\n\t".$attributes;
}
else
{
$attributes = array_change_key_case($attributes, CASE_UPPER);
- $sql .= "\n\t".$this->db->_protect_identifiers($field);
-
- $sql .= ' '.$attributes['TYPE'];
-
- if (array_key_exists('CONSTRAINT', $attributes))
- {
- $sql .= '('.$attributes['CONSTRAINT'].')';
- }
-
- if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE)
- {
- $sql .= ' UNSIGNED';
- }
-
- if (array_key_exists('DEFAULT', $attributes))
- {
- $sql .= ' DEFAULT \''.$attributes['DEFAULT'].'\'';
- }
-
- if (array_key_exists('NULL', $attributes) && $attributes['NULL'] === TRUE)
- {
- $sql .= ' NULL';
- }
- else
- {
- $sql .= ' NOT NULL';
- }
-
- if (array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE)
- {
- $sql .= ' AUTO_INCREMENT';
- }
+ $sql .= "\n\t".$this->db->protect_identifiers($field).' '.$attributes['TYPE']
+ .((isset($attributes['UNSINGED']) && $attributes['UNSIGNED'] === TRUE) ? ' UNSIGNED' : '')
+ .(isset($attributes['DEFAULT']) ? " DEFAULT '".$attributes['DEFAULT']."'" : '')
+ .((isset($attributes['NULL']) && $attributes['NULL'] === TRUE) ? '' : ' NOT NULL')
+ .(isset($attributes['CONSTRAINT']) ? ' CONSTRAINT '.$attributes['CONSTRAINT'] : '');
}
// don't add a comma on the end of the last field
@@ -143,8 +115,8 @@ class CI_DB_oci8_forge extends CI_DB_forge {
if (count($primary_keys) > 0)
{
- $primary_keys = $this->db->_protect_identifiers($primary_keys);
- $sql .= ",\n\tPRIMARY KEY (" . implode(', ', $primary_keys) . ")";
+ $primary_keys = $this->db->protect_identifiers($primary_keys);
+ $sql .= ",\n\tCONSTRAINT ".$table.' PRIMARY KEY ('.implode(', ', $primary_keys).')';
}
if (is_array($keys) && count($keys) > 0)
@@ -153,20 +125,18 @@ class CI_DB_oci8_forge extends CI_DB_forge {
{
if (is_array($key))
{
- $key = $this->db->_protect_identifiers($key);
+ $key = $this->db->protect_identifiers($key);
}
else
{
- $key = array($this->db->_protect_identifiers($key));
+ $key = array($this->db->protect_identifiers($key));
}
- $sql .= ",\n\tUNIQUE COLUMNS (" . implode(', ', $key) . ")";
+ $sql .= ",\n\tUNIQUE COLUMNS (".implode(', ', $key).")";
}
}
- $sql .= "\n)";
-
- return $sql;
+ return $sql."\n)";
}
// --------------------------------------------------------------------
@@ -202,7 +172,7 @@ class CI_DB_oci8_forge extends CI_DB_forge {
*/
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);
+ $sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '.$this->db->protect_identifiers($column_name);
// DROP has everything it needs now.
if ($alter_type == 'DROP')
@@ -228,7 +198,7 @@ class CI_DB_oci8_forge extends CI_DB_forge {
if ($after_field != '')
{
- $sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field);
+ return $sql.' AFTER '.$this->db->protect_identifiers($after_field);
}
return $sql;
@@ -249,12 +219,10 @@ class CI_DB_oci8_forge extends CI_DB_forge {
*/
function _rename_table($table_name, $new_table_name)
{
- $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table_name)." RENAME TO ".$this->db->_protect_identifiers($new_table_name);
- return $sql;
+ return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name);
}
-
}
/* End of file oci8_forge.php */
-/* Location: ./system/database/drivers/oci8/oci8_forge.php */ \ No newline at end of file
+/* Location: ./system/database/drivers/oci8/oci8_forge.php */
diff --git a/system/database/drivers/oci8/oci8_result.php b/system/database/drivers/oci8/oci8_result.php
index 0f69fa9ef..6f1b8b4c1 100644
--- a/system/database/drivers/oci8/oci8_result.php
+++ b/system/database/drivers/oci8/oci8_result.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
@@ -38,9 +38,18 @@
*/
class CI_DB_oci8_result extends CI_DB_result {
- var $stmt_id;
- var $curs_id;
- var $limit_used;
+ public $stmt_id;
+ public $curs_id;
+ public $limit_used;
+
+ public function __construct(&$driver_object)
+ {
+ parent::__construct($driver_object);
+ $this->stmt_id = $driver_object->stmt_id;
+ $this->curs_id = $driver_object->curs_id;
+ $this->limit_used = $driver_object->limit_used;
+ $driver_object->stmt_id = FALSE;
+ }
/**
* Number of rows in the result set.
diff --git a/system/database/drivers/oci8/oci8_utility.php b/system/database/drivers/oci8/oci8_utility.php
index d60f98bc4..62dfb2f3c 100644
--- a/system/database/drivers/oci8/oci8_utility.php
+++ b/system/database/drivers/oci8/oci8_utility.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/database/drivers/odbc/odbc_driver.php b/system/database/drivers/odbc/odbc_driver.php
index abb660324..acc2838e3 100644
--- a/system/database/drivers/odbc/odbc_driver.php
+++ b/system/database/drivers/odbc/odbc_driver.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
@@ -124,19 +124,6 @@ class CI_DB_odbc_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * Version number query string
- *
- * @access public
- * @return string
- */
- function _version()
- {
- return "SELECT version() AS ver";
- }
-
- // --------------------------------------------------------------------
-
- /**
* Execute the query
*
* @access private called by the base class
@@ -300,12 +287,11 @@ class CI_DB_odbc_driver extends CI_DB {
/**
* Insert ID
*
- * @access public
- * @return integer
+ * @return bool
*/
- function insert_id()
+ public function insert_id()
{
- return @odbc_insert_id($this->conn_id);
+ return ($this->db->db_debug) ? $this->db->display_error('db_unsuported_feature') : FALSE;
}
// --------------------------------------------------------------------
@@ -327,7 +313,7 @@ class CI_DB_odbc_driver extends CI_DB {
return 0;
}
- $query = $this->query($this->_count_string . $this->_protect_identifiers('numrows') . " FROM " . $this->_protect_identifiers($table, TRUE, NULL, FALSE));
+ $query = $this->query($this->_count_string . $this->protect_identifiers('numrows') . " FROM " . $this->protect_identifiers($table, TRUE, NULL, FALSE));
if ($query->num_rows() == 0)
{
@@ -398,27 +384,16 @@ class CI_DB_odbc_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * The error message string
+ * Error
*
- * @access private
- * @return string
- */
- function _error_message()
- {
- return odbc_errormsg($this->conn_id);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * The error message number
+ * Returns an array containing code and message of the last
+ * database error that has occured.
*
- * @access private
- * @return integer
+ * @return array
*/
- function _error_number()
+ public function error()
{
- return odbc_error($this->conn_id);
+ return array('code' => odbc_error($this->conn_id), 'message' => odbc_errormsg($this->conn_id));
}
// --------------------------------------------------------------------
diff --git a/system/database/drivers/odbc/odbc_forge.php b/system/database/drivers/odbc/odbc_forge.php
index e0ec687c8..acc2cadee 100644
--- a/system/database/drivers/odbc/odbc_forge.php
+++ b/system/database/drivers/odbc/odbc_forge.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
@@ -112,7 +112,7 @@ class CI_DB_odbc_forge extends CI_DB_forge {
{
$attributes = array_change_key_case($attributes, CASE_UPPER);
- $sql .= "\n\t".$this->db->_protect_identifiers($field);
+ $sql .= "\n\t".$this->db->protect_identifiers($field);
$sql .= ' '.$attributes['TYPE'];
@@ -155,7 +155,7 @@ class CI_DB_odbc_forge extends CI_DB_forge {
if (count($primary_keys) > 0)
{
- $primary_keys = $this->db->_protect_identifiers($primary_keys);
+ $primary_keys = $this->db->protect_identifiers($primary_keys);
$sql .= ",\n\tPRIMARY KEY (" . implode(', ', $primary_keys) . ")";
}
@@ -165,11 +165,11 @@ class CI_DB_odbc_forge extends CI_DB_forge {
{
if (is_array($key))
{
- $key = $this->db->_protect_identifiers($key);
+ $key = $this->db->protect_identifiers($key);
}
else
{
- $key = array($this->db->_protect_identifiers($key));
+ $key = array($this->db->protect_identifiers($key));
}
$sql .= ",\n\tFOREIGN KEY (" . implode(', ', $key) . ")";
@@ -219,7 +219,7 @@ class CI_DB_odbc_forge extends CI_DB_forge {
*/
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);
+ $sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '.$this->db->protect_identifiers($column_name);
// DROP has everything it needs now.
if ($alter_type == 'DROP')
@@ -245,7 +245,7 @@ class CI_DB_odbc_forge extends CI_DB_forge {
if ($after_field != '')
{
- $sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field);
+ return $sql.' AFTER '.$this->db->protect_identifiers($after_field);
}
return $sql;
@@ -267,12 +267,10 @@ class CI_DB_odbc_forge extends CI_DB_forge {
*/
function _rename_table($table_name, $new_table_name)
{
- $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table_name)." RENAME TO ".$this->db->_protect_identifiers($new_table_name);
- return $sql;
+ return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name);
}
-
}
/* End of file odbc_forge.php */
-/* Location: ./system/database/drivers/odbc/odbc_forge.php */ \ No newline at end of file
+/* Location: ./system/database/drivers/odbc/odbc_forge.php */
diff --git a/system/database/drivers/odbc/odbc_result.php b/system/database/drivers/odbc/odbc_result.php
index 572e110ca..d19fa247e 100644
--- a/system/database/drivers/odbc/odbc_result.php
+++ b/system/database/drivers/odbc/odbc_result.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
@@ -245,8 +245,77 @@ class CI_DB_odbc_result extends CI_DB_result {
return $rs_assoc;
}
-}
+ // --------------------------------------------------------------------
+
+ /**
+ * Query result. Array version.
+ *
+ * @return array
+ */
+ public function result_array()
+ {
+ if (count($this->result_array) > 0)
+ {
+ return $this->result_array;
+ }
+ elseif (($c = count($this->result_object)) > 0)
+ {
+ for ($i = 0; $i < $c; $i++)
+ {
+ $this->result_array[$i] = (array) $this->result_object[$i];
+ }
+ }
+ elseif ($this->result_id === FALSE)
+ {
+ return array();
+ }
+ else
+ {
+ while ($row = $this->_fetch_assoc())
+ {
+ $this->result_array[] = $row;
+ }
+ }
+ return $this->result_array;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Query result. Object version.
+ *
+ * @return array
+ */
+ public function result_object()
+ {
+ if (count($this->result_object) > 0)
+ {
+ return $this->result_object;
+ }
+ elseif (($c = count($this->result_array)) > 0)
+ {
+ for ($i = 0; $i < $c; $i++)
+ {
+ $this->result_object[$i] = (object) $this->result_array[$i];
+ }
+ }
+ elseif ($this->result_id === FALSE)
+ {
+ return array();
+ }
+ else
+ {
+ while ($row = $this->_fetch_object())
+ {
+ $this->result_object[] = $row;
+ }
+ }
+
+ return $this->result_object;
+ }
+
+}
/* End of file odbc_result.php */
/* Location: ./system/database/drivers/odbc/odbc_result.php */
diff --git a/system/database/drivers/odbc/odbc_utility.php b/system/database/drivers/odbc/odbc_utility.php
index bae3fe853..c146c1785 100644
--- a/system/database/drivers/odbc/odbc_utility.php
+++ b/system/database/drivers/odbc/odbc_utility.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php
index 90f0fd791..09764779a 100644
--- a/system/database/drivers/pdo/pdo_driver.php
+++ b/system/database/drivers/pdo/pdo_driver.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
@@ -59,8 +59,7 @@ class CI_DB_pdo_driver extends CI_DB {
var $_count_string = "SELECT COUNT(*) AS ";
var $_random_keyword;
- // need to track the pdo DSN, driver and options
- var $dsn;
+ // need to track the pdo driver and options
var $pdodriver;
var $options = array();
@@ -289,13 +288,15 @@ class CI_DB_pdo_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * Version number query string
+ * Database version number
*
* @return string
*/
- protected function _version()
+ public function version()
{
- return $this->conn_id->getAttribute(PDO::ATTR_SERVER_VERSION);
+ return isset($this->data_cache['version'])
+ ? $this->data_cache['version']
+ : $this->data_cache['version'] = $this->conn_id->getAttribute(PDO::ATTR_SERVER_VERSION);
}
// --------------------------------------------------------------------
@@ -499,7 +500,7 @@ class CI_DB_pdo_driver extends CI_DB {
*/
public function insert_id($name = NULL)
{
- if ($this->pdodriver === 'pgsql' && $name === NULL && $this->_version() >= '8.1')
+ if ($this->pdodriver === 'pgsql' && $name === NULL && $this->version() >= '8.1')
{
$query = $this->query('SELECT LASTVAL() AS ins_id');
$query = $query->row();
@@ -528,8 +529,7 @@ class CI_DB_pdo_driver extends CI_DB {
return 0;
}
- $sql = $this->_count_string.$this->_protect_identifiers('numrows').' FROM ';
- $sql .= $this->_protect_identifiers($table, TRUE, NULL, FALSE);
+ $sql = $this->_count_string.$this->protect_identifiers('numrows').' FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE);
$query = $this->query($sql);
if ($query->num_rows() == 0)
@@ -609,29 +609,30 @@ class CI_DB_pdo_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * The error message string
+ * Error
*
- * @access private
- * @return string
+ * Returns an array containing code and message of the last
+ * database error that has occured.
+ *
+ * @return array
*/
- function _error_message()
+ public function error()
{
- $error_array = $this->conn_id->errorInfo();
+ $error = array('code' => '00000', 'message' => '');
+ $pdo_error = $this->conn_id->errorInfo();
- return $error_array[2];
- }
+ if (empty($pdo_error[0]))
+ {
+ return $error;
+ }
- // --------------------------------------------------------------------
+ $error['code'] = isset($pdo_error[1]) ? $pdo_error[0].'/'.$pdo_error[1] : $pdo_error[0];
+ if (isset($pdo_error[2]))
+ {
+ $error['message'] = $pdo_error[2];
+ }
- /**
- * The error message number
- *
- * @access private
- * @return integer
- */
- function _error_number()
- {
- return $this->conn_id->errorCode();
+ return $error;
}
// --------------------------------------------------------------------
diff --git a/system/database/drivers/pdo/pdo_forge.php b/system/database/drivers/pdo/pdo_forge.php
index 478b2dbfb..87b638570 100644
--- a/system/database/drivers/pdo/pdo_forge.php
+++ b/system/database/drivers/pdo/pdo_forge.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
@@ -113,7 +113,7 @@ class CI_DB_pdo_forge extends CI_DB_forge {
$attributes = array_change_key_case($attributes, CASE_UPPER);
$numeric = array('SERIAL', 'INTEGER');
- $sql .= "\n\t".$this->db->_protect_identifiers($field);
+ $sql .= "\n\t".$this->db->protect_identifiers($field);
$sql .= ' '.$attributes['TYPE'];
@@ -160,7 +160,7 @@ class CI_DB_pdo_forge extends CI_DB_forge {
if (count($primary_keys) > 0)
{
- $primary_keys = $this->db->_protect_identifiers($primary_keys);
+ $primary_keys = $this->db->protect_identifiers($primary_keys);
$sql .= ",\n\tPRIMARY KEY (" . implode(', ', $primary_keys) . ")";
}
@@ -170,11 +170,11 @@ class CI_DB_pdo_forge extends CI_DB_forge {
{
if (is_array($key))
{
- $key = $this->db->_protect_identifiers($key);
+ $key = $this->db->protect_identifiers($key);
}
else
{
- $key = array($this->db->_protect_identifiers($key));
+ $key = array($this->db->protect_identifiers($key));
}
$sql .= ",\n\tFOREIGN KEY (" . implode(', ', $key) . ")";
@@ -224,7 +224,7 @@ class CI_DB_pdo_forge extends CI_DB_forge {
*/
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);
+ $sql = 'ALTER TABLE `'.$this->db->protect_identifiers($table).'` '.$alter_type.' '.$this->db->protect_identifiers($column_name);
// DROP has everything it needs now.
if ($alter_type == 'DROP')
@@ -250,7 +250,7 @@ class CI_DB_pdo_forge extends CI_DB_forge {
if ($after_field != '')
{
- $sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field);
+ return $sql.' AFTER '.$this->db->protect_identifiers($after_field);
}
return $sql;
@@ -272,11 +272,10 @@ class CI_DB_pdo_forge extends CI_DB_forge {
*/
function _rename_table($table_name, $new_table_name)
{
- $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table_name)." RENAME TO ".$this->db->_protect_identifiers($new_table_name);
- return $sql;
+ return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name);
}
}
/* End of file pdo_forge.php */
-/* Location: ./system/database/drivers/pdo/pdo_forge.php */ \ No newline at end of file
+/* Location: ./system/database/drivers/pdo/pdo_forge.php */
diff --git a/system/database/drivers/pdo/pdo_result.php b/system/database/drivers/pdo/pdo_result.php
index c333abc40..309f1947d 100644
--- a/system/database/drivers/pdo/pdo_result.php
+++ b/system/database/drivers/pdo/pdo_result.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/database/drivers/pdo/pdo_utility.php b/system/database/drivers/pdo/pdo_utility.php
index 971ec8803..c278c5172 100644
--- a/system/database/drivers/pdo/pdo_utility.php
+++ b/system/database/drivers/pdo/pdo_utility.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php
index 89541e5fa..5d22af2e6 100644
--- a/system/database/drivers/postgre/postgre_driver.php
+++ b/system/database/drivers/postgre/postgre_driver.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
@@ -147,14 +147,43 @@ class CI_DB_postgre_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * Version number query string
+ * Set client character set
+ *
+ * @param string
+ * @return bool
+ */
+ protected function _db_set_charset($charset)
+ {
+ return (pg_set_client_encoding($this->conn_id, $charset) === 0);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Database version number
*
- * @access public
* @return string
*/
- function _version()
+ public function version()
{
- return "SELECT version() AS ver";
+ if (isset($this->data_cache['version']))
+ {
+ return $this->data_cache['version'];
+ }
+
+ if (($pg_version = pg_version($this->conn_id)) === FALSE)
+ {
+ return FALSE;
+ }
+
+ /* If PHP was compiled with PostgreSQL lib versions earlier
+ * than 7.4, pg_version() won't return the server version
+ * and so we'll have to fall back to running a query in
+ * order to get it.
+ */
+ return isset($pg_version['server'])
+ ? $this->data_cache['version'] = $pg_version['server']
+ : parent::version();
}
// --------------------------------------------------------------------
@@ -193,18 +222,12 @@ class CI_DB_postgre_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)
- {
- 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;
}
@@ -212,9 +235,9 @@ class CI_DB_postgre_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);
- return @pg_exec($this->conn_id, "begin");
+ return @pg_query($this->conn_id, 'BEGIN');
}
// --------------------------------------------------------------------
@@ -222,23 +245,17 @@ class CI_DB_postgre_driver extends CI_DB {
/**
* Commit Transaction
*
- * @access public
* @return bool
*/
- function trans_commit()
+ 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;
}
- return @pg_exec($this->conn_id, "commit");
+ return @pg_query($this->conn_id, 'COMMIT');
}
// --------------------------------------------------------------------
@@ -246,23 +263,17 @@ class CI_DB_postgre_driver extends CI_DB {
/**
* Rollback Transaction
*
- * @access public
* @return bool
*/
- function trans_rollback()
+ 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;
}
- return @pg_exec($this->conn_id, "rollback");
+ return @pg_query($this->conn_id, 'ROLLBACK');
}
// --------------------------------------------------------------------
@@ -323,8 +334,7 @@ class CI_DB_postgre_driver extends CI_DB {
*/
function insert_id()
{
- $v = $this->_version();
- $v = $v['server'];
+ $v = $this->version();
$table = func_num_args() > 0 ? func_get_arg(0) : NULL;
$column = func_num_args() > 1 ? func_get_arg(1) : NULL;
@@ -373,8 +383,7 @@ class CI_DB_postgre_driver extends CI_DB {
return 0;
}
- $query = $this->query($this->_count_string . $this->_protect_identifiers('numrows') . " FROM " . $this->_protect_identifiers($table, TRUE, NULL, FALSE));
-
+ $query = $this->query($this->_count_string.$this->protect_identifiers('numrows').' FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE));
if ($query->num_rows() == 0)
{
return 0;
@@ -443,27 +452,16 @@ class CI_DB_postgre_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * The error message string
+ * Error
*
- * @access private
- * @return string
- */
- function _error_message()
- {
- return pg_last_error($this->conn_id);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * The error message number
+ * Returns an array containing code and message of the last
+ * database error that has occured.
*
- * @access private
- * @return integer
+ * @return array
*/
- function _error_number()
+ public function error()
{
- return '';
+ return array('code' => '', 'message' => pg_last_error($this->conn_id));
}
// --------------------------------------------------------------------
@@ -588,16 +586,10 @@ class CI_DB_postgre_driver extends CI_DB {
$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.$limit;
-
return $sql;
}
@@ -648,9 +640,7 @@ class CI_DB_postgre_driver extends CI_DB {
$conditions .= implode("\n", $like);
}
- $limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
-
- return "DELETE FROM ".$table.$conditions.$limit;
+ return "DELETE FROM ".$table.$conditions;
}
// --------------------------------------------------------------------
diff --git a/system/database/drivers/postgre/postgre_forge.php b/system/database/drivers/postgre/postgre_forge.php
index 756fd347a..577100544 100644
--- a/system/database/drivers/postgre/postgre_forge.php
+++ b/system/database/drivers/postgre/postgre_forge.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
@@ -88,7 +88,7 @@ class CI_DB_postgre_forge extends CI_DB_forge {
{
$attributes = array_change_key_case($attributes, CASE_UPPER);
- $sql .= "\n\t".$this->db->_protect_identifiers($field);
+ $sql .= "\n\t".$this->db->protect_identifiers($field);
$is_unsigned = (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE);
@@ -203,10 +203,10 @@ class CI_DB_postgre_forge extends CI_DB_forge {
if (count($primary_keys) > 0)
{
- // Something seems to break when passing an array to _protect_identifiers()
+ // Something seems to break when passing an array to protect_identifiers()
foreach ($primary_keys as $index => $key)
{
- $primary_keys[$index] = $this->db->_protect_identifiers($key);
+ $primary_keys[$index] = $this->db->protect_identifiers($key);
}
$sql .= ",\n\tPRIMARY KEY (" . implode(', ', $primary_keys) . ")";
@@ -220,11 +220,11 @@ class CI_DB_postgre_forge extends CI_DB_forge {
{
if (is_array($key))
{
- $key = $this->db->_protect_identifiers($key);
+ $key = $this->db->protect_identifiers($key);
}
else
{
- $key = array($this->db->_protect_identifiers($key));
+ $key = array($this->db->protect_identifiers($key));
}
foreach ($key as $field)
@@ -267,19 +267,19 @@ class CI_DB_postgre_forge extends CI_DB_forge {
*/
function _alter_table($alter_type, $table, $fields, $after_field = '')
{
- $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table)." $alter_type ";
+ $sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' ';
// DROP has everything it needs now.
if ($alter_type == 'DROP')
{
- return $sql.$this->db->_protect_identifiers($fields);
+ return $sql.$this->db->protect_identifiers($fields);
}
$sql .= $this->_process_fields($fields);
if ($after_field != '')
{
- $sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field);
+ return $sql.' AFTER '.$this->db->protect_identifiers($after_field);
}
return $sql;
@@ -299,10 +299,9 @@ class CI_DB_postgre_forge extends CI_DB_forge {
*/
function _rename_table($table_name, $new_table_name)
{
- $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table_name)." RENAME TO ".$this->db->_protect_identifiers($new_table_name);
- return $sql;
+ return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name);
}
}
/* End of file postgre_forge.php */
-/* Location: ./system/database/drivers/postgre/postgre_forge.php */ \ No newline at end of file
+/* Location: ./system/database/drivers/postgre/postgre_forge.php */
diff --git a/system/database/drivers/postgre/postgre_result.php b/system/database/drivers/postgre/postgre_result.php
index 9161bf955..12d7547c5 100644
--- a/system/database/drivers/postgre/postgre_result.php
+++ b/system/database/drivers/postgre/postgre_result.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/database/drivers/postgre/postgre_utility.php b/system/database/drivers/postgre/postgre_utility.php
index dffd8c549..e31a6db8f 100644
--- a/system/database/drivers/postgre/postgre_utility.php
+++ b/system/database/drivers/postgre/postgre_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.1.6 or newer
+ * 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 Utility Class
*
@@ -39,12 +37,11 @@ class CI_DB_postgre_utility extends CI_DB_utility {
/**
* List databases
*
- * @access private
- * @return bool
+ * @return string
*/
- function _list_databases()
+ public function _list_databases()
{
- return "SELECT datname FROM pg_database";
+ return 'SELECT datname FROM pg_database';
}
// --------------------------------------------------------------------
@@ -52,15 +49,12 @@ class CI_DB_postgre_utility extends CI_DB_utility {
/**
* Optimize table query
*
- * Is table optimization supported in Postgre?
- *
- * @access private
* @param string the table name
- * @return object
+ * @return string
*/
- function _optimize_table($table)
+ public function _optimize_table($table)
{
- return FALSE;
+ return 'REINDEX TABLE '.$this->db->protect_identifiers($table);
}
// --------------------------------------------------------------------
@@ -68,13 +62,10 @@ class CI_DB_postgre_utility extends CI_DB_utility {
/**
* Repair table query
*
- * Are table repairs supported in Postgre?
- *
- * @access private
* @param string the table name
- * @return object
+ * @return bool
*/
- function _repair_table($table)
+ public function _repair_table($table)
{
return FALSE;
}
@@ -84,7 +75,6 @@ class CI_DB_postgre_utility extends CI_DB_utility {
/**
* Postgre Export
*
- * @access private
* @param array Preferences
* @return mixed
*/
@@ -95,6 +85,5 @@ class CI_DB_postgre_utility extends CI_DB_utility {
}
}
-
/* End of file postgre_utility.php */
-/* Location: ./system/database/drivers/postgre/postgre_utility.php */ \ No newline at end of file
+/* Location: ./system/database/drivers/postgre/postgre_utility.php */
diff --git a/system/database/drivers/sqlite/sqlite_driver.php b/system/database/drivers/sqlite/sqlite_driver.php
index 718501b20..55d9bfdb8 100644
--- a/system/database/drivers/sqlite/sqlite_driver.php
+++ b/system/database/drivers/sqlite/sqlite_driver.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
@@ -141,14 +141,15 @@ class CI_DB_sqlite_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * Version number query string
+ * Database version number
*
- * @access public
* @return string
*/
- function _version()
+ public function version()
{
- return sqlite_libversion();
+ return isset($this->data_cache['version'])
+ ? $this->data_cache['version']
+ : $this->data_cache['version'] = sqlite_libversion();
}
// --------------------------------------------------------------------
@@ -342,8 +343,7 @@ class CI_DB_sqlite_driver extends CI_DB {
return 0;
}
- $query = $this->query($this->_count_string . $this->_protect_identifiers('numrows') . " FROM " . $this->_protect_identifiers($table, TRUE, NULL, FALSE));
-
+ $query = $this->query($this->_count_string.$this->protect_identifiers('numrows').' FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE));
if ($query->num_rows() == 0)
{
return 0;
@@ -412,27 +412,18 @@ class CI_DB_sqlite_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * The error message string
+ * Error
*
- * @access private
- * @return string
- */
- function _error_message()
- {
- return sqlite_error_string(sqlite_last_error($this->conn_id));
- }
-
- // --------------------------------------------------------------------
-
- /**
- * The error message number
+ * Returns an array containing code and message of the last
+ * database error that has occured.
*
- * @access private
- * @return integer
+ * @return array
*/
- function _error_number()
+ public function error()
{
- return sqlite_last_error($this->conn_id);
+ $error = array('code' => sqlite_last_error($this->conn_id));
+ $error['message'] = sqlite_error_string($error['code']);
+ return $error;
}
// --------------------------------------------------------------------
diff --git a/system/database/drivers/sqlite/sqlite_forge.php b/system/database/drivers/sqlite/sqlite_forge.php
index 2b723be0b..7fc531463 100644
--- a/system/database/drivers/sqlite/sqlite_forge.php
+++ b/system/database/drivers/sqlite/sqlite_forge.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
@@ -89,7 +89,7 @@ class CI_DB_sqlite_forge extends CI_DB_forge {
$sql = 'CREATE TABLE ';
// IF NOT EXISTS added to SQLite in 3.3.0
- if ($if_not_exists === TRUE && version_compare($this->db->_version(), '3.3.0', '>=') === TRUE)
+ if ($if_not_exists === TRUE && version_compare($this->db->version(), '3.3.0', '>=') === TRUE)
{
$sql .= 'IF NOT EXISTS ';
}
@@ -110,7 +110,7 @@ class CI_DB_sqlite_forge extends CI_DB_forge {
{
$attributes = array_change_key_case($attributes, CASE_UPPER);
- $sql .= "\n\t".$this->db->_protect_identifiers($field);
+ $sql .= "\n\t".$this->db->protect_identifiers($field);
$sql .= ' '.$attributes['TYPE'];
@@ -153,7 +153,7 @@ class CI_DB_sqlite_forge extends CI_DB_forge {
if (count($primary_keys) > 0)
{
- $primary_keys = $this->db->_protect_identifiers($primary_keys);
+ $primary_keys = $this->db->protect_identifiers($primary_keys);
$sql .= ",\n\tPRIMARY KEY (" . implode(', ', $primary_keys) . ")";
}
@@ -163,11 +163,11 @@ class CI_DB_sqlite_forge extends CI_DB_forge {
{
if (is_array($key))
{
- $key = $this->db->_protect_identifiers($key);
+ $key = $this->db->protect_identifiers($key);
}
else
{
- $key = array($this->db->_protect_identifiers($key));
+ $key = array($this->db->protect_identifiers($key));
}
$sql .= ",\n\tUNIQUE (" . implode(', ', $key) . ")";
@@ -218,7 +218,7 @@ class CI_DB_sqlite_forge extends CI_DB_forge {
*/
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);
+ $sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '.$this->db->protect_identifiers($column_name);
// DROP has everything it needs now.
if ($alter_type == 'DROP')
@@ -247,7 +247,7 @@ class CI_DB_sqlite_forge extends CI_DB_forge {
if ($after_field != '')
{
- $sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field);
+ return $sql.' AFTER '.$this->db->protect_identifiers($after_field);
}
return $sql;
@@ -268,10 +268,10 @@ class CI_DB_sqlite_forge extends CI_DB_forge {
*/
function _rename_table($table_name, $new_table_name)
{
- $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table_name)." RENAME TO ".$this->db->_protect_identifiers($new_table_name);
- return $sql;
+ return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name);
}
+
}
/* End of file sqlite_forge.php */
-/* Location: ./system/database/drivers/sqlite/sqlite_forge.php */ \ No newline at end of file
+/* Location: ./system/database/drivers/sqlite/sqlite_forge.php */
diff --git a/system/database/drivers/sqlite/sqlite_result.php b/system/database/drivers/sqlite/sqlite_result.php
index 74c0dc549..ac2235cbc 100644
--- a/system/database/drivers/sqlite/sqlite_result.php
+++ b/system/database/drivers/sqlite/sqlite_result.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/database/drivers/sqlite/sqlite_utility.php b/system/database/drivers/sqlite/sqlite_utility.php
index f00687e38..9f9ddca44 100644
--- a/system/database/drivers/sqlite/sqlite_utility.php
+++ b/system/database/drivers/sqlite/sqlite_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.1.6 or newer
+ * 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 Utility Class
*
@@ -40,20 +38,15 @@ class CI_DB_sqlite_utility extends CI_DB_utility {
* List databases
*
* I don't believe you can do a database listing with SQLite
- * since each database is its own file. I suppose we could
+ * since each database is its own file. I suppose we could
* try reading a directory looking for SQLite files, but
* that doesn't seem like a terribly good idea
*
- * @access private
* @return bool
*/
- function _list_databases()
+ public function _list_databases()
{
- if ($this->db_debug)
- {
- return $this->db->display_error('db_unsuported_feature');
- }
- return array();
+ return ($this->db_debug) ? $this->db->display_error('db_unsuported_feature') : FALSE;
}
// --------------------------------------------------------------------
@@ -61,14 +54,12 @@ class CI_DB_sqlite_utility extends CI_DB_utility {
/**
* Optimize table query
*
- * Is optimization even supported in SQLite?
- *
- * @access private
* @param string the table name
- * @return object
+ * @return bool
*/
- function _optimize_table($table)
+ public function _optimize_table($table)
{
+ // Not supported
return FALSE;
}
@@ -77,14 +68,12 @@ class CI_DB_sqlite_utility extends CI_DB_utility {
/**
* Repair table query
*
- * Are table repairs even supported in SQLite?
- *
- * @access private
* @param string the table name
- * @return object
+ * @return bool
*/
- function _repair_table($table)
+ public function _repair_table($table)
{
+ // Not supported
return FALSE;
}
@@ -93,16 +82,16 @@ class CI_DB_sqlite_utility extends CI_DB_utility {
/**
* SQLite 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 sqlite_utility.php */
-/* Location: ./system/database/drivers/sqlite/sqlite_utility.php */ \ No newline at end of file
+/* Location: ./system/database/drivers/sqlite/sqlite_utility.php */
diff --git a/system/database/drivers/sqlsrv/sqlsrv_driver.php b/system/database/drivers/sqlsrv/sqlsrv_driver.php
index 9b9038189..5e920cbe8 100644
--- a/system/database/drivers/sqlsrv/sqlsrv_driver.php
+++ b/system/database/drivers/sqlsrv/sqlsrv_driver.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
@@ -317,15 +317,23 @@ class CI_DB_sqlsrv_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * Version number query string
- *
- * @access public
- * @return string
- */
- function _version()
+ * Database version number
+ *
+ * @return string
+ */
+ public function version()
{
- $info = sqlsrv_server_info($this->conn_id);
- return sprintf("select '%s' as ver", $info['SQLServerVersion']);
+ if (isset($this->data_cache['version']))
+ {
+ return $this->data_cache['version'];
+ }
+
+ if (($info = sqlsrv_server_info($this->conn_id)) === FALSE)
+ {
+ return FALSE;
+ }
+
+ return $this->data_cache['version'] = $info['SQLServerVersion'];
}
// --------------------------------------------------------------------
@@ -406,46 +414,39 @@ class CI_DB_sqlsrv_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * The error message string
+ * Error
*
- * @return string
+ * Returns an array containing code and message of the last
+ * database error that has occured.
+ *
+ * @return array
*/
- protected function _error_message()
+ public function error()
{
- $error = sqlsrv_errors();
- if ( ! is_array($error))
+ $error = array('code' => '00000', 'message' => '');
+ $sqlsrv_errors = sqlsrv_errors(SQLSRV_ERR_ERRORS);
+
+ if ( ! is_array($sqlsrv_errors))
{
- return '';
+ return $error;
}
- $error = array_shift($error);
- return isset($error['message']) ? $error['message'] : '';
- }
-
- // --------------------------------------------------------------------
-
- /**
- * The error message number
- *
- * @return string
- */
- protected function _error_number()
- {
- $error = sqlsrv_errors();
- if ( ! is_array($error))
+ $sqlsrv_error = array_shift($sqlsrv_errors);
+ if (isset($sqlsrv_error['SQLSTATE']))
{
- return '';
+ $error['code'] = isset($sqlsrv_error['code']) ? $sqlsrv_error['SQLSTATE'].'/'.$sqlsrv_error['code'] : $sqlsrv_error['SQLSTATE'];
}
- elseif (isset($error['SQLSTATE']))
+ elseif (isset($sqlsrv_error['code']))
{
- return isset($error['code']) ? $error['SQLSTATE'].'/'.$error['code'] : $error['SQLSTATE'];
+ $error['code'] = $sqlsrv_error['code'];
}
- elseif (isset($error['code']))
+
+ if (isset($sqlsrv_error['message']))
{
- return $error['code'];
+ $error['message'] = $sqlsrv_error['message'];
}
- return '';
+ return $error;
}
// --------------------------------------------------------------------
diff --git a/system/database/drivers/sqlsrv/sqlsrv_forge.php b/system/database/drivers/sqlsrv/sqlsrv_forge.php
index 2a7766927..cd061dd23 100644
--- a/system/database/drivers/sqlsrv/sqlsrv_forge.php
+++ b/system/database/drivers/sqlsrv/sqlsrv_forge.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
@@ -113,7 +113,7 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge {
{
$attributes = array_change_key_case($attributes, CASE_UPPER);
- $sql .= "\n\t".$this->db->_protect_identifiers($field);
+ $sql .= "\n\t".$this->db->protect_identifiers($field);
$sql .= ' '.$attributes['TYPE'];
@@ -156,7 +156,7 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge {
if (count($primary_keys) > 0)
{
- $primary_keys = $this->db->_protect_identifiers($primary_keys);
+ $primary_keys = $this->db->protect_identifiers($primary_keys);
$sql .= ",\n\tPRIMARY KEY (" . implode(', ', $primary_keys) . ")";
}
@@ -166,11 +166,11 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge {
{
if (is_array($key))
{
- $key = $this->db->_protect_identifiers($key);
+ $key = $this->db->protect_identifiers($key);
}
else
{
- $key = array($this->db->_protect_identifiers($key));
+ $key = array($this->db->protect_identifiers($key));
}
$sql .= ",\n\tFOREIGN KEY (" . implode(', ', $key) . ")";
@@ -202,7 +202,7 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge {
*/
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);
+ $sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '.$this->db->protect_identifiers($column_name);
// DROP has everything it needs now.
if ($alter_type == 'DROP')
@@ -228,7 +228,7 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge {
if ($after_field != '')
{
- $sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field);
+ return $sql.' AFTER '.$this->db->protect_identifiers($after_field);
}
return $sql;
@@ -250,11 +250,10 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge {
function _rename_table($table_name, $new_table_name)
{
// I think this syntax will work, but can find little documentation on renaming tables in MSSQL
- $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table_name)." RENAME TO ".$this->db->_protect_identifiers($new_table_name);
- return $sql;
+ return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name);
}
}
-/* End of file mssql_forge.php */
-/* Location: ./system/database/drivers/mssql/mssql_forge.php */ \ No newline at end of file
+/* End of file sqlsrv_forge.php */
+/* Location: ./system/database/drivers/sqlsrv/sqlsrv_forge.php */
diff --git a/system/database/drivers/sqlsrv/sqlsrv_result.php b/system/database/drivers/sqlsrv/sqlsrv_result.php
index 1ee19c2d1..52d338a30 100644
--- a/system/database/drivers/sqlsrv/sqlsrv_result.php
+++ b/system/database/drivers/sqlsrv/sqlsrv_result.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/database/drivers/sqlsrv/sqlsrv_utility.php b/system/database/drivers/sqlsrv/sqlsrv_utility.php
index e96df96f9..44e6fafeb 100644
--- a/system/database/drivers/sqlsrv/sqlsrv_utility.php
+++ b/system/database/drivers/sqlsrv/sqlsrv_utility.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/helpers/array_helper.php b/system/helpers/array_helper.php
index c46c4d103..464d1d112 100644
--- a/system/helpers/array_helper.php
+++ b/system/helpers/array_helper.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.1.6 or newer
+ * 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
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter Array Helpers
*
@@ -45,7 +43,6 @@
* Lets you determine whether an array index is set and whether it has a value.
* If the element is empty it returns FALSE (or whatever you specify as the default value.)
*
- * @access public
* @param string
* @param array
* @param mixed
@@ -55,12 +52,7 @@ if ( ! function_exists('element'))
{
function element($item, $array, $default = FALSE)
{
- if ( ! isset($array[$item]) OR $array[$item] == "")
- {
- return $default;
- }
-
- return $array[$item];
+ return empty($array[$item]) ? $default : $array[$item];
}
}
@@ -69,7 +61,6 @@ if ( ! function_exists('element'))
/**
* Random Element - Takes an array as input and returns a random element
*
- * @access public
* @param array
* @return mixed depends on what the array contains
*/
@@ -77,12 +68,7 @@ if ( ! function_exists('random_element'))
{
function random_element($array)
{
- if ( ! is_array($array))
- {
- return $array;
- }
-
- return $array[array_rand($array)];
+ return is_array($array) ? $array[array_rand($array)] : $array;
}
}
@@ -91,10 +77,9 @@ if ( ! function_exists('random_element'))
/**
* Elements
*
- * Returns only the array items specified. Will return a default value if
+ * Returns only the array items specified. Will return a default value if
* it is not set.
*
- * @access public
* @param array
* @param array
* @param mixed
@@ -105,22 +90,12 @@ if ( ! function_exists('elements'))
function elements($items, $array, $default = FALSE)
{
$return = array();
-
- if ( ! is_array($items))
- {
- $items = array($items);
- }
-
+
+ is_array($items) OR $items = array($items);
+
foreach ($items as $item)
{
- if (isset($array[$item]))
- {
- $return[$item] = $array[$item];
- }
- else
- {
- $return[$item] = $default;
- }
+ $return[$item] = isset($array[$item]) ? $array[$item] : $default;
}
return $return;
@@ -128,4 +103,4 @@ if ( ! function_exists('elements'))
}
/* End of file array_helper.php */
-/* Location: ./system/helpers/array_helper.php */ \ No newline at end of file
+/* Location: ./system/helpers/array_helper.php */
diff --git a/system/helpers/captcha_helper.php b/system/helpers/captcha_helper.php
index 668b034d4..578796573 100644
--- a/system/helpers/captcha_helper.php
+++ b/system/helpers/captcha_helper.php
@@ -2,12 +2,12 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * 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:
@@ -94,16 +94,15 @@ if ( ! function_exists('create_captcha'))
// Remove old images
// -----------------------------------
- list($usec, $sec) = explode(" ", microtime());
- $now = ((float)$usec + (float)$sec);
+ $now = microtime(TRUE);
$current_dir = @opendir($img_path);
while ($filename = @readdir($current_dir))
{
- if ($filename != "." and $filename != ".." and $filename != "index.html")
+ if ($filename != '.' && $filename != '..' && $filename != 'index.html')
{
- $name = str_replace(".jpg", "", $filename);
+ $name = str_replace('.jpg', '', $filename);
if (($name + $expiration) < $now)
{
@@ -198,7 +197,7 @@ if ( ! function_exists('create_captcha'))
// Write the text
// -----------------------------------
- $use_font = ($font_path != '' AND file_exists($font_path) AND function_exists('imagettftext')) ? TRUE : FALSE;
+ $use_font = ($font_path != '' && file_exists($font_path) && function_exists('imagettftext')) ? TRUE : FALSE;
if ($use_font == FALSE)
{
diff --git a/system/helpers/cookie_helper.php b/system/helpers/cookie_helper.php
index 7b439c47f..38a2f78fc 100644
--- a/system/helpers/cookie_helper.php
+++ b/system/helpers/cookie_helper.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.1.6 or newer
+ * 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
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter Cookie Helpers
*
@@ -45,7 +43,6 @@
* Accepts six parameter, or you can submit an associative
* array in the first parameter containing all the values.
*
- * @access public
* @param mixed
* @param string the value of the cookie
* @param string the number of seconds until expiration
@@ -69,7 +66,6 @@ if ( ! function_exists('set_cookie'))
/**
* Fetch an item from the COOKIE array
*
- * @access public
* @param string
* @param bool
* @return mixed
@@ -79,14 +75,7 @@ if ( ! function_exists('get_cookie'))
function get_cookie($index = '', $xss_clean = FALSE)
{
$CI =& get_instance();
-
- $prefix = '';
-
- if ( ! isset($_COOKIE[$index]) && config_item('cookie_prefix') != '')
- {
- $prefix = config_item('cookie_prefix');
- }
-
+ $prefix = isset($_COOKIE[$index]) ? '' : config_item('cookie_prefix');
return $CI->input->cookie($prefix.$index, $xss_clean);
}
}
@@ -97,7 +86,7 @@ if ( ! function_exists('get_cookie'))
* Delete a COOKIE
*
* @param mixed
- * @param string the cookie domain. Usually: .yourdomain.com
+ * @param string the cookie domain. Usually: .yourdomain.com
* @param string the cookie path
* @param string the cookie prefix
* @return void
@@ -110,6 +99,5 @@ if ( ! function_exists('delete_cookie'))
}
}
-
/* End of file cookie_helper.php */
-/* Location: ./system/helpers/cookie_helper.php */ \ No newline at end of file
+/* Location: ./system/helpers/cookie_helper.php */
diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php
index 9e58d8630..2a34cf93e 100644
--- a/system/helpers/date_helper.php
+++ b/system/helpers/date_helper.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/helpers/directory_helper.php b/system/helpers/directory_helper.php
index be65b388d..d7ca13e85 100644
--- a/system/helpers/directory_helper.php
+++ b/system/helpers/directory_helper.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.1.6 or newer
+ * 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
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter Directory Helpers
*
@@ -43,12 +41,11 @@
* Create a Directory Map
*
* Reads the specified directory and builds an array
- * representation of it. Sub-folders contained with the
+ * representation of it. Sub-folders contained with the
* directory will be mapped as well.
*
- * @access public
* @param string path to source
- * @param int depth of directories to traverse (0 = fully recursive, 1 = current dir, etc)
+ * @param int depth of directories to traverse (0 = fully recursive, 1 = current dir, etc)
* @return array
*/
if ( ! function_exists('directory_map'))
@@ -64,7 +61,7 @@ if ( ! function_exists('directory_map'))
while (FALSE !== ($file = readdir($fp)))
{
// Remove '.', '..', and hidden files [optional]
- if ( ! trim($file, '.') OR ($hidden == FALSE && $file[0] == '.'))
+ if ( ! trim($file, '.') OR ($hidden == FALSE && $file[0] === '.'))
{
continue;
}
@@ -87,6 +84,5 @@ if ( ! function_exists('directory_map'))
}
}
-
/* End of file directory_helper.php */
-/* Location: ./system/helpers/directory_helper.php */ \ No newline at end of file
+/* Location: ./system/helpers/directory_helper.php */
diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php
index a8c59c2c0..96ff29dec 100644
--- a/system/helpers/download_helper.php
+++ b/system/helpers/download_helper.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
@@ -60,19 +60,19 @@ if ( ! function_exists('force_download'))
// Set the default MIME type to send
$mime = 'application/octet-stream';
+ $x = explode('.', $filename);
+ $extension = end($x);
+
if ($set_mime === TRUE)
{
- /* If we're going to detect the MIME type,
- * we'll need a file extension.
- */
- if (FALSE === strpos($filename, '.'))
+ if (count($x) === 1 OR $extension === '')
{
+ /* If we're going to detect the MIME type,
+ * we'll need a file extension.
+ */
return FALSE;
}
- $extension = explode('.', $filename);
- $extension = end($extension);
-
// Load the mime types
if (defined('ENVIRONMENT') && is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes.php'))
{
@@ -90,8 +90,20 @@ if ( ! function_exists('force_download'))
}
}
+ /* It was reported that browsers on Android 2.1 (and possibly older as well)
+ * need to have the filename extension upper-cased in order to be able to
+ * download it.
+ *
+ * Reference: http://digiblog.de/2011/04/19/android-and-the-download-file-headers/
+ */
+ if (count($x) !== 1 && isset($_SERVER['HTTP_USER_AGENT']) && preg_match('/Android\s(1|2\.[01])/', $_SERVER['HTTP_USER_AGENT']))
+ {
+ $x[count($x) - 1] = strtoupper($extension);
+ $filename = implode('.', $x);
+ }
+
// Generate the server headers
- header('Content-Type: "'.$mime.'"');
+ header('Content-Type: '.$mime);
header('Content-Disposition: attachment; filename="'.$filename.'"');
header('Expires: 0');
header('Content-Transfer-Encoding: binary');
diff --git a/system/helpers/email_helper.php b/system/helpers/email_helper.php
index f184031a9..b87bce674 100644
--- a/system/helpers/email_helper.php
+++ b/system/helpers/email_helper.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/helpers/file_helper.php b/system/helpers/file_helper.php
index 2d4b10e37..3fd6b82e1 100644
--- a/system/helpers/file_helper.php
+++ b/system/helpers/file_helper.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php
index bed2cb297..37337d975 100644
--- a/system/helpers/form_helper.php
+++ b/system/helpers/form_helper.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
@@ -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
*/
// ------------------------------------------------------------------------
@@ -72,8 +71,8 @@ if ( ! function_exists('form_open'))
$form = '<form action="'.$action.'"'._attributes_to_string($attributes, TRUE).">\n";
- // Add CSRF field if enabled, but leave it out for GET requests and requests to external websites
- if ($CI->config->item('csrf_protection') === TRUE AND ! (strpos($action, $CI->config->site_url()) === FALSE OR strpos($form, 'method="get"')))
+ // Add CSRF field if enabled, but leave it out for GET requests and requests to external websites
+ if ($CI->config->item('csrf_protection') === TRUE AND ! (strpos($action, $CI->config->base_url()) === FALSE OR strpos($form, 'method="get"')))
{
$hidden[$CI->security->get_csrf_token_name()] = $CI->security->get_csrf_hash();
}
@@ -315,6 +314,28 @@ if ( ! function_exists('form_dropdown'))
{
function form_dropdown($name = '', $options = array(), $selected = array(), $extra = '')
{
+ // If name is really an array then we'll call the function again using the array
+ if (is_array($name) && isset($name['name']))
+ {
+
+ if ( ! isset($name['options']))
+ {
+ $name['options'] = array();
+ }
+
+ if ( ! isset($name['selected']))
+ {
+ $name['selected'] = array();
+ }
+
+ if ( ! isset($name['extra']))
+ {
+ $name['extra'] = '';
+ }
+
+ return form_dropdown($name['name'], $name['options'], $name['selected'], $name['extra']);
+ }
+
if ( ! is_array($selected))
{
$selected = array($selected);
diff --git a/system/helpers/html_helper.php b/system/helpers/html_helper.php
index 72970d9ca..b8c4f36f6 100644
--- a/system/helpers/html_helper.php
+++ b/system/helpers/html_helper.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/helpers/inflector_helper.php b/system/helpers/inflector_helper.php
index 02c425b8a..9cf015d2b 100644
--- a/system/helpers/inflector_helper.php
+++ b/system/helpers/inflector_helper.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter Inflector Helpers
*
@@ -37,7 +35,6 @@
* @link http://codeigniter.com/user_guide/helpers/inflector_helper.html
*/
-
// --------------------------------------------------------------------
/**
@@ -58,7 +55,7 @@ if ( ! function_exists('singular'))
{
return $result;
}
-
+
$singular_rules = array(
'/(matr)ices$/' => '\1ix',
'/(vert|ind)ices$/' => '\1ex',
@@ -116,7 +113,7 @@ if ( ! function_exists('singular'))
if ( ! function_exists('plural'))
{
function plural($str, $force = FALSE)
- {
+ {
$result = strval($str);
if ( ! is_countable($result))
@@ -145,7 +142,7 @@ if ( ! function_exists('plural'))
'/s$/' => 's', // no change (compatibility)
'/$/' => 's',
);
-
+
foreach ($plural_rules as $rule => $replacement)
{
if (preg_match($rule, $result))
@@ -173,7 +170,7 @@ if ( ! function_exists('camelize'))
{
function camelize($str)
{
- return substr(str_replace(' ', '', ucwords(preg_replace('/[\s_]+/', ' ', $str))), 1);
+ return str_replace(' ', '', ucwords(preg_replace('/[\s_]+/', ' ', strtolower($str))));
}
}
@@ -232,4 +229,4 @@ if ( ! function_exists('is_countable'))
}
/* End of file inflector_helper.php */
-/* Location: ./system/helpers/inflector_helper.php */ \ No newline at end of file
+/* Location: ./system/helpers/inflector_helper.php */
diff --git a/system/helpers/language_helper.php b/system/helpers/language_helper.php
index a83580a97..1d66df59f 100644
--- a/system/helpers/language_helper.php
+++ b/system/helpers/language_helper.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/helpers/number_helper.php b/system/helpers/number_helper.php
index 331b468c6..b6c823d8b 100644
--- a/system/helpers/number_helper.php
+++ b/system/helpers/number_helper.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/helpers/path_helper.php b/system/helpers/path_helper.php
index cd87a73eb..2eb85fefa 100644
--- a/system/helpers/path_helper.php
+++ b/system/helpers/path_helper.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/helpers/security_helper.php b/system/helpers/security_helper.php
index 99fda561a..e05e947a5 100644
--- a/system/helpers/security_helper.php
+++ b/system/helpers/security_helper.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/helpers/smiley_helper.php b/system/helpers/smiley_helper.php
index cb902114e..83fb863df 100644
--- a/system/helpers/smiley_helper.php
+++ b/system/helpers/smiley_helper.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/helpers/string_helper.php b/system/helpers/string_helper.php
index 0d1018f53..6573b9a5d 100644
--- a/system/helpers/string_helper.php
+++ b/system/helpers/string_helper.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php
index 37b5d3178..bddb112b2 100644
--- a/system/helpers/text_helper.php
+++ b/system/helpers/text_helper.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/helpers/typography_helper.php b/system/helpers/typography_helper.php
index c49348e6a..9b19c7c2d 100644
--- a/system/helpers/typography_helper.php
+++ b/system/helpers/typography_helper.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php
index 2cbcd9dbf..2ae1fd37b 100644
--- a/system/helpers/url_helper.php
+++ b/system/helpers/url_helper.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
@@ -470,39 +470,35 @@ if ( ! function_exists('prep_url'))
* Create URL Title
*
* Takes a "title" string as input and creates a
- * human-friendly URL string with either a dash
- * or an underscore as the word separator.
+ * human-friendly URL string with a "separator" string
+ * as the word separator.
*
* @access public
* @param string the string
- * @param string the separator: dash, or underscore
+ * @param string the separator
* @return string
*/
if ( ! function_exists('url_title'))
{
- function url_title($str, $separator = 'dash', $lowercase = FALSE)
+ function url_title($str, $separator = '-', $lowercase = FALSE)
{
if ($separator === 'dash')
{
- $search = '_';
- $replace = '-';
+ $separator = '-';
}
- else
+ else if ($separator == 'underscore')
{
- $search = '-';
- $replace = '_';
+ $separator = '_';
}
+
+ $q_separator = preg_quote($separator);
$trans = array(
- '&\#\d+?;' => '',
- '&\S+?;' => '',
- '\s+' => $replace,
- '[^a-z0-9\-\._]' => '',
- $replace.'+' => $replace,
- $replace.'$' => $replace,
- '^'.$replace => $replace,
- '\.+$' => ''
- );
+ '&.+?;' => '',
+ '[^a-z0-9 _-]' => '',
+ '\s+' => $separator,
+ '('.$q_separator.')+' => $separator
+ );
$str = strip_tags($str);
foreach ($trans as $key => $val)
@@ -515,7 +511,7 @@ if ( ! function_exists('url_title'))
$str = strtolower($str);
}
- return trim(trim(stripslashes($str)), $replace);
+ return trim(trim($str, $separator));
}
}
diff --git a/system/helpers/xml_helper.php b/system/helpers/xml_helper.php
index 5242193ac..f3ff5764c 100644
--- a/system/helpers/xml_helper.php
+++ b/system/helpers/xml_helper.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/language/english/calendar_lang.php b/system/language/english/calendar_lang.php
index bf61db039..2d477e6c8 100644
--- a/system/language/english/calendar_lang.php
+++ b/system/language/english/calendar_lang.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/language/english/date_lang.php b/system/language/english/date_lang.php
index cd6cf39c4..533563700 100644
--- a/system/language/english/date_lang.php
+++ b/system/language/english/date_lang.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/language/english/db_lang.php b/system/language/english/db_lang.php
index 2a91597df..a135d1aac 100644
--- a/system/language/english/db_lang.php
+++ b/system/language/english/db_lang.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/language/english/email_lang.php b/system/language/english/email_lang.php
index e0ef427a6..23296a244 100644
--- a/system/language/english/email_lang.php
+++ b/system/language/english/email_lang.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/language/english/form_validation_lang.php b/system/language/english/form_validation_lang.php
index 6afa37a29..6cf0b46f4 100644
--- a/system/language/english/form_validation_lang.php
+++ b/system/language/english/form_validation_lang.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
@@ -25,30 +25,32 @@
* @filesource
*/
-$lang['required'] = "The %s field is required.";
-$lang['isset'] = "The %s field must have a value.";
-$lang['valid_email'] = "The %s field must contain a valid email address.";
-$lang['valid_emails'] = "The %s field must contain all valid email addresses.";
-$lang['valid_url'] = "The %s field must contain a valid URL.";
-$lang['valid_ip'] = "The %s field must contain a valid IP.";
-$lang['min_length'] = "The %s field must be at least %s characters in length.";
-$lang['max_length'] = "The %s field cannot exceed %s characters in length.";
-$lang['exact_length'] = "The %s field must be exactly %s characters in length.";
-$lang['alpha'] = "The %s field may only contain alphabetical characters.";
-$lang['alpha_numeric'] = "The %s field may only contain alpha-numeric characters.";
-$lang['alpha_dash'] = "The %s field may only contain alpha-numeric characters, underscores, and dashes.";
-$lang['numeric'] = "The %s field must contain only numbers.";
-$lang['is_numeric'] = "The %s field must contain only numeric characters.";
-$lang['integer'] = "The %s field must contain an integer.";
-$lang['regex_match'] = "The %s field is not in the correct format.";
-$lang['matches'] = "The %s field does not match the %s field.";
-$lang['is_unique'] = "The %s field must contain a unique value.";
-$lang['is_natural'] = "The %s field must contain only positive numbers.";
-$lang['is_natural_no_zero'] = "The %s field must contain a number greater than zero.";
-$lang['decimal'] = "The %s field must contain a decimal number.";
-$lang['less_than'] = "The %s field must contain a number less than %s.";
-$lang['greater_than'] = "The %s field must contain a number greater than %s.";
+$lang['required'] = "The %s field is required.";
+$lang['isset'] = "The %s field must have a value.";
+$lang['valid_email'] = "The %s field must contain a valid email address.";
+$lang['valid_emails'] = "The %s field must contain all valid email addresses.";
+$lang['valid_url'] = "The %s field must contain a valid URL.";
+$lang['valid_ip'] = "The %s field must contain a valid IP.";
+$lang['min_length'] = "The %s field must be at least %s characters in length.";
+$lang['max_length'] = "The %s field cannot exceed %s characters in length.";
+$lang['exact_length'] = "The %s field must be exactly %s characters in length.";
+$lang['alpha'] = "The %s field may only contain alphabetical characters.";
+$lang['alpha_numeric'] = "The %s field may only contain alpha-numeric characters.";
+$lang['alpha_dash'] = "The %s field may only contain alpha-numeric characters, underscores, and dashes.";
+$lang['numeric'] = "The %s field must contain only numbers.";
+$lang['is_numeric'] = "The %s field must contain only numeric characters.";
+$lang['integer'] = "The %s field must contain an integer.";
+$lang['regex_match'] = "The %s field is not in the correct format.";
+$lang['matches'] = "The %s field does not match the %s field.";
+$lang['is_unique'] = "The %s field must contain a unique value.";
+$lang['is_natural'] = "The %s field must contain only positive numbers.";
+$lang['is_natural_no_zero'] = "The %s field must contain a number greater than zero.";
+$lang['decimal'] = "The %s field must contain a decimal number.";
+$lang['less_than'] = "The %s field must contain a number less than %s.";
+$lang['less_than_equal_to'] = "The %s field must contain a number less than or equal to %s.";
+$lang['greater_than'] = "The %s field must contain a number greater than %s.";
+$lang['greater_than_equal_to'] = "The %s field must contain a number greater than or equal to %s.";
/* End of file form_validation_lang.php */
-/* Location: ./system/language/english/form_validation_lang.php */ \ No newline at end of file
+/* Location: ./system/language/english/form_validation_lang.php */
diff --git a/system/language/english/ftp_lang.php b/system/language/english/ftp_lang.php
index 18ca92713..4e39e43bf 100644
--- a/system/language/english/ftp_lang.php
+++ b/system/language/english/ftp_lang.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/language/english/imglib_lang.php b/system/language/english/imglib_lang.php
index fbb92abfb..67ca94277 100644
--- a/system/language/english/imglib_lang.php
+++ b/system/language/english/imglib_lang.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/language/english/migration_lang.php b/system/language/english/migration_lang.php
index 9765562b5..2085cee2a 100644
--- a/system/language/english/migration_lang.php
+++ b/system/language/english/migration_lang.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/language/english/number_lang.php b/system/language/english/number_lang.php
index 5dfd882ed..0c19ec614 100644
--- a/system/language/english/number_lang.php
+++ b/system/language/english/number_lang.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/language/english/profiler_lang.php b/system/language/english/profiler_lang.php
index 1d10efa76..11d791272 100644
--- a/system/language/english/profiler_lang.php
+++ b/system/language/english/profiler_lang.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/language/english/unit_test_lang.php b/system/language/english/unit_test_lang.php
index ed98439f4..3a8e14403 100644
--- a/system/language/english/unit_test_lang.php
+++ b/system/language/english/unit_test_lang.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/language/english/upload_lang.php b/system/language/english/upload_lang.php
index a9a2fe74b..ec5de1e6b 100644
--- a/system/language/english/upload_lang.php
+++ b/system/language/english/upload_lang.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/libraries/Cache/Cache.php b/system/libraries/Cache/Cache.php
index 2e78a6660..7642a5270 100644
--- a/system/libraries/Cache/Cache.php
+++ b/system/libraries/Cache/Cache.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
@@ -39,20 +39,17 @@
class CI_Cache extends CI_Driver_Library {
protected $valid_drivers = array(
- 'cache_apc', 'cache_file', 'cache_memcached', 'cache_dummy'
- );
-
- protected $_cache_path = NULL; // Path of cache files (if file-based cache)
- protected $_adapter = 'dummy';
+ 'cache_apc',
+ 'cache_file',
+ 'cache_memcached',
+ 'cache_dummy',
+ 'cache_wincache'
+ );
+
+ protected $_cache_path = NULL; // Path of cache files (if file-based cache)
+ protected $_adapter = 'dummy';
protected $_backup_driver;
- // ------------------------------------------------------------------------
-
- /**
- * Constructor
- *
- * @param array
- */
public function __construct($config = array())
{
if ( ! empty($config))
diff --git a/system/libraries/Cache/drivers/Cache_apc.php b/system/libraries/Cache/drivers/Cache_apc.php
index a3dd46978..c387a30fc 100644
--- a/system/libraries/Cache/drivers/Cache_apc.php
+++ b/system/libraries/Cache/drivers/Cache_apc.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/libraries/Cache/drivers/Cache_dummy.php b/system/libraries/Cache/drivers/Cache_dummy.php
index fcd55da39..c9767e401 100644
--- a/system/libraries/Cache/drivers/Cache_dummy.php
+++ b/system/libraries/Cache/drivers/Cache_dummy.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/libraries/Cache/drivers/Cache_file.php b/system/libraries/Cache/drivers/Cache_file.php
index a960730d7..c0be0def4 100644
--- a/system/libraries/Cache/drivers/Cache_file.php
+++ b/system/libraries/Cache/drivers/Cache_file.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/libraries/Cache/drivers/Cache_memcached.php b/system/libraries/Cache/drivers/Cache_memcached.php
index ffe6f2ff7..b8f2d7e4c 100644
--- a/system/libraries/Cache/drivers/Cache_memcached.php
+++ b/system/libraries/Cache/drivers/Cache_memcached.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/libraries/Cache/drivers/Cache_wincache.php b/system/libraries/Cache/drivers/Cache_wincache.php
new file mode 100644
index 000000000..df619d4e6
--- /dev/null
+++ b/system/libraries/Cache/drivers/Cache_wincache.php
@@ -0,0 +1,165 @@
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 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:
+ * http://opensource.org/licenses/OSL-3.0
+ * If you did not receive a copy of the license and are unable to obtain it
+ * through the world wide web, please send an email to
+ * licensing@ellislab.com so we can send you a copy immediately.
+ *
+ * @package CodeIgniter
+ * @author EllisLab Dev Team
+ * @copyright Copyright (c) 2006 - 2012 EllisLab, Inc.
+ * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
+ * @link http://codeigniter.com
+ * @since Version 3.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * CodeIgniter Wincache Caching Class
+ *
+ * Read more about Wincache functions here:
+ * http://www.php.net/manual/en/ref.wincache.php
+ *
+ * @package CodeIgniter
+ * @subpackage Libraries
+ * @category Core
+ * @author Mike Murkovic
+ * @link
+ */
+
+class CI_Cache_wincache extends CI_Driver {
+
+ /**
+ * Get
+ *
+ * Look for a value in the cache. If it exists, return the data,
+ * if not, return FALSE
+ *
+ * @param string
+ * @return mixed value that is stored/FALSE on failure
+ */
+ public function get($id)
+ {
+ $success = FALSE;
+ $data = wincache_ucache_get($id, $success);
+
+ // Success returned by reference from wincache_ucache_get()
+ return ($success) ? $data : FALSE;
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * Cache Save
+ *
+ * @param string Unique Key
+ * @param mixed Data to store
+ * @param int Length of time (in seconds) to cache the data
+ * @return bool true on success/false on failure
+ */
+ public function save($id, $data, $ttl = 60)
+ {
+ return wincache_ucache_set($id, $data, $ttl);
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * Delete from Cache
+ *
+ * @param mixed unique identifier of the item in the cache
+ * @param bool true on success/false on failure
+ */
+ public function delete($id)
+ {
+ return wincache_ucache_delete($id);
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * Clean the cache
+ *
+ * @return bool false on failure/true on success
+ */
+ public function clean()
+ {
+ return wincache_ucache_clear();
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * Cache Info
+ *
+ * @return mixed array on success, false on failure
+ */
+ public function cache_info()
+ {
+ return wincache_ucache_info(TRUE);
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * Get Cache Metadata
+ *
+ * @param mixed key to get cache metadata on
+ * @return mixed array on success/false on failure
+ */
+ public function get_metadata($id)
+ {
+ if ($stored = wincache_ucache_info(FALSE, $id))
+ {
+ $age = $stored['ucache_entries'][1]['age_seconds'];
+ $ttl = $stored['ucache_entries'][1]['ttl_seconds'];
+ $hitcount = $stored['ucache_entries'][1]['hitcount'];
+
+ return array(
+ 'expire' => $ttl - $age,
+ 'hitcount' => $hitcount,
+ 'age' => $age,
+ 'ttl' => $ttl
+ );
+ }
+
+ return FALSE;
+ }
+
+ // ------------------------------------------------------------------------
+
+ /**
+ * is_supported()
+ *
+ * Check to see if WinCache is available on this system, bail if it isn't.
+ *
+ * @return bool
+ */
+ public function is_supported()
+ {
+ if ( ! extension_loaded('wincache'))
+ {
+ log_message('error', 'The Wincache PHP extension must be loaded to use Wincache Cache.');
+ return FALSE;
+ }
+
+ return TRUE;
+ }
+
+}
+
+/* End of file Cache_wincache.php */
+/* Location: ./system/libraries/Cache/drivers/Cache_wincache.php */
diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php
index a05a7babf..6c04de8a2 100644
--- a/system/libraries/Calendar.php
+++ b/system/libraries/Calendar.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/libraries/Cart.php b/system/libraries/Cart.php
index 10b5362a5..60a1e52fe 100644
--- a/system/libraries/Cart.php
+++ b/system/libraries/Cart.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/libraries/Driver.php b/system/libraries/Driver.php
index 4e8944311..9a073b336 100644
--- a/system/libraries/Driver.php
+++ b/system/libraries/Driver.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/libraries/Email.php b/system/libraries/Email.php
index c8a5b41af..f30fe40b6 100644
--- a/system/libraries/Email.php
+++ b/system/libraries/Email.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
@@ -1359,6 +1359,7 @@ class CI_Email {
if ( ! $this->$method())
{
$this->_set_error_message('lang:email_send_failure_' . ($this->_get_protocol() === 'mail' ? 'phpmail' : $this->_get_protocol()));
+ return FALSE;
}
$this->_set_error_message('lang:email_sent', $this->_get_protocol());
@@ -1433,8 +1434,10 @@ class CI_Email {
return FALSE;
}
- $this->_smtp_connect();
- $this->_smtp_authenticate();
+ if ( ! $this->_smtp_connect() OR ! $this->_smtp_authenticate())
+ {
+ return FALSE;
+ }
$this->_send_command('from', $this->clean_email($this->_headers['From']));
diff --git a/system/libraries/Encrypt.php b/system/libraries/Encrypt.php
index 0b0618991..b29eb470e 100644
--- a/system/libraries/Encrypt.php
+++ b/system/libraries/Encrypt.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php
index 2ee734ae6..9491f354c 100644
--- a/system/libraries/Form_validation.php
+++ b/system/libraries/Form_validation.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
@@ -47,14 +47,24 @@ class CI_Form_validation {
protected $_error_suffix = '</p>';
protected $error_string = '';
protected $_safe_form_data = FALSE;
+ protected $validation_data = array();
- /**
- * Constructor
- */
public function __construct($rules = array())
{
$this->CI =& get_instance();
+ // applies delimiters set in config file.
+ if (isset($rules['error_prefix']))
+ {
+ $this->_error_prefix = $rules['error_prefix'];
+ unset($rules['error_prefix']);
+ }
+ if (isset($rules['error_suffix']))
+ {
+ $this->_error_suffix = $rules['error_suffix'];
+ unset($rules['error_suffix']);
+ }
+
// Validation rules can be stored in a config file.
$this->_config_rules = $rules;
@@ -62,12 +72,12 @@ class CI_Form_validation {
$this->CI->load->helper('form');
// Set the character encoding in MB.
- if (function_exists('mb_internal_encoding'))
+ if (MB_ENABLED === TRUE)
{
mb_internal_encoding($this->CI->config->item('charset'));
}
- log_message('debug', "Form Validation Class Initialized");
+ log_message('debug', 'Form Validation Class Initialized');
}
// --------------------------------------------------------------------
@@ -85,7 +95,8 @@ class CI_Form_validation {
public function set_rules($field, $label = '', $rules = '')
{
// No reason to set rules if we have no POST data
- if (count($_POST) === 0)
+ // or a validation array has not been specified
+ if ($this->CI->input->method() !== 'post' && empty($this->validation_data))
{
return $this;
}
@@ -162,10 +173,33 @@ class CI_Form_validation {
// --------------------------------------------------------------------
/**
+ * By default, form validation uses the $_POST array to validate
+ *
+ * If an array is set through this method, then this array will
+ * be used instead of the $_POST array
+ *
+ * Note that if you are validating multiple arrays, then the
+ * reset_validation() function should be called after validating
+ * each array due to the limitations of CI's singleton
+ *
+ * @param array $data
+ * @return void
+ */
+ public function set_data($data = '')
+ {
+ if ( ! empty($data) && is_array($data))
+ {
+ $this->validation_data = $data;
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Set Error Message
*
* Lets users set their own error messages on the fly. Note: The key
- * name has to match the function name that it corresponds to.
+ * name has to match the function name that it corresponds to.
*
* @param string
* @param string
@@ -235,6 +269,20 @@ class CI_Form_validation {
// --------------------------------------------------------------------
/**
+ * Get Array of Error Messages
+ *
+ * Returns the error messages as an array
+ *
+ * @return array
+ */
+ public function error_array()
+ {
+ return $this->_error_array;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Error String
*
* Returns the error messages as a string, wrapped in the error delimiters
@@ -286,7 +334,8 @@ class CI_Form_validation {
public function run($group = '')
{
// Do we even have any data to process? Mm?
- if (count($_POST) === 0)
+ $validation_array = ( ! empty($this->validation_data)) ? $this->validation_data : $_POST;
+ if (count($validation_array) === 0)
{
return FALSE;
}
@@ -328,18 +377,18 @@ class CI_Form_validation {
// corresponding $_POST item and test for errors
foreach ($this->_field_data as $field => $row)
{
- // Fetch the data from the corresponding $_POST array and cache it in the _field_data array.
+ // Fetch the data from the corresponding $_POST or validation array and cache it in the _field_data array.
// Depending on whether the field name is an array or a string will determine where we get it from.
if ($row['is_array'] === TRUE)
{
- $this->_field_data[$field]['postdata'] = $this->_reduce_array($_POST, $row['keys']);
+ $this->_field_data[$field]['postdata'] = $this->_reduce_array($validation_array, $row['keys']);
}
else
{
- if (isset($_POST[$field]) AND $_POST[$field] != "")
+ if (isset($validation_array[$field]) AND $validation_array[$field] != "")
{
- $this->_field_data[$field]['postdata'] = $_POST[$field];
+ $this->_field_data[$field]['postdata'] = $validation_array[$field];
}
}
@@ -853,12 +902,13 @@ class CI_Form_validation {
*/
public function matches($str, $field)
{
- if ( ! isset($_POST[$field]))
+ $validation_array = ( ! empty($this->validation_data)) ? $this->validation_data : $_POST;
+ if ( ! isset($validation_array[$field]))
{
return FALSE;
}
- return ($str === $_POST[$field]);
+ return ($str === $validation_array[$field]);
}
// --------------------------------------------------------------------
@@ -900,7 +950,7 @@ class CI_Form_validation {
return FALSE;
}
- if (function_exists('mb_strlen'))
+ if (MB_ENABLED === TRUE)
{
return ! (mb_strlen($str) < $val);
}
@@ -924,7 +974,7 @@ class CI_Form_validation {
return FALSE;
}
- if (function_exists('mb_strlen'))
+ if (MB_ENABLED === TRUE)
{
return ! (mb_strlen($str) > $val);
}
@@ -948,7 +998,7 @@ class CI_Form_validation {
return FALSE;
}
- if (function_exists('mb_strlen'))
+ if (MB_ENABLED === TRUE)
{
return (mb_strlen($str) == $val);
}
@@ -1103,7 +1153,7 @@ class CI_Form_validation {
// --------------------------------------------------------------------
/**
- * Greather than
+ * Greater than
*
* @param string
* @return bool
@@ -1120,6 +1170,23 @@ class CI_Form_validation {
// --------------------------------------------------------------------
/**
+ * Equal to or Greater than
+ *
+ * @param string
+ * @return bool
+ */
+ public function greater_than_equal_to($str, $min)
+ {
+ if ( ! is_numeric($str))
+ {
+ return FALSE;
+ }
+ return $str >= $min;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Less than
*
* @param string
@@ -1137,6 +1204,23 @@ class CI_Form_validation {
// --------------------------------------------------------------------
/**
+ * Equal to or Less than
+ *
+ * @param string
+ * @return bool
+ */
+ public function less_than_equal_to($str, $max)
+ {
+ if ( ! is_numeric($str))
+ {
+ return FALSE;
+ }
+ return $str <= $max;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Is a Natural number (0,1,2,3, etc.)
*
* @param string
@@ -1269,6 +1353,25 @@ class CI_Form_validation {
return str_replace(array('<?php', '<?PHP', '<?', '?>'), array('&lt;?php', '&lt;?PHP', '&lt;?', '?&gt;'), $str);
}
+ // --------------------------------------------------------------------
+
+ /**
+ * Reset validation vars
+ *
+ * Prevents subsequent validation routines from being affected by the
+ * results of any previous validation routine due to the CI singleton.
+ *
+ * @return void
+ */
+ public function reset_validation()
+ {
+ $this->_field_data = array();
+ $this->_config_rules = array();
+ $this->_error_array = array();
+ $this->_error_messages = array();
+ $this->error_string = '';
+ }
+
}
/* End of file Form_validation.php */
diff --git a/system/libraries/Ftp.php b/system/libraries/Ftp.php
index ab395b0a0..4d96c00cc 100644
--- a/system/libraries/Ftp.php
+++ b/system/libraries/Ftp.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php
index 9826eabdd..86b77bf07 100644
--- a/system/libraries/Image_lib.php
+++ b/system/libraries/Image_lib.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/libraries/Javascript.php b/system/libraries/Javascript.php
index 33df6007a..9ba93000b 100644
--- a/system/libraries/Javascript.php
+++ b/system/libraries/Javascript.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/libraries/Log.php b/system/libraries/Log.php
index 944173fdd..955277acc 100644
--- a/system/libraries/Log.php
+++ b/system/libraries/Log.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/libraries/Migration.php b/system/libraries/Migration.php
index d07097223..c045ac0e2 100644
--- a/system/libraries/Migration.php
+++ b/system/libraries/Migration.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php
index 35ac541e8..86b8d79fa 100644
--- a/system/libraries/Pagination.php
+++ b/system/libraries/Pagination.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/libraries/Parser.php b/system/libraries/Parser.php
index 321248277..290e17fc0 100644
--- a/system/libraries/Parser.php
+++ b/system/libraries/Parser.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/libraries/Profiler.php b/system/libraries/Profiler.php
index 89c616543..d84e5d3fc 100644
--- a/system/libraries/Profiler.php
+++ b/system/libraries/Profiler.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
@@ -270,7 +270,7 @@ class CI_Profiler {
}
$output .= "<tr><td style='width:50%;color:#000;background-color:#ddd;padding:5px'>&#36;_GET[".$key."]&nbsp;&nbsp; </td><td style='width:50%;padding:5px;color:#cd6e00;font-weight:normal;background-color:#ddd;'>"
- . (is_array($val) ? "<pre>" . htmlspecialchars(stripslashes(print_r($val, true))) . "</pre>" : htmlspecialchars(stripslashes($val)))
+ . ((is_array($val) OR is_object($val)) ? "<pre>" . htmlspecialchars(stripslashes(print_r($val, true))) . "</pre>" : htmlspecialchars(stripslashes($val)))
. "</td></tr>\n";
}
@@ -311,7 +311,7 @@ class CI_Profiler {
}
$output .= "<tr><td style='width:50%;padding:5px;color:#000;background-color:#ddd;'>&#36;_POST[".$key."]&nbsp;&nbsp; </td><td style='width:50%;padding:5px;color:#009900;font-weight:normal;background-color:#ddd;'>";
- if (is_array($val))
+ if (is_array($val) OR is_object($val))
{
$output .= "<pre>" . htmlspecialchars(stripslashes(print_r($val, TRUE))) . "</pre>";
}
@@ -426,9 +426,9 @@ class CI_Profiler {
. '<legend style="color:#000;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_config').'&nbsp;&nbsp;(<span style="cursor: pointer;" onclick="var s=document.getElementById(\'ci_profiler_config_table\').style;s.display=s.display==\'none\'?\'\':\'none\';this.innerHTML=this.innerHTML==\''.$this->CI->lang->line('profiler_section_show').'\'?\''.$this->CI->lang->line('profiler_section_hide').'\':\''.$this->CI->lang->line('profiler_section_show').'\';">'.$this->CI->lang->line('profiler_section_show').'</span>)</legend>'
. "\n\n\n<table style='width:100%; display:none' id='ci_profiler_config_table'>\n";
- foreach ($this->CI->config->config as $config=>$val)
+ foreach ($this->CI->config->config as $config => $val)
{
- if (is_array($val))
+ if (is_array($val) OR is_object($val))
{
$val = print_r($val, TRUE);
}
@@ -459,7 +459,7 @@ class CI_Profiler {
foreach ($this->CI->session->all_userdata() as $key => $val)
{
- if (is_array($val) || is_object($val))
+ if (is_array($val) OR is_object($val))
{
$val = print_r($val, TRUE);
}
@@ -501,7 +501,5 @@ class CI_Profiler {
}
}
-// END CI_Profiler class
-
/* End of file Profiler.php */
/* Location: ./system/libraries/Profiler.php */
diff --git a/system/libraries/Session.php b/system/libraries/Session.php
index 66b39a6a2..0b9d45b2a 100644
--- a/system/libraries/Session.php
+++ b/system/libraries/Session.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
@@ -219,7 +219,7 @@ class CI_Session {
$this->CI->db->where('user_agent', $session['user_agent']);
}
- $query = $this->CI->db->get($this->sess_table_name);
+ $query = $this->CI->db->limit(1)->get($this->sess_table_name);
// No result? Kill it!
if ($query->num_rows() === 0)
@@ -454,7 +454,7 @@ class CI_Session {
*/
public function userdata($item)
{
- return ( ! isset($this->userdata[$item])) ? FALSE : $this->userdata[$item];
+ return isset($this->userdata[$item]) ? $this->userdata[$item] : FALSE;
}
// --------------------------------------------------------------------
@@ -729,7 +729,7 @@ class CI_Session {
*/
protected function _unserialize($data)
{
- $data = @unserialize(strip_slashes($data));
+ $data = @unserialize(strip_slashes(trim($data)));
if (is_array($data))
{
@@ -737,9 +737,11 @@ class CI_Session {
return $data;
}
- return (is_string($data)) ? str_replace('{{slash}}', '\\', $data) : $data;
+ return is_string($data) ? str_replace('{{slash}}', '\\', $data) : $data;
}
+ // --------------------------------------------------------------------
+
/**
* Unescape slashes
*
@@ -779,7 +781,7 @@ class CI_Session {
{
$expire = $this->now - $this->sess_expiration;
- $this->CI->db->where("last_activity < {$expire}");
+ $this->CI->db->where('last_activity < '.$expire);
$this->CI->db->delete($this->sess_table_name);
log_message('debug', 'Session garbage collection performed.');
diff --git a/system/libraries/Table.php b/system/libraries/Table.php
index fb154e50f..99d001ce5 100644
--- a/system/libraries/Table.php
+++ b/system/libraries/Table.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* HTML Table Generating Class
*
@@ -49,9 +47,21 @@ class CI_Table {
public $empty_cells = '';
public $function = FALSE;
- public function __construct()
+ /**
+ * Set the template from the table config file if it exists
+ *
+ * @param array $config (default: array())
+ * @return void
+ */
+ public function __construct($config = array())
{
- log_message('debug', "Table Class Initialized");
+ log_message('debug', 'Table Class Initialized');
+
+ // initialize config
+ foreach ($config as $key => $val)
+ {
+ $this->template[$key] = $val;
+ }
}
// --------------------------------------------------------------------
diff --git a/system/libraries/Trackback.php b/system/libraries/Trackback.php
index 79a009133..be1de6f3f 100644
--- a/system/libraries/Trackback.php
+++ b/system/libraries/Trackback.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
@@ -141,7 +141,7 @@ class CI_Trackback {
$this->data['charset'] = ( ! isset($_POST['charset'])) ? 'auto' : strtoupper(trim($_POST['charset']));
- if ($val != 'url' && function_exists('mb_convert_encoding'))
+ if ($val != 'url' && MB_ENABLED === TRUE)
{
$_POST[$val] = mb_convert_encoding($_POST[$val], $this->charset, $this->data['charset']);
}
diff --git a/system/libraries/Typography.php b/system/libraries/Typography.php
index 46c73ef8b..65e30b089 100644
--- a/system/libraries/Typography.php
+++ b/system/libraries/Typography.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/libraries/Unit_test.php b/system/libraries/Unit_test.php
index 38d767c69..2eb8df356 100644
--- a/system/libraries/Unit_test.php
+++ b/system/libraries/Unit_test.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php
index ac29c1bdd..42664a587 100644
--- a/system/libraries/Upload.php
+++ b/system/libraries/Upload.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
@@ -1101,7 +1101,7 @@ class CI_Upload {
$proc = @popen($cmd, 'r');
if (is_resource($proc))
{
- $mime = @fread($test, 512);
+ $mime = @fread($proc, 512);
@pclose($proc);
if ($mime !== FALSE)
{
diff --git a/system/libraries/User_agent.php b/system/libraries/User_agent.php
index cd644c00d..9109edd0f 100644
--- a/system/libraries/User_agent.php
+++ b/system/libraries/User_agent.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php
index 730a0fc49..32e2e523b 100644
--- a/system/libraries/Xmlrpc.php
+++ b/system/libraries/Xmlrpc.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/libraries/Xmlrpcs.php b/system/libraries/Xmlrpcs.php
index 355d43f29..fc41444bc 100644
--- a/system/libraries/Xmlrpcs.php
+++ b/system/libraries/Xmlrpcs.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php
index 50e84920e..e33eb4e5a 100644
--- a/system/libraries/Zip.php
+++ b/system/libraries/Zip.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*
diff --git a/system/libraries/javascript/Jquery.php b/system/libraries/javascript/Jquery.php
index 03574c66e..f30d7c639 100644
--- a/system/libraries/javascript/Jquery.php
+++ b/system/libraries/javascript/Jquery.php
@@ -2,7 +2,7 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 5.1.6 or newer
+ * An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
*