Update to CodeIgniter 2.1.0
This commit is contained in:
41
application/config/migration.php
Normal file
41
application/config/migration.php
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
<?php defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Enable/Disable Migrations
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Migrations are disabled by default but should be enabled
|
||||||
|
| whenever you intend to do a schema migration.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
$config['migration_enabled'] = FALSE;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Migrations version
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This is used to set migration version that the file system should be on.
|
||||||
|
| If you run $this->migration->latest() this is the version that schema will
|
||||||
|
| be upgraded / downgraded to.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
$config['migration_version'] = 0;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Migrations Path
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Path to your migrations folder.
|
||||||
|
| Typically, it will be within your application path.
|
||||||
|
| Also, writing permission is required within the migrations path.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
$config['migration_path'] = APPPATH . 'migrations/';
|
||||||
|
|
||||||
|
|
||||||
|
/* End of file migration.php */
|
||||||
|
/* Location: ./application/config/migration.php */
|
||||||
188
application/config/mimes.php
Executable file → Normal file
188
application/config/mimes.php
Executable file → Normal file
@@ -1,4 +1,4 @@
|
|||||||
<?php defined('BASEPATH') || exit('No direct script access allowed');
|
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||||
/*
|
/*
|
||||||
| -------------------------------------------------------------------
|
| -------------------------------------------------------------------
|
||||||
| MIME TYPES
|
| MIME TYPES
|
||||||
@@ -8,100 +8,98 @@
|
|||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$mimes = array(
|
$mimes = array( 'hqx' => 'application/mac-binhex40',
|
||||||
'hqx' => 'application/mac-binhex40',
|
'cpt' => 'application/mac-compactpro',
|
||||||
'cpt' => 'application/mac-compactpro',
|
'csv' => array('text/x-comma-separated-values', 'text/comma-separated-values', 'application/octet-stream', 'application/vnd.ms-excel', 'application/x-csv', 'text/x-csv', 'text/csv', 'application/csv', 'application/excel', 'application/vnd.msexcel'),
|
||||||
'csv' => array('text/x-comma-separated-values', 'text/comma-separated-values', 'application/octet-stream', 'application/vnd.ms-excel', 'text/x-csv', 'text/csv', 'application/csv', 'application/excel', 'application/vnd.msexcel'),
|
'bin' => 'application/macbinary',
|
||||||
'bin' => 'application/macbinary',
|
'dms' => 'application/octet-stream',
|
||||||
'dms' => 'application/octet-stream',
|
'lha' => 'application/octet-stream',
|
||||||
'lha' => 'application/octet-stream',
|
'lzh' => 'application/octet-stream',
|
||||||
'lzh' => 'application/octet-stream',
|
'exe' => array('application/octet-stream', 'application/x-msdownload'),
|
||||||
'exe' => array('application/octet-stream', 'application/x-msdownload'),
|
'class' => 'application/octet-stream',
|
||||||
'class' => 'application/octet-stream',
|
'psd' => 'application/x-photoshop',
|
||||||
'psd' => 'application/x-photoshop',
|
'so' => 'application/octet-stream',
|
||||||
'so' => 'application/octet-stream',
|
'sea' => 'application/octet-stream',
|
||||||
'sea' => 'application/octet-stream',
|
'dll' => 'application/octet-stream',
|
||||||
'dll' => 'application/octet-stream',
|
'oda' => 'application/oda',
|
||||||
'oda' => 'application/oda',
|
'pdf' => array('application/pdf', 'application/x-download'),
|
||||||
'pdf' => array('application/pdf', 'application/x-download'),
|
'ai' => 'application/postscript',
|
||||||
'ai' => 'application/postscript',
|
'eps' => 'application/postscript',
|
||||||
'eps' => 'application/postscript',
|
'ps' => 'application/postscript',
|
||||||
'ps' => 'application/postscript',
|
'smi' => 'application/smil',
|
||||||
'smi' => 'application/smil',
|
'smil' => 'application/smil',
|
||||||
'smil' => 'application/smil',
|
'mif' => 'application/vnd.mif',
|
||||||
'mif' => 'application/vnd.mif',
|
'xls' => array('application/excel', 'application/vnd.ms-excel', 'application/msexcel'),
|
||||||
'xls' => array('application/excel', 'application/vnd.ms-excel', 'application/msexcel'),
|
'ppt' => array('application/powerpoint', 'application/vnd.ms-powerpoint'),
|
||||||
'ppt' => array('application/powerpoint', 'application/vnd.ms-powerpoint'),
|
'wbxml' => 'application/wbxml',
|
||||||
'wbxml' => 'application/wbxml',
|
'wmlc' => 'application/wmlc',
|
||||||
'wmlc' => 'application/wmlc',
|
'dcr' => 'application/x-director',
|
||||||
'dcr' => 'application/x-director',
|
'dir' => 'application/x-director',
|
||||||
'dir' => 'application/x-director',
|
'dxr' => 'application/x-director',
|
||||||
'dxr' => 'application/x-director',
|
'dvi' => 'application/x-dvi',
|
||||||
'dvi' => 'application/x-dvi',
|
'gtar' => 'application/x-gtar',
|
||||||
'gtar' => 'application/x-gtar',
|
'gz' => 'application/x-gzip',
|
||||||
'gz' => 'application/x-gzip',
|
'php' => 'application/x-httpd-php',
|
||||||
'php' => 'application/x-httpd-php',
|
'php4' => 'application/x-httpd-php',
|
||||||
'php4' => 'application/x-httpd-php',
|
'php3' => 'application/x-httpd-php',
|
||||||
'php3' => 'application/x-httpd-php',
|
'phtml' => 'application/x-httpd-php',
|
||||||
'phtml' => 'application/x-httpd-php',
|
'phps' => 'application/x-httpd-php-source',
|
||||||
'phps' => 'application/x-httpd-php-source',
|
'js' => 'application/x-javascript',
|
||||||
'js' => 'application/x-javascript',
|
'swf' => 'application/x-shockwave-flash',
|
||||||
'swf' => 'application/x-shockwave-flash',
|
'sit' => 'application/x-stuffit',
|
||||||
'sit' => 'application/x-stuffit',
|
'tar' => 'application/x-tar',
|
||||||
'tar' => 'application/x-tar',
|
'tgz' => array('application/x-tar', 'application/x-gzip-compressed'),
|
||||||
'tgz' => array('application/x-tar', 'application/x-gzip-compressed'),
|
'xhtml' => 'application/xhtml+xml',
|
||||||
'xhtml' => 'application/xhtml+xml',
|
'xht' => 'application/xhtml+xml',
|
||||||
'xht' => 'application/xhtml+xml',
|
'zip' => array('application/x-zip', 'application/zip', 'application/x-zip-compressed'),
|
||||||
'zip' => array('application/x-zip', 'application/zip', 'application/x-zip-compressed'),
|
'mid' => 'audio/midi',
|
||||||
'mid' => 'audio/midi',
|
'midi' => 'audio/midi',
|
||||||
'midi' => 'audio/midi',
|
'mpga' => 'audio/mpeg',
|
||||||
'mpga' => 'audio/mpeg',
|
'mp2' => 'audio/mpeg',
|
||||||
'mp2' => 'audio/mpeg',
|
'mp3' => array('audio/mpeg', 'audio/mpg', 'audio/mpeg3', 'audio/mp3'),
|
||||||
'mp3' => array('audio/mpeg', 'audio/mpg', 'audio/mpeg3', 'audio/mp3'),
|
'aif' => 'audio/x-aiff',
|
||||||
'aif' => 'audio/x-aiff',
|
'aiff' => 'audio/x-aiff',
|
||||||
'aiff' => 'audio/x-aiff',
|
'aifc' => 'audio/x-aiff',
|
||||||
'aifc' => 'audio/x-aiff',
|
'ram' => 'audio/x-pn-realaudio',
|
||||||
'ram' => 'audio/x-pn-realaudio',
|
'rm' => 'audio/x-pn-realaudio',
|
||||||
'rm' => 'audio/x-pn-realaudio',
|
'rpm' => 'audio/x-pn-realaudio-plugin',
|
||||||
'rpm' => 'audio/x-pn-realaudio-plugin',
|
'ra' => 'audio/x-realaudio',
|
||||||
'ra' => 'audio/x-realaudio',
|
'rv' => 'video/vnd.rn-realvideo',
|
||||||
'rv' => 'video/vnd.rn-realvideo',
|
'wav' => array('audio/x-wav', 'audio/wave', 'audio/wav'),
|
||||||
'wav' => 'audio/x-wav',
|
'bmp' => array('image/bmp', 'image/x-windows-bmp'),
|
||||||
'bmp' => 'image/bmp',
|
'gif' => 'image/gif',
|
||||||
'gif' => 'image/gif',
|
'jpeg' => array('image/jpeg', 'image/pjpeg'),
|
||||||
'jpeg' => array('image/jpeg', 'image/pjpeg'),
|
'jpg' => array('image/jpeg', 'image/pjpeg'),
|
||||||
'jpg' => array('image/jpeg', 'image/pjpeg'),
|
'jpe' => array('image/jpeg', 'image/pjpeg'),
|
||||||
'jpe' => array('image/jpeg', 'image/pjpeg'),
|
'png' => array('image/png', 'image/x-png'),
|
||||||
'png' => array('image/png', 'image/x-png'),
|
'tiff' => 'image/tiff',
|
||||||
'tiff' => 'image/tiff',
|
'tif' => 'image/tiff',
|
||||||
'tif' => 'image/tiff',
|
'css' => 'text/css',
|
||||||
'css' => 'text/css',
|
'html' => 'text/html',
|
||||||
'html' => 'text/html',
|
'htm' => 'text/html',
|
||||||
'htm' => 'text/html',
|
'shtml' => 'text/html',
|
||||||
'shtml' => 'text/html',
|
'txt' => 'text/plain',
|
||||||
'txt' => 'text/plain',
|
'text' => 'text/plain',
|
||||||
'text' => 'text/plain',
|
'log' => array('text/plain', 'text/x-log'),
|
||||||
'log' => array('text/plain', 'text/x-log'),
|
'rtx' => 'text/richtext',
|
||||||
'rtx' => 'text/richtext',
|
'rtf' => 'text/rtf',
|
||||||
'rtf' => 'text/rtf',
|
'xml' => 'text/xml',
|
||||||
'xml' => 'text/xml',
|
'xsl' => 'text/xml',
|
||||||
'xsl' => 'text/xml',
|
'mpeg' => 'video/mpeg',
|
||||||
'mpeg' => 'video/mpeg',
|
'mpg' => 'video/mpeg',
|
||||||
'mpg' => 'video/mpeg',
|
'mpe' => 'video/mpeg',
|
||||||
'mpe' => 'video/mpeg',
|
'qt' => 'video/quicktime',
|
||||||
'qt' => 'video/quicktime',
|
'mov' => 'video/quicktime',
|
||||||
'mov' => 'video/quicktime',
|
'avi' => 'video/x-msvideo',
|
||||||
'avi' => 'video/x-msvideo',
|
'movie' => 'video/x-sgi-movie',
|
||||||
'movie' => 'video/x-sgi-movie',
|
'doc' => 'application/msword',
|
||||||
'doc' => 'application/msword',
|
'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
||||||
'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||||
'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
'word' => array('application/msword', 'application/octet-stream'),
|
||||||
'word' => array('application/msword', 'application/octet-stream'),
|
'xl' => 'application/excel',
|
||||||
'xl' => 'application/excel',
|
'eml' => 'message/rfc822',
|
||||||
'eml' => 'message/rfc822',
|
'json' => array('application/json', 'text/json')
|
||||||
'json' => array('application/json', 'text/json'),
|
);
|
||||||
'obj' => 'text/plain',
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
/* End of file mimes.php */
|
/* End of file mimes.php */
|
||||||
|
|||||||
@@ -29,6 +29,11 @@
|
|||||||
*/
|
*/
|
||||||
class CI_Benchmark {
|
class CI_Benchmark {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of all benchmark markers and when they were added
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
var $marker = array();
|
var $marker = array();
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|||||||
@@ -27,17 +27,19 @@
|
|||||||
* @link http://codeigniter.com/user_guide/
|
* @link http://codeigniter.com/user_guide/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* ------------------------------------------------------
|
* CodeIgniter Version
|
||||||
* Define the CodeIgniter Version
|
*
|
||||||
* ------------------------------------------------------
|
* @var string
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
define('CI_VERSION', '2.0.3');
|
define('CI_VERSION', '2.1.0');
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* ------------------------------------------------------
|
* CodeIgniter Branch (Core = TRUE, Reactor = FALSE)
|
||||||
* Define the CodeIgniter Branch (Core = TRUE, Reactor = FALSE)
|
*
|
||||||
* ------------------------------------------------------
|
* @var boolean
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
define('CI_CORE', FALSE);
|
define('CI_CORE', FALSE);
|
||||||
|
|
||||||
@@ -267,7 +269,25 @@
|
|||||||
OR in_array(strtolower($method), array_map('strtolower', get_class_methods('CI_Controller')))
|
OR in_array(strtolower($method), array_map('strtolower', get_class_methods('CI_Controller')))
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
show_404("{$class}/{$method}");
|
if ( ! empty($RTR->routes['404_override']))
|
||||||
|
{
|
||||||
|
$x = explode('/', $RTR->routes['404_override']);
|
||||||
|
$class = $x[0];
|
||||||
|
$method = (isset($x[1]) ? $x[1] : 'index');
|
||||||
|
if ( ! class_exists($class))
|
||||||
|
{
|
||||||
|
if ( ! file_exists(APPPATH.'controllers/'.$class.'.php'))
|
||||||
|
{
|
||||||
|
show_404("{$class}/{$method}");
|
||||||
|
}
|
||||||
|
|
||||||
|
include_once(APPPATH.'controllers/'.$class.'.php');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
show_404("{$class}/{$method}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
30
system/core/Common.php
Executable file → Normal file
30
system/core/Common.php
Executable file → Normal file
@@ -132,9 +132,9 @@ if ( ! function_exists('load_class'))
|
|||||||
|
|
||||||
$name = FALSE;
|
$name = FALSE;
|
||||||
|
|
||||||
// Look for the class first in the native system/libraries folder
|
// Look for the class first in the local application/libraries folder
|
||||||
// thenin the local application/libraries folder
|
// then in the native system/libraries folder
|
||||||
foreach (array(BASEPATH, APPPATH) as $path)
|
foreach (array(APPPATH, BASEPATH) as $path)
|
||||||
{
|
{
|
||||||
if (file_exists($path.$directory.'/'.$class.'.php'))
|
if (file_exists($path.$directory.'/'.$class.'.php'))
|
||||||
{
|
{
|
||||||
@@ -536,5 +536,29 @@ if ( ! function_exists('remove_invisible_characters'))
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns HTML escaped variable
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param mixed
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
if ( ! function_exists('html_escape'))
|
||||||
|
{
|
||||||
|
function html_escape($var)
|
||||||
|
{
|
||||||
|
if (is_array($var))
|
||||||
|
{
|
||||||
|
return array_map('html_escape', $var);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return htmlspecialchars($var, ENT_QUOTES, config_item('charset'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* End of file Common.php */
|
/* End of file Common.php */
|
||||||
/* Location: ./system/core/Common.php */
|
/* Location: ./system/core/Common.php */
|
||||||
@@ -28,8 +28,23 @@
|
|||||||
*/
|
*/
|
||||||
class CI_Config {
|
class CI_Config {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of all loaded config values
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
var $config = array();
|
var $config = array();
|
||||||
|
/**
|
||||||
|
* List of all loaded config files
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
var $is_loaded = array();
|
var $is_loaded = array();
|
||||||
|
/**
|
||||||
|
* List of paths to search when trying to load a config file
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
var $_config_paths = array(APPPATH);
|
var $_config_paths = array(APPPATH);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
2
system/core/Controller.php
Executable file → Normal file
2
system/core/Controller.php
Executable file → Normal file
@@ -48,7 +48,7 @@ class CI_Controller {
|
|||||||
|
|
||||||
$this->load =& load_class('Loader', 'core');
|
$this->load =& load_class('Loader', 'core');
|
||||||
|
|
||||||
$this->load->set_base_classes()->ci_autoloader();
|
$this->load->initialize();
|
||||||
|
|
||||||
log_message('debug', "Controller Class Initialized");
|
log_message('debug', "Controller Class Initialized");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,8 +30,21 @@ class CI_Exceptions {
|
|||||||
var $message;
|
var $message;
|
||||||
var $filename;
|
var $filename;
|
||||||
var $line;
|
var $line;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Nesting level of the output buffering mechanism
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
var $ob_level;
|
var $ob_level;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List if available error levels
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
var $levels = array(
|
var $levels = array(
|
||||||
E_ERROR => 'Error',
|
E_ERROR => 'Error',
|
||||||
E_WARNING => 'Warning',
|
E_WARNING => 'Warning',
|
||||||
@@ -84,7 +97,8 @@ class CI_Exceptions {
|
|||||||
* 404 Page Not Found Handler
|
* 404 Page Not Found Handler
|
||||||
*
|
*
|
||||||
* @access private
|
* @access private
|
||||||
* @param string
|
* @param string the page
|
||||||
|
* @param bool log error yes/no
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function show_404($page = '', $log_error = TRUE)
|
function show_404($page = '', $log_error = TRUE)
|
||||||
@@ -115,6 +129,7 @@ class CI_Exceptions {
|
|||||||
* @param string the heading
|
* @param string the heading
|
||||||
* @param string the message
|
* @param string the message
|
||||||
* @param string the template name
|
* @param string the template name
|
||||||
|
* @param int the status code
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function show_error($heading, $message, $template = 'error_general', $status_code = 500)
|
function show_error($heading, $message, $template = 'error_general', $status_code = 500)
|
||||||
|
|||||||
@@ -28,8 +28,23 @@
|
|||||||
*/
|
*/
|
||||||
class CI_Hooks {
|
class CI_Hooks {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines wether hooks are enabled
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
var $enabled = FALSE;
|
var $enabled = FALSE;
|
||||||
|
/**
|
||||||
|
* List of all hooks set in config/hooks.php
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
var $hooks = array();
|
var $hooks = array();
|
||||||
|
/**
|
||||||
|
* Determines wether hook is in progress, used to prevent infinte loops
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
var $in_progress = FALSE;
|
var $in_progress = FALSE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -28,13 +28,49 @@
|
|||||||
*/
|
*/
|
||||||
class CI_Input {
|
class CI_Input {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* IP address of the current user
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
var $ip_address = FALSE;
|
var $ip_address = FALSE;
|
||||||
|
/**
|
||||||
|
* user agent (web browser) being used by the current user
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
var $user_agent = FALSE;
|
var $user_agent = FALSE;
|
||||||
|
/**
|
||||||
|
* If FALSE, then $_GET will be set to an empty array
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
var $_allow_get_array = TRUE;
|
var $_allow_get_array = TRUE;
|
||||||
|
/**
|
||||||
|
* If TRUE, then newlines are standardized
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
var $_standardize_newlines = TRUE;
|
var $_standardize_newlines = TRUE;
|
||||||
var $_enable_xss = FALSE; // Set automatically based on config setting
|
/**
|
||||||
var $_enable_csrf = FALSE; // Set automatically based on config setting
|
* Determines whether the XSS filter is always active when GET, POST or COOKIE data is encountered
|
||||||
|
* Set automatically based on config setting
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
var $_enable_xss = FALSE;
|
||||||
|
/**
|
||||||
|
* Enables a CSRF cookie token to be set.
|
||||||
|
* Set automatically based on config setting
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
var $_enable_csrf = FALSE;
|
||||||
|
/**
|
||||||
|
* List of all HTTP request headers
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
protected $headers = array();
|
protected $headers = array();
|
||||||
|
|
||||||
|
|
||||||
@@ -512,8 +548,12 @@ class CI_Input {
|
|||||||
return $new_array;
|
return $new_array;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We strip slashes if magic quotes is on to keep things consistent
|
/* We strip slashes if magic quotes is on to keep things consistent
|
||||||
if (function_exists('get_magic_quotes_gpc') AND get_magic_quotes_gpc())
|
|
||||||
|
NOTE: In PHP 5.4 get_magic_quotes_gpc() will always return 0 and
|
||||||
|
it will probably not exist in future versions at all.
|
||||||
|
*/
|
||||||
|
if ( ! is_php('5.4') && get_magic_quotes_gpc())
|
||||||
{
|
{
|
||||||
$str = stripslashes($str);
|
$str = stripslashes($str);
|
||||||
}
|
}
|
||||||
@@ -582,6 +622,8 @@ class CI_Input {
|
|||||||
* In Apache, you can simply call apache_request_headers(), however for
|
* In Apache, you can simply call apache_request_headers(), however for
|
||||||
* people running other webservers the function is undefined.
|
* people running other webservers the function is undefined.
|
||||||
*
|
*
|
||||||
|
* @param bool XSS cleaning
|
||||||
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function request_headers($xss_clean = FALSE)
|
public function request_headers($xss_clean = FALSE)
|
||||||
@@ -676,7 +718,6 @@ class CI_Input {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// END Input class
|
|
||||||
|
|
||||||
/* End of file Input.php */
|
/* End of file Input.php */
|
||||||
/* Location: ./system/core/Input.php */
|
/* Location: ./system/core/Input.php */
|
||||||
@@ -26,7 +26,17 @@
|
|||||||
*/
|
*/
|
||||||
class CI_Lang {
|
class CI_Lang {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of translations
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
var $language = array();
|
var $language = array();
|
||||||
|
/**
|
||||||
|
* List of loaded language files
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
var $is_loaded = array();
|
var $is_loaded = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -47,6 +57,9 @@ class CI_Lang {
|
|||||||
* @access public
|
* @access public
|
||||||
* @param mixed the name of the language file to be loaded. Can be an array
|
* @param mixed the name of the language file to be loaded. Can be an array
|
||||||
* @param string the language (english, etc.)
|
* @param string the language (english, etc.)
|
||||||
|
* @param bool return loaded array of translations
|
||||||
|
* @param bool add suffix to $langfile
|
||||||
|
* @param string alternative path to look for language file
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
function load($langfile = '', $idiom = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '')
|
function load($langfile = '', $idiom = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '')
|
||||||
|
|||||||
112
system/core/Loader.php
Executable file → Normal file
112
system/core/Loader.php
Executable file → Normal file
@@ -29,17 +29,90 @@
|
|||||||
class CI_Loader {
|
class CI_Loader {
|
||||||
|
|
||||||
// All these are set automatically. Don't mess with them.
|
// All these are set automatically. Don't mess with them.
|
||||||
|
/**
|
||||||
|
* Nesting level of the output buffering mechanism
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
protected $_ci_ob_level;
|
protected $_ci_ob_level;
|
||||||
|
/**
|
||||||
|
* List of paths to load views from
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
protected $_ci_view_paths = array();
|
protected $_ci_view_paths = array();
|
||||||
|
/**
|
||||||
|
* List of paths to load libraries from
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
protected $_ci_library_paths = array();
|
protected $_ci_library_paths = array();
|
||||||
|
/**
|
||||||
|
* List of paths to load models from
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
protected $_ci_model_paths = array();
|
protected $_ci_model_paths = array();
|
||||||
|
/**
|
||||||
|
* List of paths to load helpers from
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
protected $_ci_helper_paths = array();
|
protected $_ci_helper_paths = array();
|
||||||
|
/**
|
||||||
|
* List of loaded base classes
|
||||||
|
* Set by the controller class
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
protected $_base_classes = array(); // Set by the controller class
|
protected $_base_classes = array(); // Set by the controller class
|
||||||
|
/**
|
||||||
|
* List of cached variables
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
protected $_ci_cached_vars = array();
|
protected $_ci_cached_vars = array();
|
||||||
|
/**
|
||||||
|
* List of loaded classes
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
protected $_ci_classes = array();
|
protected $_ci_classes = array();
|
||||||
|
/**
|
||||||
|
* List of loaded files
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
protected $_ci_loaded_files = array();
|
protected $_ci_loaded_files = array();
|
||||||
|
/**
|
||||||
|
* List of loaded models
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
protected $_ci_models = array();
|
protected $_ci_models = array();
|
||||||
|
/**
|
||||||
|
* List of loaded helpers
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
protected $_ci_helpers = array();
|
protected $_ci_helpers = array();
|
||||||
|
/**
|
||||||
|
* List of class name mappings
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
protected $_ci_varmap = array('unit_test' => 'unit',
|
protected $_ci_varmap = array('unit_test' => 'unit',
|
||||||
'user_agent' => 'agent');
|
'user_agent' => 'agent');
|
||||||
|
|
||||||
@@ -62,17 +135,22 @@ class CI_Loader {
|
|||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set _base_classes variable
|
* Initialize the Loader
|
||||||
*
|
*
|
||||||
* This method is called once in CI_Controller.
|
* This method is called once in CI_Controller.
|
||||||
*
|
*
|
||||||
* @param array
|
* @param array
|
||||||
* @return object
|
* @return object
|
||||||
*/
|
*/
|
||||||
public function set_base_classes()
|
public function initialize()
|
||||||
{
|
{
|
||||||
|
$this->_ci_classes = array();
|
||||||
|
$this->_ci_loaded_files = array();
|
||||||
|
$this->_ci_models = array();
|
||||||
$this->_base_classes =& is_loaded();
|
$this->_base_classes =& is_loaded();
|
||||||
|
|
||||||
|
$this->_ci_autoloader();
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -366,6 +444,7 @@ class CI_Loader {
|
|||||||
* the controller class and its "view" files.
|
* the controller class and its "view" files.
|
||||||
*
|
*
|
||||||
* @param array
|
* @param array
|
||||||
|
* @param string
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function vars($vars = array(), $val = '')
|
public function vars($vars = array(), $val = '')
|
||||||
@@ -507,6 +586,8 @@ class CI_Loader {
|
|||||||
* Loads a config file
|
* Loads a config file
|
||||||
*
|
*
|
||||||
* @param string
|
* @param string
|
||||||
|
* @param bool
|
||||||
|
* @param bool
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function config($file = '', $use_sections = FALSE, $fail_gracefully = FALSE)
|
public function config($file = '', $use_sections = FALSE, $fail_gracefully = FALSE)
|
||||||
@@ -535,6 +616,11 @@ class CI_Loader {
|
|||||||
require BASEPATH.'libraries/Driver.php';
|
require BASEPATH.'libraries/Driver.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($library == '')
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
// We can save the loader some time since Drivers will *always* be in a subfolder,
|
// We can save the loader some time since Drivers will *always* be in a subfolder,
|
||||||
// and typically identically named to the library
|
// and typically identically named to the library
|
||||||
if ( ! strpos($library, '/'))
|
if ( ! strpos($library, '/'))
|
||||||
@@ -595,6 +681,7 @@ class CI_Loader {
|
|||||||
* If no path is provided, the most recently added path is removed.
|
* If no path is provided, the most recently added path is removed.
|
||||||
*
|
*
|
||||||
* @param type
|
* @param type
|
||||||
|
* @param bool
|
||||||
* @return type
|
* @return type
|
||||||
*/
|
*/
|
||||||
public function remove_package_path($path = '', $remove_config_path = TRUE)
|
public function remove_package_path($path = '', $remove_config_path = TRUE)
|
||||||
@@ -913,6 +1000,7 @@ class CI_Loader {
|
|||||||
*
|
*
|
||||||
* @param string
|
* @param string
|
||||||
* @param string
|
* @param string
|
||||||
|
* @param bool
|
||||||
* @param string an optional object name
|
* @param string an optional object name
|
||||||
* @return null
|
* @return null
|
||||||
*/
|
*/
|
||||||
@@ -935,22 +1023,22 @@ class CI_Loader {
|
|||||||
// first, global next
|
// first, global next
|
||||||
if (defined('ENVIRONMENT') AND file_exists($path .'config/'.ENVIRONMENT.'/'.strtolower($class).'.php'))
|
if (defined('ENVIRONMENT') AND file_exists($path .'config/'.ENVIRONMENT.'/'.strtolower($class).'.php'))
|
||||||
{
|
{
|
||||||
include_once($path .'config/'.ENVIRONMENT.'/'.strtolower($class).'.php');
|
include($path .'config/'.ENVIRONMENT.'/'.strtolower($class).'.php');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
elseif (defined('ENVIRONMENT') AND file_exists($path .'config/'.ENVIRONMENT.'/'.ucfirst(strtolower($class)).'.php'))
|
elseif (defined('ENVIRONMENT') AND file_exists($path .'config/'.ENVIRONMENT.'/'.ucfirst(strtolower($class)).'.php'))
|
||||||
{
|
{
|
||||||
include_once($path .'config/'.ENVIRONMENT.'/'.ucfirst(strtolower($class)).'.php');
|
include($path .'config/'.ENVIRONMENT.'/'.ucfirst(strtolower($class)).'.php');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
elseif (file_exists($path .'config/'.strtolower($class).'.php'))
|
elseif (file_exists($path .'config/'.strtolower($class).'.php'))
|
||||||
{
|
{
|
||||||
include_once($path .'config/'.strtolower($class).'.php');
|
include($path .'config/'.strtolower($class).'.php');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
elseif (file_exists($path .'config/'.ucfirst(strtolower($class)).'.php'))
|
elseif (file_exists($path .'config/'.ucfirst(strtolower($class)).'.php'))
|
||||||
{
|
{
|
||||||
include_once($path .'config/'.ucfirst(strtolower($class)).'.php');
|
include($path .'config/'.ucfirst(strtolower($class)).'.php');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1020,24 +1108,20 @@ class CI_Loader {
|
|||||||
* The config/autoload.php file contains an array that permits sub-systems,
|
* The config/autoload.php file contains an array that permits sub-systems,
|
||||||
* libraries, and helpers to be loaded automatically.
|
* libraries, and helpers to be loaded automatically.
|
||||||
*
|
*
|
||||||
* This function is public, as it's used in the CI_Controller class.
|
|
||||||
* However, there is no reason you should ever needs to use it.
|
|
||||||
*
|
|
||||||
* @param array
|
* @param array
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function ci_autoloader()
|
private function _ci_autoloader()
|
||||||
{
|
{
|
||||||
if (defined('ENVIRONMENT') AND file_exists(APPPATH.'config/'.ENVIRONMENT.'/autoload.php'))
|
if (defined('ENVIRONMENT') AND file_exists(APPPATH.'config/'.ENVIRONMENT.'/autoload.php'))
|
||||||
{
|
{
|
||||||
include_once(APPPATH.'config/'.ENVIRONMENT.'/autoload.php');
|
include(APPPATH.'config/'.ENVIRONMENT.'/autoload.php');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
include_once(APPPATH.'config/autoload.php');
|
include(APPPATH.'config/autoload.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ( ! isset($autoload))
|
if ( ! isset($autoload))
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -1122,6 +1206,7 @@ class CI_Loader {
|
|||||||
/**
|
/**
|
||||||
* Get a reference to a specific library or model
|
* Get a reference to a specific library or model
|
||||||
*
|
*
|
||||||
|
* @param string
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function &_ci_get_component($component)
|
protected function &_ci_get_component($component)
|
||||||
@@ -1138,6 +1223,7 @@ class CI_Loader {
|
|||||||
* This function preps the name of various items to make loading them more reliable.
|
* This function preps the name of various items to make loading them more reliable.
|
||||||
*
|
*
|
||||||
* @param mixed
|
* @param mixed
|
||||||
|
* @param string
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function _ci_prep_filename($filename, $extension)
|
protected function _ci_prep_filename($filename, $extension)
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ class CI_Model {
|
|||||||
* Allows models to access CI's loaded classes using the same
|
* Allows models to access CI's loaded classes using the same
|
||||||
* syntax as controllers.
|
* syntax as controllers.
|
||||||
*
|
*
|
||||||
|
* @param string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function __get($key)
|
function __get($key)
|
||||||
|
|||||||
@@ -28,15 +28,67 @@
|
|||||||
*/
|
*/
|
||||||
class CI_Output {
|
class CI_Output {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Current output string
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
protected $final_output;
|
protected $final_output;
|
||||||
|
/**
|
||||||
|
* Cache expiration time
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
protected $cache_expiration = 0;
|
protected $cache_expiration = 0;
|
||||||
|
/**
|
||||||
|
* List of server headers
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
protected $headers = array();
|
protected $headers = array();
|
||||||
protected $mime_types = array();
|
/**
|
||||||
|
* List of mime types
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
|
protected $mime_types = array();
|
||||||
|
/**
|
||||||
|
* Determines wether profiler is enabled
|
||||||
|
*
|
||||||
|
* @var book
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
protected $enable_profiler = FALSE;
|
protected $enable_profiler = FALSE;
|
||||||
|
/**
|
||||||
|
* Determines if output compression is enabled
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
protected $_zlib_oc = FALSE;
|
protected $_zlib_oc = FALSE;
|
||||||
|
/**
|
||||||
|
* List of profiler sections
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
protected $_profiler_sections = array();
|
protected $_profiler_sections = array();
|
||||||
protected $parse_exec_vars = TRUE; // whether or not to parse variables like {elapsed_time} and {memory_usage}
|
/**
|
||||||
|
* Whether or not to parse variables like {elapsed_time} and {memory_usage}
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
|
protected $parse_exec_vars = TRUE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
*/
|
||||||
function __construct()
|
function __construct()
|
||||||
{
|
{
|
||||||
$this->_zlib_oc = @ini_get('zlib.output_compression');
|
$this->_zlib_oc = @ini_get('zlib.output_compression');
|
||||||
@@ -127,6 +179,7 @@ class CI_Output {
|
|||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @param string
|
* @param string
|
||||||
|
* @param bool
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function set_header($header, $replace = TRUE)
|
function set_header($header, $replace = TRUE)
|
||||||
@@ -265,6 +318,7 @@ class CI_Output {
|
|||||||
* benchmark timer so the page rendering speed and memory usage can be shown.
|
* benchmark timer so the page rendering speed and memory usage can be shown.
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
|
* @param string
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
function _display($output = '')
|
function _display($output = '')
|
||||||
@@ -401,6 +455,7 @@ class CI_Output {
|
|||||||
* Write a Cache File
|
* Write a Cache File
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
|
* @param string
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function _write_cache($output)
|
function _write_cache($output)
|
||||||
@@ -452,6 +507,8 @@ class CI_Output {
|
|||||||
* Update/serve a cached file
|
* Update/serve a cached file
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
|
* @param object config class
|
||||||
|
* @param object uri class
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function _display_cache(&$CFG, &$URI)
|
function _display_cache(&$CFG, &$URI)
|
||||||
|
|||||||
@@ -28,12 +28,54 @@
|
|||||||
*/
|
*/
|
||||||
class CI_Router {
|
class CI_Router {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Config class
|
||||||
|
*
|
||||||
|
* @var object
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
var $config;
|
var $config;
|
||||||
|
/**
|
||||||
|
* List of routes
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
var $routes = array();
|
var $routes = array();
|
||||||
|
/**
|
||||||
|
* List of error routes
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
var $error_routes = array();
|
var $error_routes = array();
|
||||||
|
/**
|
||||||
|
* Current class name
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
var $class = '';
|
var $class = '';
|
||||||
|
/**
|
||||||
|
* Current method name
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
var $method = 'index';
|
var $method = 'index';
|
||||||
|
/**
|
||||||
|
* Sub-directory that contains the requested controller class
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
var $directory = '';
|
var $directory = '';
|
||||||
|
/**
|
||||||
|
* Default controller (and method if specific)
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
var $default_controller;
|
var $default_controller;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -244,7 +286,20 @@ class CI_Router {
|
|||||||
// Does the requested controller exist in the sub-folder?
|
// Does the requested controller exist in the sub-folder?
|
||||||
if ( ! file_exists(APPPATH.'controllers/'.$this->fetch_directory().$segments[0].'.php'))
|
if ( ! file_exists(APPPATH.'controllers/'.$this->fetch_directory().$segments[0].'.php'))
|
||||||
{
|
{
|
||||||
show_404($this->fetch_directory().$segments[0]);
|
if ( ! empty($this->routes['404_override']))
|
||||||
|
{
|
||||||
|
$x = explode('/', $this->routes['404_override']);
|
||||||
|
|
||||||
|
$this->set_directory('');
|
||||||
|
$this->set_class($x[0]);
|
||||||
|
$this->set_method(isset($x[1]) ? $x[1] : 'index');
|
||||||
|
|
||||||
|
return $x;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
show_404($this->fetch_directory().$segments[0]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -26,13 +26,48 @@
|
|||||||
*/
|
*/
|
||||||
class CI_Security {
|
class CI_Security {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Random Hash for protecting URLs
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
protected $_xss_hash = '';
|
protected $_xss_hash = '';
|
||||||
|
/**
|
||||||
|
* Random Hash for Cross Site Request Forgery Protection Cookie
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
protected $_csrf_hash = '';
|
protected $_csrf_hash = '';
|
||||||
protected $_csrf_expire = 7200; // Two hours (in seconds)
|
/**
|
||||||
|
* Expiration time for Cross Site Request Forgery Protection Cookie
|
||||||
|
* Defaults to two hours (in seconds)
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
|
protected $_csrf_expire = 7200;
|
||||||
|
/**
|
||||||
|
* Token name for Cross Site Request Forgery Protection Cookie
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
protected $_csrf_token_name = 'ci_csrf_token';
|
protected $_csrf_token_name = 'ci_csrf_token';
|
||||||
|
/**
|
||||||
|
* Cookie name for Cross Site Request Forgery Protection Cookie
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
protected $_csrf_cookie_name = 'ci_csrf_token';
|
protected $_csrf_cookie_name = 'ci_csrf_token';
|
||||||
|
/**
|
||||||
/* never allowed, string replacement */
|
* List of never allowed strings
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
protected $_never_allowed_str = array(
|
protected $_never_allowed_str = array(
|
||||||
'document.cookie' => '[removed]',
|
'document.cookie' => '[removed]',
|
||||||
'document.write' => '[removed]',
|
'document.write' => '[removed]',
|
||||||
@@ -42,10 +77,17 @@ class CI_Security {
|
|||||||
'-moz-binding' => '[removed]',
|
'-moz-binding' => '[removed]',
|
||||||
'<!--' => '<!--',
|
'<!--' => '<!--',
|
||||||
'-->' => '-->',
|
'-->' => '-->',
|
||||||
'<![CDATA[' => '<![CDATA['
|
'<![CDATA[' => '<![CDATA[',
|
||||||
|
'<comment>' => '<comment>'
|
||||||
);
|
);
|
||||||
|
|
||||||
/* never allowed, regex replacement */
|
/* never allowed, regex replacement */
|
||||||
|
/**
|
||||||
|
* List of never allowed regex replacement
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
protected $_never_allowed_regex = array(
|
protected $_never_allowed_regex = array(
|
||||||
"javascript\s*:" => '[removed]',
|
"javascript\s*:" => '[removed]',
|
||||||
"expression\s*(\(|&\#40;)" => '[removed]', // CSS and IE
|
"expression\s*(\(|&\#40;)" => '[removed]', // CSS and IE
|
||||||
@@ -215,6 +257,7 @@ class CI_Security {
|
|||||||
* http://ha.ckers.org/xss.html
|
* http://ha.ckers.org/xss.html
|
||||||
*
|
*
|
||||||
* @param mixed string or array
|
* @param mixed string or array
|
||||||
|
* @param bool
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function xss_clean($str, $is_image = FALSE)
|
public function xss_clean($str, $is_image = FALSE)
|
||||||
@@ -433,15 +476,7 @@ class CI_Security {
|
|||||||
{
|
{
|
||||||
if ($this->_xss_hash == '')
|
if ($this->_xss_hash == '')
|
||||||
{
|
{
|
||||||
if (phpversion() >= 4.2)
|
mt_srand();
|
||||||
{
|
|
||||||
mt_srand();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mt_srand(hexdec(substr(md5(microtime()), -8)) & 0x7fffffff);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->_xss_hash = md5(time() + mt_rand(0, 1999999999));
|
$this->_xss_hash = md5(time() + mt_rand(0, 1999999999));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -455,14 +490,11 @@ class CI_Security {
|
|||||||
*
|
*
|
||||||
* This function is a replacement for html_entity_decode()
|
* This function is a replacement for html_entity_decode()
|
||||||
*
|
*
|
||||||
* In some versions of PHP the native function does not work
|
* The reason we are not using html_entity_decode() by itself is because
|
||||||
* when UTF-8 is the specified character set, so this gives us
|
* while it is not technically correct to leave out the semicolon
|
||||||
* a work-around. More info here:
|
* at the end of an entity most browsers will still interpret the entity
|
||||||
* http://bugs.php.net/bug.php?id=25670
|
* correctly. html_entity_decode() does not convert entities without
|
||||||
*
|
* semicolons, so we are left with our own little solution here. Bummer.
|
||||||
* NOTE: html_entity_decode() has a bug in some PHP versions when UTF-8 is the
|
|
||||||
* character set, and the PHP developers said they were not back porting the
|
|
||||||
* fix to versions other than PHP 5.x.
|
|
||||||
*
|
*
|
||||||
* @param string
|
* @param string
|
||||||
* @param string
|
* @param string
|
||||||
@@ -470,33 +502,14 @@ class CI_Security {
|
|||||||
*/
|
*/
|
||||||
public function entity_decode($str, $charset='UTF-8')
|
public function entity_decode($str, $charset='UTF-8')
|
||||||
{
|
{
|
||||||
if (stristr($str, '&') === FALSE) return $str;
|
|
||||||
|
|
||||||
// The reason we are not using html_entity_decode() by itself is because
|
|
||||||
// while it is not technically correct to leave out the semicolon
|
|
||||||
// at the end of an entity most browsers will still interpret the entity
|
|
||||||
// correctly. html_entity_decode() does not convert entities without
|
|
||||||
// semicolons, so we are left with our own little solution here. Bummer.
|
|
||||||
|
|
||||||
if (function_exists('html_entity_decode') &&
|
|
||||||
(strtolower($charset) != 'utf-8'))
|
|
||||||
{
|
|
||||||
$str = html_entity_decode($str, ENT_COMPAT, $charset);
|
|
||||||
$str = preg_replace('~&#x(0*[0-9a-f]{2,5})~ei', 'chr(hexdec("\\1"))', $str);
|
|
||||||
return preg_replace('~&#([0-9]{2,4})~e', 'chr(\\1)', $str);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Numeric Entities
|
|
||||||
$str = preg_replace('~&#x(0*[0-9a-f]{2,5});{0,1}~ei', 'chr(hexdec("\\1"))', $str);
|
|
||||||
$str = preg_replace('~&#([0-9]{2,4});{0,1}~e', 'chr(\\1)', $str);
|
|
||||||
|
|
||||||
// Literal Entities - Slightly slow so we do another check
|
|
||||||
if (stristr($str, '&') === FALSE)
|
if (stristr($str, '&') === FALSE)
|
||||||
{
|
{
|
||||||
$str = strtr($str, array_flip(get_html_translation_table(HTML_ENTITIES)));
|
return $str;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $str;
|
$str = html_entity_decode($str, ENT_COMPAT, $charset);
|
||||||
|
$str = preg_replace('~&#x(0*[0-9a-f]{2,5})~ei', 'chr(hexdec("\\1"))', $str);
|
||||||
|
return preg_replace('~&#([0-9]{2,4})~e', 'chr(\\1)', $str);
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@@ -505,6 +518,7 @@ class CI_Security {
|
|||||||
* Filename Security
|
* Filename Security
|
||||||
*
|
*
|
||||||
* @param string
|
* @param string
|
||||||
|
* @param bool
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function sanitize_filename($str, $relative_path = FALSE)
|
public function sanitize_filename($str, $relative_path = FALSE)
|
||||||
@@ -589,7 +603,7 @@ class CI_Security {
|
|||||||
protected function _remove_evil_attributes($str, $is_image)
|
protected function _remove_evil_attributes($str, $is_image)
|
||||||
{
|
{
|
||||||
// All javascript event handlers (e.g. onload, onclick, onmouseover), style, and xmlns
|
// All javascript event handlers (e.g. onload, onclick, onmouseover), style, and xmlns
|
||||||
$evil_attributes = array('on\w*', 'style', 'xmlns');
|
$evil_attributes = array('on\w*', 'style', 'xmlns', 'formaction');
|
||||||
|
|
||||||
if ($is_image === TRUE)
|
if ($is_image === TRUE)
|
||||||
{
|
{
|
||||||
@@ -601,11 +615,31 @@ class CI_Security {
|
|||||||
}
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
$str = preg_replace(
|
$count = 0;
|
||||||
"#<(/?[^><]+?)([^A-Za-z\-])(".implode('|', $evil_attributes).")(\s*=\s*)([\"][^>]*?[\"]|[\'][^>]*?[\']|[^>]*?)([\s><])([><]*)#i",
|
$attribs = array();
|
||||||
"<$1$6",
|
|
||||||
$str, -1, $count
|
// find occurrences of illegal attribute strings without quotes
|
||||||
);
|
preg_match_all("/(".implode('|', $evil_attributes).")\s*=\s*([^\s]*)/is", $str, $matches, PREG_SET_ORDER);
|
||||||
|
|
||||||
|
foreach ($matches as $attr)
|
||||||
|
{
|
||||||
|
$attribs[] = preg_quote($attr[0], '/');
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
|
||||||
|
foreach ($matches as $attr)
|
||||||
|
{
|
||||||
|
$attribs[] = preg_quote($attr[0], '/');
|
||||||
|
}
|
||||||
|
|
||||||
|
// replace illegal attribute strings that are inside an html tag
|
||||||
|
if (count($attribs) > 0)
|
||||||
|
{
|
||||||
|
$str = preg_replace("/<(\/?[^><]+?)([^A-Za-z\-])(".implode('|', $attribs).")([\s><])([><]*)/i", '<$1$2$4$5', $str, -1, $count);
|
||||||
|
}
|
||||||
|
|
||||||
} while ($count);
|
} while ($count);
|
||||||
|
|
||||||
return $str;
|
return $str;
|
||||||
|
|||||||
@@ -28,9 +28,34 @@
|
|||||||
*/
|
*/
|
||||||
class CI_URI {
|
class CI_URI {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of cached uri segments
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
var $keyval = array();
|
var $keyval = array();
|
||||||
|
/**
|
||||||
|
* Current uri string
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
var $uri_string;
|
var $uri_string;
|
||||||
|
/**
|
||||||
|
* List of uri segments
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
var $segments = array();
|
var $segments = array();
|
||||||
|
/**
|
||||||
|
* Re-indexed list of uri segments
|
||||||
|
* Starts at 1 instead of 0
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
var $rsegments = array();
|
var $rsegments = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -127,6 +152,7 @@ class CI_URI {
|
|||||||
* Set the URI String
|
* Set the URI String
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
|
* @param string
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function _set_uri_string($str)
|
function _set_uri_string($str)
|
||||||
@@ -366,6 +392,11 @@ class CI_URI {
|
|||||||
/**
|
/**
|
||||||
* Identical to above only it uses the re-routed segment array
|
* Identical to above only it uses the re-routed segment array
|
||||||
*
|
*
|
||||||
|
* @access public
|
||||||
|
* @param integer the starting segment number
|
||||||
|
* @param array an array of default values
|
||||||
|
* @return array
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
function ruri_to_assoc($n = 3, $default = array())
|
function ruri_to_assoc($n = 3, $default = array())
|
||||||
{
|
{
|
||||||
|
|||||||
0
system/core/Utf8.php
Executable file → Normal file
0
system/core/Utf8.php
Executable file → Normal file
0
system/core/index.html
Executable file → Normal file
0
system/core/index.html
Executable file → Normal file
@@ -21,6 +21,8 @@
|
|||||||
* @category Database
|
* @category Database
|
||||||
* @author ExpressionEngine Dev Team
|
* @author ExpressionEngine Dev Team
|
||||||
* @link http://codeigniter.com/user_guide/database/
|
* @link http://codeigniter.com/user_guide/database/
|
||||||
|
* @param string
|
||||||
|
* @param bool Determines if active record should be used or not
|
||||||
*/
|
*/
|
||||||
function &DB($params = '', $active_record_override = NULL)
|
function &DB($params = '', $active_record_override = NULL)
|
||||||
{
|
{
|
||||||
|
|||||||
6
system/database/DB_active_rec.php
Executable file → Normal file
6
system/database/DB_active_rec.php
Executable file → Normal file
@@ -870,11 +870,11 @@ class CI_DB_active_record extends CI_DB_driver {
|
|||||||
*/
|
*/
|
||||||
public function limit($value, $offset = '')
|
public function limit($value, $offset = '')
|
||||||
{
|
{
|
||||||
$this->ar_limit = $value;
|
$this->ar_limit = (int) $value;
|
||||||
|
|
||||||
if ($offset != '')
|
if ($offset != '')
|
||||||
{
|
{
|
||||||
$this->ar_offset = $offset;
|
$this->ar_offset = (int) $offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
@@ -1322,7 +1322,7 @@ class CI_DB_active_record extends CI_DB_driver {
|
|||||||
{
|
{
|
||||||
if ($this->db_debug)
|
if ($this->db_debug)
|
||||||
{
|
{
|
||||||
return $this->display_error('db_myst_use_index');
|
return $this->display_error('db_must_use_index');
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|||||||
2
system/database/DB_cache.php
Executable file → Normal file
2
system/database/DB_cache.php
Executable file → Normal file
@@ -33,7 +33,7 @@ class CI_DB_Cache {
|
|||||||
* Grabs the CI super object instance so we can access it.
|
* Grabs the CI super object instance so we can access it.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function CI_DB_Cache(&$db)
|
function __construct(&$db)
|
||||||
{
|
{
|
||||||
// Assign the main CI object to $this->CI
|
// Assign the main CI object to $this->CI
|
||||||
// and load the file helper since we use it a lot
|
// and load the file helper since we use it a lot
|
||||||
|
|||||||
4
system/database/DB_driver.php
Executable file → Normal file
4
system/database/DB_driver.php
Executable file → Normal file
@@ -78,7 +78,7 @@ class CI_DB_driver {
|
|||||||
*
|
*
|
||||||
* @param array
|
* @param array
|
||||||
*/
|
*/
|
||||||
function CI_DB_driver($params)
|
function __construct($params)
|
||||||
{
|
{
|
||||||
if (is_array($params))
|
if (is_array($params))
|
||||||
{
|
{
|
||||||
@@ -218,7 +218,7 @@ class CI_DB_driver {
|
|||||||
|
|
||||||
// Some DBs have functions that return the version, and don't run special
|
// Some DBs have functions that return the version, and don't run special
|
||||||
// SQL queries per se. In these instances, just return the result.
|
// SQL queries per se. In these instances, just return the result.
|
||||||
$driver_version_exceptions = array('oci8', 'sqlite');
|
$driver_version_exceptions = array('oci8', 'sqlite', 'cubrid');
|
||||||
|
|
||||||
if (in_array($this->dbdriver, $driver_version_exceptions))
|
if (in_array($this->dbdriver, $driver_version_exceptions))
|
||||||
{
|
{
|
||||||
|
|||||||
4
system/database/DB_forge.php
Executable file → Normal file
4
system/database/DB_forge.php
Executable file → Normal file
@@ -35,7 +35,7 @@ class CI_DB_forge {
|
|||||||
* Grabs the CI super object instance so we can access it.
|
* Grabs the CI super object instance so we can access it.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function CI_DB_forge()
|
function __construct()
|
||||||
{
|
{
|
||||||
// Assign the main database object to $this->db
|
// Assign the main database object to $this->db
|
||||||
$CI =& get_instance();
|
$CI =& get_instance();
|
||||||
@@ -234,7 +234,7 @@ class CI_DB_forge {
|
|||||||
show_error('A table name is required for that operation.');
|
show_error('A table name is required for that operation.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = $this->_rename_table($table_name, $new_table_name);
|
$sql = $this->_rename_table($this->db->dbprefix.$table_name, $this->db->dbprefix.$new_table_name);
|
||||||
return $this->db->query($sql);
|
return $this->db->query($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
42
system/database/DB_result.php
Executable file → Normal file
42
system/database/DB_result.php
Executable file → Normal file
@@ -45,7 +45,7 @@ class CI_DB_result {
|
|||||||
* @param string can be "object" or "array"
|
* @param string can be "object" or "array"
|
||||||
* @return mixed either a result object or array
|
* @return mixed either a result object or array
|
||||||
*/
|
*/
|
||||||
function result($type = 'object')
|
public function result($type = 'object')
|
||||||
{
|
{
|
||||||
if ($type == 'array') return $this->result_array();
|
if ($type == 'array') return $this->result_array();
|
||||||
else if ($type == 'object') return $this->result_object();
|
else if ($type == 'object') return $this->result_object();
|
||||||
@@ -60,7 +60,7 @@ class CI_DB_result {
|
|||||||
* @param class_name A string that represents the type of object you want back
|
* @param class_name A string that represents the type of object you want back
|
||||||
* @return array of objects
|
* @return array of objects
|
||||||
*/
|
*/
|
||||||
function custom_result_object($class_name)
|
public function custom_result_object($class_name)
|
||||||
{
|
{
|
||||||
if (array_key_exists($class_name, $this->custom_result_object))
|
if (array_key_exists($class_name, $this->custom_result_object))
|
||||||
{
|
{
|
||||||
@@ -100,7 +100,7 @@ class CI_DB_result {
|
|||||||
* @access public
|
* @access public
|
||||||
* @return object
|
* @return object
|
||||||
*/
|
*/
|
||||||
function result_object()
|
public function result_object()
|
||||||
{
|
{
|
||||||
if (count($this->result_object) > 0)
|
if (count($this->result_object) > 0)
|
||||||
{
|
{
|
||||||
@@ -132,7 +132,7 @@ class CI_DB_result {
|
|||||||
* @access public
|
* @access public
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function result_array()
|
public function result_array()
|
||||||
{
|
{
|
||||||
if (count($this->result_array) > 0)
|
if (count($this->result_array) > 0)
|
||||||
{
|
{
|
||||||
@@ -166,7 +166,7 @@ class CI_DB_result {
|
|||||||
* @param string can be "object" or "array"
|
* @param string can be "object" or "array"
|
||||||
* @return mixed either a result object or array
|
* @return mixed either a result object or array
|
||||||
*/
|
*/
|
||||||
function row($n = 0, $type = 'object')
|
public function row($n = 0, $type = 'object')
|
||||||
{
|
{
|
||||||
if ( ! is_numeric($n))
|
if ( ! is_numeric($n))
|
||||||
{
|
{
|
||||||
@@ -198,7 +198,7 @@ class CI_DB_result {
|
|||||||
* @access public
|
* @access public
|
||||||
* @return object
|
* @return object
|
||||||
*/
|
*/
|
||||||
function set_row($key, $value = NULL)
|
public function set_row($key, $value = NULL)
|
||||||
{
|
{
|
||||||
// We cache the row data for subsequent uses
|
// We cache the row data for subsequent uses
|
||||||
if ( ! is_array($this->row_data))
|
if ( ! is_array($this->row_data))
|
||||||
@@ -230,7 +230,7 @@ class CI_DB_result {
|
|||||||
* @access public
|
* @access public
|
||||||
* @return object
|
* @return object
|
||||||
*/
|
*/
|
||||||
function custom_row_object($n, $type)
|
public function custom_row_object($n, $type)
|
||||||
{
|
{
|
||||||
$result = $this->custom_result_object($type);
|
$result = $this->custom_result_object($type);
|
||||||
|
|
||||||
@@ -253,7 +253,7 @@ class CI_DB_result {
|
|||||||
* @access public
|
* @access public
|
||||||
* @return object
|
* @return object
|
||||||
*/
|
*/
|
||||||
function row_object($n = 0)
|
public function row_object($n = 0)
|
||||||
{
|
{
|
||||||
$result = $this->result_object();
|
$result = $this->result_object();
|
||||||
|
|
||||||
@@ -278,7 +278,7 @@ class CI_DB_result {
|
|||||||
* @access public
|
* @access public
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function row_array($n = 0)
|
public function row_array($n = 0)
|
||||||
{
|
{
|
||||||
$result = $this->result_array();
|
$result = $this->result_array();
|
||||||
|
|
||||||
@@ -304,7 +304,7 @@ class CI_DB_result {
|
|||||||
* @access public
|
* @access public
|
||||||
* @return object
|
* @return object
|
||||||
*/
|
*/
|
||||||
function first_row($type = 'object')
|
public function first_row($type = 'object')
|
||||||
{
|
{
|
||||||
$result = $this->result($type);
|
$result = $this->result($type);
|
||||||
|
|
||||||
@@ -323,7 +323,7 @@ class CI_DB_result {
|
|||||||
* @access public
|
* @access public
|
||||||
* @return object
|
* @return object
|
||||||
*/
|
*/
|
||||||
function last_row($type = 'object')
|
public function last_row($type = 'object')
|
||||||
{
|
{
|
||||||
$result = $this->result($type);
|
$result = $this->result($type);
|
||||||
|
|
||||||
@@ -342,7 +342,7 @@ class CI_DB_result {
|
|||||||
* @access public
|
* @access public
|
||||||
* @return object
|
* @return object
|
||||||
*/
|
*/
|
||||||
function next_row($type = 'object')
|
public function next_row($type = 'object')
|
||||||
{
|
{
|
||||||
$result = $this->result($type);
|
$result = $this->result($type);
|
||||||
|
|
||||||
@@ -367,7 +367,7 @@ class CI_DB_result {
|
|||||||
* @access public
|
* @access public
|
||||||
* @return object
|
* @return object
|
||||||
*/
|
*/
|
||||||
function previous_row($type = 'object')
|
public function previous_row($type = 'object')
|
||||||
{
|
{
|
||||||
$result = $this->result($type);
|
$result = $this->result($type);
|
||||||
|
|
||||||
@@ -394,14 +394,14 @@ class CI_DB_result {
|
|||||||
* operational due to the unavailability of the database resource IDs with
|
* operational due to the unavailability of the database resource IDs with
|
||||||
* cached results.
|
* cached results.
|
||||||
*/
|
*/
|
||||||
function num_rows() { return $this->num_rows; }
|
public function num_rows() { return $this->num_rows; }
|
||||||
function num_fields() { return 0; }
|
public function num_fields() { return 0; }
|
||||||
function list_fields() { return array(); }
|
public function list_fields() { return array(); }
|
||||||
function field_data() { return array(); }
|
public function field_data() { return array(); }
|
||||||
function free_result() { return TRUE; }
|
public function free_result() { return TRUE; }
|
||||||
function _data_seek() { return TRUE; }
|
protected function _data_seek() { return TRUE; }
|
||||||
function _fetch_assoc() { return array(); }
|
protected function _fetch_assoc() { return array(); }
|
||||||
function _fetch_object() { return array(); }
|
protected function _fetch_object() { return array(); }
|
||||||
|
|
||||||
}
|
}
|
||||||
// END DB_result class
|
// END DB_result class
|
||||||
|
|||||||
2
system/database/DB_utility.php
Executable file → Normal file
2
system/database/DB_utility.php
Executable file → Normal file
@@ -33,7 +33,7 @@ class CI_DB_utility extends CI_DB_forge {
|
|||||||
* Grabs the CI super object instance so we can access it.
|
* Grabs the CI super object instance so we can access it.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function CI_DB_utility()
|
function __construct()
|
||||||
{
|
{
|
||||||
// Assign the main database object to $this->db
|
// Assign the main database object to $this->db
|
||||||
$CI =& get_instance();
|
$CI =& get_instance();
|
||||||
|
|||||||
792
system/database/drivers/cubrid/cubrid_driver.php
Normal file
792
system/database/drivers/cubrid/cubrid_driver.php
Normal file
@@ -0,0 +1,792 @@
|
|||||||
|
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||||
|
/**
|
||||||
|
* CodeIgniter
|
||||||
|
*
|
||||||
|
* An open source application development framework for PHP 5.1.6 or newer
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @author Esen Sagynov
|
||||||
|
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
|
||||||
|
* @license http://codeigniter.com/user_guide/license.html
|
||||||
|
* @link http://codeigniter.com
|
||||||
|
* @since Version 2.0.2
|
||||||
|
* @filesource
|
||||||
|
*/
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CUBRID 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 Esen Sagynov
|
||||||
|
* @link http://codeigniter.com/user_guide/database/
|
||||||
|
*/
|
||||||
|
class CI_DB_cubrid_driver extends CI_DB {
|
||||||
|
|
||||||
|
// Default CUBRID Broker port. Will be used unless user
|
||||||
|
// explicitly specifies another one.
|
||||||
|
const DEFAULT_PORT = 33000;
|
||||||
|
|
||||||
|
var $dbdriver = 'cubrid';
|
||||||
|
|
||||||
|
// The character used for escaping - no need in CUBRID
|
||||||
|
var $_escape_char = '';
|
||||||
|
|
||||||
|
// clause and character used for LIKE escape sequences - not used in CUBRID
|
||||||
|
var $_like_escape_str = '';
|
||||||
|
var $_like_escape_chr = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The syntax to count rows is slightly different across different
|
||||||
|
* database engines, so this string appears in each driver and is
|
||||||
|
* used for the count_all() and count_all_results() functions.
|
||||||
|
*/
|
||||||
|
var $_count_string = 'SELECT COUNT(*) AS ';
|
||||||
|
var $_random_keyword = ' RAND()'; // database specific random keyword
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Non-persistent database connection
|
||||||
|
*
|
||||||
|
* @access private called by the base class
|
||||||
|
* @return resource
|
||||||
|
*/
|
||||||
|
function db_connect()
|
||||||
|
{
|
||||||
|
// If no port is defined by the user, use the default value
|
||||||
|
if ($this->port == '')
|
||||||
|
{
|
||||||
|
$this->port = self::DEFAULT_PORT;
|
||||||
|
}
|
||||||
|
|
||||||
|
$conn = cubrid_connect($this->hostname, $this->port, $this->database, $this->username, $this->password);
|
||||||
|
|
||||||
|
if ($conn)
|
||||||
|
{
|
||||||
|
// Check if a user wants to run queries in dry, i.e. run the
|
||||||
|
// queries but not commit them.
|
||||||
|
if (isset($this->auto_commit) && ! $this->auto_commit)
|
||||||
|
{
|
||||||
|
cubrid_set_autocommit($conn, CUBRID_AUTOCOMMIT_FALSE);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cubrid_set_autocommit($conn, CUBRID_AUTOCOMMIT_TRUE);
|
||||||
|
$this->auto_commit = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $conn;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Persistent database connection
|
||||||
|
* In CUBRID persistent DB connection is supported natively in CUBRID
|
||||||
|
* engine which can be configured in the CUBRID Broker configuration
|
||||||
|
* file by setting the CCI_PCONNECT parameter to ON. In that case, all
|
||||||
|
* connections established between the client application and the
|
||||||
|
* server will become persistent. This is calling the same
|
||||||
|
* @cubrid_connect function will establish persisten connection
|
||||||
|
* considering that the CCI_PCONNECT is ON.
|
||||||
|
*
|
||||||
|
* @access private called by the base class
|
||||||
|
* @return resource
|
||||||
|
*/
|
||||||
|
function db_pconnect()
|
||||||
|
{
|
||||||
|
return $this->db_connect();
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reconnect
|
||||||
|
*
|
||||||
|
* Keep / reestablish the db connection if no queries have been
|
||||||
|
* sent for a length of time exceeding the server's idle timeout
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function reconnect()
|
||||||
|
{
|
||||||
|
if (cubrid_ping($this->conn_id) === FALSE)
|
||||||
|
{
|
||||||
|
$this->conn_id = FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Select the database
|
||||||
|
*
|
||||||
|
* @access private called by the base class
|
||||||
|
* @return resource
|
||||||
|
*/
|
||||||
|
function db_select()
|
||||||
|
{
|
||||||
|
// In CUBRID there is no need to select a database as the database
|
||||||
|
// is chosen at the connection time.
|
||||||
|
// So, to determine if the database is "selected", all we have to
|
||||||
|
// do is ping the server and return that value.
|
||||||
|
return cubrid_ping($this->conn_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set client character set
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param string
|
||||||
|
* @param string
|
||||||
|
* @return resource
|
||||||
|
*/
|
||||||
|
function db_set_charset($charset, $collation)
|
||||||
|
{
|
||||||
|
// In CUBRID, there is no need to set charset or collation.
|
||||||
|
// This is why returning true will allow the application continue
|
||||||
|
// its normal process.
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Version number query string
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the query
|
||||||
|
*
|
||||||
|
* @access private called by the base class
|
||||||
|
* @param string an SQL query
|
||||||
|
* @return resource
|
||||||
|
*/
|
||||||
|
function _execute($sql)
|
||||||
|
{
|
||||||
|
$sql = $this->_prep_query($sql);
|
||||||
|
return @cubrid_query($sql, $this->conn_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prep the query
|
||||||
|
*
|
||||||
|
* If needed, each database adapter can prep the query string
|
||||||
|
*
|
||||||
|
* @access private called by execute()
|
||||||
|
* @param string an SQL query
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function _prep_query($sql)
|
||||||
|
{
|
||||||
|
// No need to prepare
|
||||||
|
return $sql;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Begin Transaction
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
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;
|
||||||
|
|
||||||
|
if (cubrid_get_autocommit($this->conn_id))
|
||||||
|
{
|
||||||
|
cubrid_set_autocommit($this->conn_id, CUBRID_AUTOCOMMIT_FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Commit Transaction
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
cubrid_commit($this->conn_id);
|
||||||
|
|
||||||
|
if ($this->auto_commit && ! cubrid_get_autocommit($this->conn_id))
|
||||||
|
{
|
||||||
|
cubrid_set_autocommit($this->conn_id, CUBRID_AUTOCOMMIT_TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rollback Transaction
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
cubrid_rollback($this->conn_id);
|
||||||
|
|
||||||
|
if ($this->auto_commit && ! cubrid_get_autocommit($this->conn_id))
|
||||||
|
{
|
||||||
|
cubrid_set_autocommit($this->conn_id, CUBRID_AUTOCOMMIT_TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Escape String
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param string
|
||||||
|
* @param bool whether or not the string will be used in a LIKE condition
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function escape_str($str, $like = FALSE)
|
||||||
|
{
|
||||||
|
if (is_array($str))
|
||||||
|
{
|
||||||
|
foreach ($str as $key => $val)
|
||||||
|
{
|
||||||
|
$str[$key] = $this->escape_str($val, $like);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $str;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (function_exists('cubrid_real_escape_string') AND is_resource($this->conn_id))
|
||||||
|
{
|
||||||
|
$str = cubrid_real_escape_string($str, $this->conn_id);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$str = addslashes($str);
|
||||||
|
}
|
||||||
|
|
||||||
|
// escape LIKE condition wildcards
|
||||||
|
if ($like === TRUE)
|
||||||
|
{
|
||||||
|
$str = str_replace(array('%', '_'), array('\\%', '\\_'), $str);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $str;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Affected Rows
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return integer
|
||||||
|
*/
|
||||||
|
function affected_rows()
|
||||||
|
{
|
||||||
|
return @cubrid_affected_rows($this->conn_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Insert ID
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return integer
|
||||||
|
*/
|
||||||
|
function insert_id()
|
||||||
|
{
|
||||||
|
return @cubrid_insert_id($this->conn_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* "Count All" query
|
||||||
|
*
|
||||||
|
* Generates a platform-specific query string that counts all records in
|
||||||
|
* the specified table
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param string
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
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
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
* @param boolean
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function _list_tables($prefix_limit = FALSE)
|
||||||
|
{
|
||||||
|
$sql = "SHOW TABLES";
|
||||||
|
|
||||||
|
if ($prefix_limit !== FALSE AND $this->dbprefix != '')
|
||||||
|
{
|
||||||
|
$sql .= " LIKE '".$this->escape_like_str($this->dbprefix)."%'";
|
||||||
|
}
|
||||||
|
|
||||||
|
return $sql;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show column query
|
||||||
|
*
|
||||||
|
* Generates a platform-specific query string so that the column names can be fetched
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param string the table name
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function _list_columns($table = '')
|
||||||
|
{
|
||||||
|
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
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param string the table name
|
||||||
|
* @return object
|
||||||
|
*/
|
||||||
|
function _field_data($table)
|
||||||
|
{
|
||||||
|
return "SELECT * FROM ".$table." LIMIT 1";
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The error message string
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function _error_message()
|
||||||
|
{
|
||||||
|
return cubrid_error($this->conn_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The error message number
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
* @return integer
|
||||||
|
*/
|
||||||
|
function _error_number()
|
||||||
|
{
|
||||||
|
return cubrid_errno($this->conn_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Escape the SQL Identifiers
|
||||||
|
*
|
||||||
|
* This function escapes column and table names
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
* @param string
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function _escape_identifiers($item)
|
||||||
|
{
|
||||||
|
if ($this->_escape_char == '')
|
||||||
|
{
|
||||||
|
return $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 function implicitly groups FROM tables so there is no confusion
|
||||||
|
* about operator precedence in harmony with SQL standards
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param type
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
|
function _from_tables($tables)
|
||||||
|
{
|
||||||
|
if ( ! is_array($tables))
|
||||||
|
{
|
||||||
|
$tables = array($tables);
|
||||||
|
}
|
||||||
|
|
||||||
|
return '('.implode(', ', $tables).')';
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Insert statement
|
||||||
|
*
|
||||||
|
* Generates a platform-specific insert string from the supplied data
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param string the table name
|
||||||
|
* @param array the insert keys
|
||||||
|
* @param array the insert values
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function _insert($table, $keys, $values)
|
||||||
|
{
|
||||||
|
return "INSERT INTO ".$table." (\"".implode('", "', $keys)."\") VALUES (".implode(', ', $values).")";
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replace statement
|
||||||
|
*
|
||||||
|
* Generates a platform-specific replace string from the supplied data
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param string the table name
|
||||||
|
* @param array the insert keys
|
||||||
|
* @param array the insert values
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function _replace($table, $keys, $values)
|
||||||
|
{
|
||||||
|
return "REPLACE INTO ".$table." (\"".implode('", "', $keys)."\") VALUES (".implode(', ', $values).")";
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Insert_batch statement
|
||||||
|
*
|
||||||
|
* Generates a platform-specific insert string from the supplied data
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param string the table name
|
||||||
|
* @param array the insert keys
|
||||||
|
* @param array the insert values
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function _insert_batch($table, $keys, $values)
|
||||||
|
{
|
||||||
|
return "INSERT INTO ".$table." (\"".implode('", "', $keys)."\") VALUES ".implode(', ', $values);
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update statement
|
||||||
|
*
|
||||||
|
* Generates a platform-specific update string from the supplied data
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param string the table name
|
||||||
|
* @param array the update data
|
||||||
|
* @param array the where clause
|
||||||
|
* @param array the orderby clause
|
||||||
|
* @param array the limit clause
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
|
||||||
|
{
|
||||||
|
foreach ($values as $key => $val)
|
||||||
|
{
|
||||||
|
$valstr[] = sprintf('"%s" = %s', $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;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update_Batch statement
|
||||||
|
*
|
||||||
|
* Generates a platform-specific batch update string from the supplied data
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param string the table name
|
||||||
|
* @param array the update data
|
||||||
|
* @param array the where clause
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function _update_batch($table, $values, $index, $where = NULL)
|
||||||
|
{
|
||||||
|
$ids = array();
|
||||||
|
$where = ($where != '' AND count($where) >=1) ? implode(" ", $where).' AND ' : '';
|
||||||
|
|
||||||
|
foreach ($values as $key => $val)
|
||||||
|
{
|
||||||
|
$ids[] = $val[$index];
|
||||||
|
|
||||||
|
foreach (array_keys($val) as $field)
|
||||||
|
{
|
||||||
|
if ($field != $index)
|
||||||
|
{
|
||||||
|
$final[$field][] = 'WHEN '.$index.' = '.$val[$index].' THEN '.$val[$field];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql = "UPDATE ".$table." SET ";
|
||||||
|
$cases = '';
|
||||||
|
|
||||||
|
foreach ($final as $k => $v)
|
||||||
|
{
|
||||||
|
$cases .= $k.' = CASE '."\n";
|
||||||
|
foreach ($v as $row)
|
||||||
|
{
|
||||||
|
$cases .= $row."\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
$cases .= 'ELSE '.$k.' END, ';
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql .= substr($cases, 0, -2);
|
||||||
|
|
||||||
|
$sql .= ' WHERE '.$where.$index.' IN ('.implode(',', $ids).')';
|
||||||
|
|
||||||
|
return $sql;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Truncate statement
|
||||||
|
*
|
||||||
|
* Generates a platform-specific truncate string from the supplied data
|
||||||
|
* If the database does not support the truncate() command
|
||||||
|
* This function maps to "DELETE FROM table"
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param string the table name
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function _truncate($table)
|
||||||
|
{
|
||||||
|
return "TRUNCATE ".$table;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete statement
|
||||||
|
*
|
||||||
|
* Generates a platform-specific delete string from the supplied data
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param string the table name
|
||||||
|
* @param array the where clause
|
||||||
|
* @param string the limit clause
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function _delete($table, $where = array(), $like = array(), $limit = FALSE)
|
||||||
|
{
|
||||||
|
$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;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Limit string
|
||||||
|
*
|
||||||
|
* Generates a platform-specific LIMIT clause
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param string the sql query string
|
||||||
|
* @param integer the number of rows to limit the query to
|
||||||
|
* @param integer the offset value
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function _limit($sql, $limit, $offset)
|
||||||
|
{
|
||||||
|
if ($offset == 0)
|
||||||
|
{
|
||||||
|
$offset = '';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$offset .= ", ";
|
||||||
|
}
|
||||||
|
|
||||||
|
return $sql."LIMIT ".$offset.$limit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Close DB Connection
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param resource
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function _close($conn_id)
|
||||||
|
{
|
||||||
|
@cubrid_close($conn_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* End of file cubrid_driver.php */
|
||||||
|
/* Location: ./system/database/drivers/cubrid/cubrid_driver.php */
|
||||||
288
system/database/drivers/cubrid/cubrid_forge.php
Normal file
288
system/database/drivers/cubrid/cubrid_forge.php
Normal file
@@ -0,0 +1,288 @@
|
|||||||
|
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||||
|
/**
|
||||||
|
* CodeIgniter
|
||||||
|
*
|
||||||
|
* An open source application development framework for PHP 5.1.6 or newer
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @author Esen Sagynov
|
||||||
|
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
|
||||||
|
* @license http://codeigniter.com/user_guide/license.html
|
||||||
|
* @link http://codeigniter.com
|
||||||
|
* @since Version 1.0
|
||||||
|
* @filesource
|
||||||
|
*/
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CUBRID Forge Class
|
||||||
|
*
|
||||||
|
* @category Database
|
||||||
|
* @author Esen Sagynov
|
||||||
|
* @link http://codeigniter.com/user_guide/database/
|
||||||
|
*/
|
||||||
|
class CI_DB_cubrid_forge extends CI_DB_forge {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create database
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
* @param string the database name
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
function _create_database($name)
|
||||||
|
{
|
||||||
|
// CUBRID does not allow to create a database in SQL. The GUI tools
|
||||||
|
// have to be used for this purpose.
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Drop database
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
* @param string the database name
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
function _drop_database($name)
|
||||||
|
{
|
||||||
|
// CUBRID does not allow to drop a database in SQL. The GUI tools
|
||||||
|
// have to be used for this purpose.
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process Fields
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
* @param mixed the fields
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function _process_fields($fields)
|
||||||
|
{
|
||||||
|
$current_field_count = 0;
|
||||||
|
$sql = '';
|
||||||
|
|
||||||
|
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) . "\"";
|
||||||
|
|
||||||
|
if (array_key_exists('NAME', $attributes))
|
||||||
|
{
|
||||||
|
$sql .= ' '.$this->db->_protect_identifiers($attributes['NAME']).' ';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array_key_exists('TYPE', $attributes))
|
||||||
|
{
|
||||||
|
$sql .= ' '.$attributes['TYPE'];
|
||||||
|
|
||||||
|
if (array_key_exists('CONSTRAINT', $attributes))
|
||||||
|
{
|
||||||
|
switch ($attributes['TYPE'])
|
||||||
|
{
|
||||||
|
case 'decimal':
|
||||||
|
case 'float':
|
||||||
|
case 'numeric':
|
||||||
|
$sql .= '('.implode(',', $attributes['CONSTRAINT']).')';
|
||||||
|
break;
|
||||||
|
case 'enum': // As of version 8.4.0 CUBRID does not support
|
||||||
|
// enum data type.
|
||||||
|
break;
|
||||||
|
case 'set':
|
||||||
|
$sql .= '("'.implode('","', $attributes['CONSTRAINT']).'")';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$sql .= '('.$attributes['CONSTRAINT'].')';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE)
|
||||||
|
{
|
||||||
|
//$sql .= ' UNSIGNED';
|
||||||
|
// As of version 8.4.0 CUBRID does not support UNSIGNED INTEGER data type.
|
||||||
|
// Will be supported in the next release as a part of MySQL Compatibility.
|
||||||
|
}
|
||||||
|
|
||||||
|
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';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array_key_exists('UNIQUE', $attributes) && $attributes['UNIQUE'] === TRUE)
|
||||||
|
{
|
||||||
|
$sql .= ' UNIQUE';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// don't add a comma on the end of the last field
|
||||||
|
if (++$current_field_count < count($fields))
|
||||||
|
{
|
||||||
|
$sql .= ',';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $sql;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create Table
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
* @param string the table name
|
||||||
|
* @param mixed the fields
|
||||||
|
* @param mixed primary key(s)
|
||||||
|
* @param mixed key(s)
|
||||||
|
* @param boolean should 'IF NOT EXISTS' be added to the SQL
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
|
||||||
|
{
|
||||||
|
$sql = 'CREATE TABLE ';
|
||||||
|
|
||||||
|
if ($if_not_exists === TRUE)
|
||||||
|
{
|
||||||
|
//$sql .= 'IF NOT EXISTS ';
|
||||||
|
// As of version 8.4.0 CUBRID does not support this SQL syntax.
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql .= $this->db->_escape_identifiers($table)." (";
|
||||||
|
|
||||||
|
$sql .= $this->_process_fields($fields);
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
$sql .= ",\n\tCONSTRAINT " . $key_name . " PRIMARY KEY(" . implode(', ', $primary_keys) . ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_array($keys) && count($keys) > 0)
|
||||||
|
{
|
||||||
|
foreach ($keys as $key)
|
||||||
|
{
|
||||||
|
if (is_array($key))
|
||||||
|
{
|
||||||
|
$key_name = $this->db->_protect_identifiers(implode('_', $key));
|
||||||
|
$key = $this->db->_protect_identifiers($key);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$key_name = $this->db->_protect_identifiers($key);
|
||||||
|
$key = array($key_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql .= ",\n\tKEY \"{$key_name}\" (" . implode(', ', $key) . ")";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql .= "\n);";
|
||||||
|
|
||||||
|
return $sql;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Drop Table
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function _drop_table($table)
|
||||||
|
{
|
||||||
|
return "DROP TABLE IF EXISTS ".$this->db->_escape_identifiers($table);
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alter table query
|
||||||
|
*
|
||||||
|
* Generates a platform-specific query so that a table can be altered
|
||||||
|
* Called by add_column(), drop_column(), and column_alter(),
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
* @param string the ALTER type (ADD, DROP, CHANGE)
|
||||||
|
* @param string the column name
|
||||||
|
* @param array fields
|
||||||
|
* @param string the field after which we should add the new field
|
||||||
|
* @return object
|
||||||
|
*/
|
||||||
|
function _alter_table($alter_type, $table, $fields, $after_field = '')
|
||||||
|
{
|
||||||
|
$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);
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql .= $this->_process_fields($fields);
|
||||||
|
|
||||||
|
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
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
* @param string the old table name
|
||||||
|
* @param string the new table name
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* End of file cubrid_forge.php */
|
||||||
|
/* Location: ./system/database/drivers/cubrid/cubrid_forge.php */
|
||||||
202
system/database/drivers/cubrid/cubrid_result.php
Normal file
202
system/database/drivers/cubrid/cubrid_result.php
Normal file
@@ -0,0 +1,202 @@
|
|||||||
|
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||||
|
/**
|
||||||
|
* CodeIgniter
|
||||||
|
*
|
||||||
|
* An open source application development framework for PHP 5.1.6 or newer
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @author Esen Sagynov
|
||||||
|
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
|
||||||
|
* @license http://codeigniter.com/user_guide/license.html
|
||||||
|
* @link http://codeigniter.com
|
||||||
|
* @since Version 2.0.2
|
||||||
|
* @filesource
|
||||||
|
*/
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CUBRID Result Class
|
||||||
|
*
|
||||||
|
* This class extends the parent result class: CI_DB_result
|
||||||
|
*
|
||||||
|
* @category Database
|
||||||
|
* @author Esen Sagynov
|
||||||
|
* @link http://codeigniter.com/user_guide/database/
|
||||||
|
*/
|
||||||
|
class CI_DB_cubrid_result extends CI_DB_result {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Number of rows in the result set
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return integer
|
||||||
|
*/
|
||||||
|
function num_rows()
|
||||||
|
{
|
||||||
|
return @cubrid_num_rows($this->result_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Number of fields in the result set
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return integer
|
||||||
|
*/
|
||||||
|
function num_fields()
|
||||||
|
{
|
||||||
|
return @cubrid_num_fields($this->result_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch Field Names
|
||||||
|
*
|
||||||
|
* Generates an array of column names
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
function list_fields()
|
||||||
|
{
|
||||||
|
return cubrid_column_names($this->result_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Field data
|
||||||
|
*
|
||||||
|
* Generates an array of objects containing field meta-data
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
function field_data()
|
||||||
|
{
|
||||||
|
$retval = array();
|
||||||
|
|
||||||
|
$tablePrimaryKeys = array();
|
||||||
|
|
||||||
|
while ($field = cubrid_fetch_field($this->result_id))
|
||||||
|
{
|
||||||
|
$F = new stdClass();
|
||||||
|
$F->name = $field->name;
|
||||||
|
$F->type = $field->type;
|
||||||
|
$F->default = $field->def;
|
||||||
|
$F->max_length = $field->max_length;
|
||||||
|
|
||||||
|
// At this moment primary_key property is not returned when
|
||||||
|
// cubrid_fetch_field is called. The following code will
|
||||||
|
// provide a patch for it. primary_key property will be added
|
||||||
|
// in the next release.
|
||||||
|
|
||||||
|
// TODO: later version of CUBRID will provide primary_key
|
||||||
|
// property.
|
||||||
|
// When PK is defined in CUBRID, an index is automatically
|
||||||
|
// created in the db_index system table in the form of
|
||||||
|
// pk_tblname_fieldname. So the following will count how many
|
||||||
|
// columns are there which satisfy this format.
|
||||||
|
// The query will search for exact single columns, thus
|
||||||
|
// compound PK is not supported.
|
||||||
|
$res = cubrid_query($this->conn_id,
|
||||||
|
"SELECT COUNT(*) FROM db_index WHERE class_name = '" . $field->table .
|
||||||
|
"' AND is_primary_key = 'YES' AND index_name = 'pk_" .
|
||||||
|
$field->table . "_" . $field->name . "'"
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($res)
|
||||||
|
{
|
||||||
|
$row = cubrid_fetch_array($res, CUBRID_NUM);
|
||||||
|
$F->primary_key = ($row[0] > 0 ? 1 : null);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$F->primary_key = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_resource($res))
|
||||||
|
{
|
||||||
|
cubrid_close_request($res);
|
||||||
|
$this->result_id = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
$retval[] = $F;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Free the result
|
||||||
|
*
|
||||||
|
* @return null
|
||||||
|
*/
|
||||||
|
function free_result()
|
||||||
|
{
|
||||||
|
if(is_resource($this->result_id) ||
|
||||||
|
get_resource_type($this->result_id) == "Unknown" &&
|
||||||
|
preg_match('/Resource id #/', strval($this->result_id)))
|
||||||
|
{
|
||||||
|
cubrid_close_request($this->result_id);
|
||||||
|
$this->result_id = FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
function _data_seek($n = 0)
|
||||||
|
{
|
||||||
|
return cubrid_data_seek($this->result_id, $n);
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Result - associative array
|
||||||
|
*
|
||||||
|
* Returns the result set as an array
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
function _fetch_assoc()
|
||||||
|
{
|
||||||
|
return cubrid_fetch_assoc($this->result_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Result - object
|
||||||
|
*
|
||||||
|
* Returns the result set as an object
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
* @return object
|
||||||
|
*/
|
||||||
|
function _fetch_object()
|
||||||
|
{
|
||||||
|
return cubrid_fetch_object($this->result_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* End of file cubrid_result.php */
|
||||||
|
/* Location: ./system/database/drivers/cubrid/cubrid_result.php */
|
||||||
108
system/database/drivers/cubrid/cubrid_utility.php
Normal file
108
system/database/drivers/cubrid/cubrid_utility.php
Normal file
@@ -0,0 +1,108 @@
|
|||||||
|
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||||
|
/**
|
||||||
|
* CodeIgniter
|
||||||
|
*
|
||||||
|
* An open source application development framework for PHP 5.1.6 or newer
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @author Esen Sagynov
|
||||||
|
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
|
||||||
|
* @license http://codeigniter.com/user_guide/license.html
|
||||||
|
* @link http://codeigniter.com
|
||||||
|
* @since Version 1.0
|
||||||
|
* @filesource
|
||||||
|
*/
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CUBRID Utility Class
|
||||||
|
*
|
||||||
|
* @category Database
|
||||||
|
* @author Esen Sagynov
|
||||||
|
* @link http://codeigniter.com/user_guide/database/
|
||||||
|
*/
|
||||||
|
class CI_DB_cubrid_utility extends CI_DB_utility {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List databases
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
function _list_databases()
|
||||||
|
{
|
||||||
|
// CUBRID does not allow to see the list of all databases on the
|
||||||
|
// server. It is the way its architecture is designed. Every
|
||||||
|
// database is independent and isolated.
|
||||||
|
// For this reason we can return only the name of the currect
|
||||||
|
// connected database.
|
||||||
|
if ($this->conn_id)
|
||||||
|
{
|
||||||
|
return "SELECT '" . $this->database . "'";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Optimize table query
|
||||||
|
*
|
||||||
|
* Generates a platform-specific query so that a table can be optimized
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
* @param string the table name
|
||||||
|
* @return object
|
||||||
|
* @link http://www.cubrid.org/manual/840/en/Optimize%20Database
|
||||||
|
*/
|
||||||
|
function _optimize_table($table)
|
||||||
|
{
|
||||||
|
// No SQL based support in CUBRID as of version 8.4.0. Database or
|
||||||
|
// table optimization can be performed using CUBRID Manager
|
||||||
|
// database administration tool. See the link above for more info.
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Repair table query
|
||||||
|
*
|
||||||
|
* Generates a platform-specific query so that a table can be repaired
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
* @param string the table name
|
||||||
|
* @return object
|
||||||
|
* @link http://www.cubrid.org/manual/840/en/Checking%20Database%20Consistency
|
||||||
|
*/
|
||||||
|
function _repair_table($table)
|
||||||
|
{
|
||||||
|
// Not supported in CUBRID as of version 8.4.0. Database or
|
||||||
|
// table consistency can be checked using CUBRID Manager
|
||||||
|
// database administration tool. See the link above for more info.
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
/**
|
||||||
|
* CUBRID Export
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
* @param array Preferences
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
function _backup($params = array())
|
||||||
|
{
|
||||||
|
// No SQL based support in CUBRID as of version 8.4.0. Database or
|
||||||
|
// table backup can be performed using CUBRID Manager
|
||||||
|
// database administration tool.
|
||||||
|
return $this->db->display_error('db_unsuported_feature');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* End of file cubrid_utility.php */
|
||||||
|
/* Location: ./system/database/drivers/cubrid/cubrid_utility.php */
|
||||||
10
system/database/drivers/cubrid/index.html
Normal file
10
system/database/drivers/cubrid/index.html
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>403 Forbidden</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<p>Directory access is forbidden.</p>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
0
system/database/drivers/index.html
Executable file → Normal file
0
system/database/drivers/index.html
Executable file → Normal file
0
system/database/drivers/mssql/index.html
Executable file → Normal file
0
system/database/drivers/mssql/index.html
Executable file → Normal file
1
system/database/drivers/mssql/mssql_driver.php
Executable file → Normal file
1
system/database/drivers/mssql/mssql_driver.php
Executable file → Normal file
@@ -367,6 +367,7 @@ class CI_DB_mssql_driver extends CI_DB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$row = $query->row();
|
$row = $query->row();
|
||||||
|
$this->_reset_select();
|
||||||
return (int) $row->numrows;
|
return (int) $row->numrows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
0
system/database/drivers/mssql/mssql_forge.php
Executable file → Normal file
0
system/database/drivers/mssql/mssql_forge.php
Executable file → Normal file
0
system/database/drivers/mssql/mssql_result.php
Executable file → Normal file
0
system/database/drivers/mssql/mssql_result.php
Executable file → Normal file
0
system/database/drivers/mssql/mssql_utility.php
Executable file → Normal file
0
system/database/drivers/mssql/mssql_utility.php
Executable file → Normal file
0
system/database/drivers/mysql/index.html
Executable file → Normal file
0
system/database/drivers/mysql/index.html
Executable file → Normal file
14
system/database/drivers/mysql/mysql_driver.php
Executable file → Normal file
14
system/database/drivers/mysql/mysql_driver.php
Executable file → Normal file
@@ -54,6 +54,9 @@ class CI_DB_mysql_driver extends CI_DB {
|
|||||||
var $_count_string = 'SELECT COUNT(*) AS ';
|
var $_count_string = 'SELECT COUNT(*) AS ';
|
||||||
var $_random_keyword = ' RAND()'; // database specific random keyword
|
var $_random_keyword = ' RAND()'; // database specific random keyword
|
||||||
|
|
||||||
|
// whether SET NAMES must be used to set the character set
|
||||||
|
var $use_set_names;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Non-persistent database connection
|
* Non-persistent database connection
|
||||||
*
|
*
|
||||||
@@ -132,15 +135,13 @@ class CI_DB_mysql_driver extends CI_DB {
|
|||||||
*/
|
*/
|
||||||
function db_set_charset($charset, $collation)
|
function db_set_charset($charset, $collation)
|
||||||
{
|
{
|
||||||
static $use_set_names;
|
if ( ! isset($this->use_set_names))
|
||||||
|
|
||||||
if ( ! isset($use_set_names))
|
|
||||||
{
|
{
|
||||||
// mysql_set_charset() requires PHP >= 5.2.3 and MySQL >= 5.0.7, use SET NAMES as fallback
|
// mysql_set_charset() requires PHP >= 5.2.3 and MySQL >= 5.0.7, use SET NAMES as fallback
|
||||||
$use_set_names = (version_compare(PHP_VERSION, '5.2.3', '>=') && version_compare(mysql_get_server_info(), '5.0.7', '>=')) ? FALSE : TRUE;
|
$this->use_set_names = (version_compare(PHP_VERSION, '5.2.3', '>=') && version_compare(mysql_get_server_info(), '5.0.7', '>=')) ? FALSE : TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($use_set_names)
|
if ($this->use_set_names === TRUE)
|
||||||
{
|
{
|
||||||
return @mysql_query("SET NAMES '".$this->escape_str($charset)."' COLLATE '".$this->escape_str($collation)."'", $this->conn_id);
|
return @mysql_query("SET NAMES '".$this->escape_str($charset)."' COLLATE '".$this->escape_str($collation)."'", $this->conn_id);
|
||||||
}
|
}
|
||||||
@@ -384,6 +385,7 @@ class CI_DB_mysql_driver extends CI_DB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$row = $query->row();
|
$row = $query->row();
|
||||||
|
$this->_reset_select();
|
||||||
return (int) $row->numrows;
|
return (int) $row->numrows;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -439,7 +441,7 @@ class CI_DB_mysql_driver extends CI_DB {
|
|||||||
*/
|
*/
|
||||||
function _field_data($table)
|
function _field_data($table)
|
||||||
{
|
{
|
||||||
return "SELECT * FROM ".$table." LIMIT 1";
|
return "DESCRIBE ".$table;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|||||||
0
system/database/drivers/mysql/mysql_forge.php
Executable file → Normal file
0
system/database/drivers/mysql/mysql_forge.php
Executable file → Normal file
17
system/database/drivers/mysql/mysql_result.php
Executable file → Normal file
17
system/database/drivers/mysql/mysql_result.php
Executable file → Normal file
@@ -84,14 +84,19 @@ class CI_DB_mysql_result extends CI_DB_result {
|
|||||||
function field_data()
|
function field_data()
|
||||||
{
|
{
|
||||||
$retval = array();
|
$retval = array();
|
||||||
while ($field = mysql_fetch_field($this->result_id))
|
while ($field = mysql_fetch_object($this->result_id))
|
||||||
{
|
{
|
||||||
|
preg_match('/([a-zA-Z]+)(\(\d+\))?/', $field->Type, $matches);
|
||||||
|
|
||||||
|
$type = (array_key_exists(1, $matches)) ? $matches[1] : NULL;
|
||||||
|
$length = (array_key_exists(2, $matches)) ? preg_replace('/[^\d]/', '', $matches[2]) : NULL;
|
||||||
|
|
||||||
$F = new stdClass();
|
$F = new stdClass();
|
||||||
$F->name = $field->name;
|
$F->name = $field->Field;
|
||||||
$F->type = $field->type;
|
$F->type = $type;
|
||||||
$F->default = $field->def;
|
$F->default = $field->Default;
|
||||||
$F->max_length = $field->max_length;
|
$F->max_length = $length;
|
||||||
$F->primary_key = $field->primary_key;
|
$F->primary_key = ( $field->Key == 'PRI' ? 1 : 0 );
|
||||||
|
|
||||||
$retval[] = $F;
|
$retval[] = $F;
|
||||||
}
|
}
|
||||||
|
|||||||
2
system/database/drivers/mysql/mysql_utility.php
Executable file → Normal file
2
system/database/drivers/mysql/mysql_utility.php
Executable file → Normal file
@@ -96,7 +96,7 @@ class CI_DB_mysql_utility extends CI_DB_utility {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get the table schema
|
// Get the table schema
|
||||||
$query = $this->db->query("SHOW CREATE TABLE `".$this->db->database.'`.'.$table);
|
$query = $this->db->query("SHOW CREATE TABLE `".$this->db->database.'`.`'.$table.'`');
|
||||||
|
|
||||||
// No result means the table name was invalid
|
// No result means the table name was invalid
|
||||||
if ($query === FALSE)
|
if ($query === FALSE)
|
||||||
|
|||||||
0
system/database/drivers/mysqli/index.html
Executable file → Normal file
0
system/database/drivers/mysqli/index.html
Executable file → Normal file
33
system/database/drivers/mysqli/mysqli_driver.php
Executable file → Normal file
33
system/database/drivers/mysqli/mysqli_driver.php
Executable file → Normal file
@@ -54,6 +54,9 @@ class CI_DB_mysqli_driver extends CI_DB {
|
|||||||
*/
|
*/
|
||||||
var $delete_hack = TRUE;
|
var $delete_hack = TRUE;
|
||||||
|
|
||||||
|
// whether SET NAMES must be used to set the character set
|
||||||
|
var $use_set_names;
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -132,15 +135,13 @@ class CI_DB_mysqli_driver extends CI_DB {
|
|||||||
*/
|
*/
|
||||||
function _db_set_charset($charset, $collation)
|
function _db_set_charset($charset, $collation)
|
||||||
{
|
{
|
||||||
static $use_set_names;
|
if ( ! isset($this->use_set_names))
|
||||||
|
|
||||||
if ( ! isset($use_set_names))
|
|
||||||
{
|
{
|
||||||
// mysqli_set_charset() requires MySQL >= 5.0.7, use SET NAMES as fallback
|
// mysqli_set_charset() requires MySQL >= 5.0.7, use SET NAMES as fallback
|
||||||
$use_set_names = (version_compare(mysqli_get_server_info($this->conn_id), '5.0.7', '>=')) ? FALSE : TRUE;
|
$this->use_set_names = (version_compare(mysqli_get_server_info($this->conn_id), '5.0.7', '>=')) ? FALSE : TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($use_set_names)
|
if ($this->use_set_names === TRUE)
|
||||||
{
|
{
|
||||||
return @mysqli_query($this->conn_id, "SET NAMES '".$this->escape_str($charset)."' COLLATE '".$this->escape_str($collation)."'");
|
return @mysqli_query($this->conn_id, "SET NAMES '".$this->escape_str($charset)."' COLLATE '".$this->escape_str($collation)."'");
|
||||||
}
|
}
|
||||||
@@ -385,6 +386,7 @@ class CI_DB_mysqli_driver extends CI_DB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$row = $query->row();
|
$row = $query->row();
|
||||||
|
$this->_reset_select();
|
||||||
return (int) $row->numrows;
|
return (int) $row->numrows;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -440,7 +442,7 @@ class CI_DB_mysqli_driver extends CI_DB {
|
|||||||
*/
|
*/
|
||||||
function _field_data($table)
|
function _field_data($table)
|
||||||
{
|
{
|
||||||
return "SELECT * FROM ".$table." LIMIT 1";
|
return "DESCRIBE ".$table;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@@ -571,6 +573,25 @@ class CI_DB_mysqli_driver extends CI_DB {
|
|||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replace statement
|
||||||
|
*
|
||||||
|
* Generates a platform-specific replace string from the supplied data
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param string the table name
|
||||||
|
* @param array the insert keys
|
||||||
|
* @param array the insert values
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function _replace($table, $keys, $values)
|
||||||
|
{
|
||||||
|
return "REPLACE INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")";
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update statement
|
* Update statement
|
||||||
*
|
*
|
||||||
|
|||||||
0
system/database/drivers/mysqli/mysqli_forge.php
Executable file → Normal file
0
system/database/drivers/mysqli/mysqli_forge.php
Executable file → Normal file
17
system/database/drivers/mysqli/mysqli_result.php
Executable file → Normal file
17
system/database/drivers/mysqli/mysqli_result.php
Executable file → Normal file
@@ -84,14 +84,19 @@ class CI_DB_mysqli_result extends CI_DB_result {
|
|||||||
function field_data()
|
function field_data()
|
||||||
{
|
{
|
||||||
$retval = array();
|
$retval = array();
|
||||||
while ($field = mysqli_fetch_field($this->result_id))
|
while ($field = mysqli_fetch_object($this->result_id))
|
||||||
{
|
{
|
||||||
|
preg_match('/([a-zA-Z]+)(\(\d+\))?/', $field->Type, $matches);
|
||||||
|
|
||||||
|
$type = (array_key_exists(1, $matches)) ? $matches[1] : NULL;
|
||||||
|
$length = (array_key_exists(2, $matches)) ? preg_replace('/[^\d]/', '', $matches[2]) : NULL;
|
||||||
|
|
||||||
$F = new stdClass();
|
$F = new stdClass();
|
||||||
$F->name = $field->name;
|
$F->name = $field->Field;
|
||||||
$F->type = $field->type;
|
$F->type = $type;
|
||||||
$F->default = $field->def;
|
$F->default = $field->Default;
|
||||||
$F->max_length = $field->max_length;
|
$F->max_length = $length;
|
||||||
$F->primary_key = ($field->flags & MYSQLI_PRI_KEY_FLAG) ? 1 : 0;
|
$F->primary_key = ( $field->Key == 'PRI' ? 1 : 0 );
|
||||||
|
|
||||||
$retval[] = $F;
|
$retval[] = $F;
|
||||||
}
|
}
|
||||||
|
|||||||
0
system/database/drivers/mysqli/mysqli_utility.php
Executable file → Normal file
0
system/database/drivers/mysqli/mysqli_utility.php
Executable file → Normal file
0
system/database/drivers/oci8/index.html
Executable file → Normal file
0
system/database/drivers/oci8/index.html
Executable file → Normal file
159
system/database/drivers/oci8/oci8_driver.php
Executable file → Normal file
159
system/database/drivers/oci8/oci8_driver.php
Executable file → Normal file
@@ -35,8 +35,6 @@
|
|||||||
* This is a modification of the DB_driver class to
|
* This is a modification of the DB_driver class to
|
||||||
* permit access to oracle databases
|
* permit access to oracle databases
|
||||||
*
|
*
|
||||||
* NOTE: this uses the PHP 4 oci methods
|
|
||||||
*
|
|
||||||
* @author Kelly McArdle
|
* @author Kelly McArdle
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@@ -77,9 +75,9 @@ class CI_DB_oci8_driver extends CI_DB {
|
|||||||
* @access private called by the base class
|
* @access private called by the base class
|
||||||
* @return resource
|
* @return resource
|
||||||
*/
|
*/
|
||||||
function db_connect()
|
public function db_connect()
|
||||||
{
|
{
|
||||||
return @ocilogon($this->username, $this->password, $this->hostname);
|
return @oci_connect($this->username, $this->password, $this->hostname, $this->char_set);
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@@ -90,9 +88,9 @@ class CI_DB_oci8_driver extends CI_DB {
|
|||||||
* @access private called by the base class
|
* @access private called by the base class
|
||||||
* @return resource
|
* @return resource
|
||||||
*/
|
*/
|
||||||
function db_pconnect()
|
public function db_pconnect()
|
||||||
{
|
{
|
||||||
return @ociplogon($this->username, $this->password, $this->hostname);
|
return @oci_pconnect($this->username, $this->password, $this->hostname, $this->char_set);
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@@ -106,9 +104,10 @@ class CI_DB_oci8_driver extends CI_DB {
|
|||||||
* @access public
|
* @access public
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function reconnect()
|
public function reconnect()
|
||||||
{
|
{
|
||||||
// not implemented in oracle
|
// not implemented in oracle
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@@ -119,8 +118,9 @@ class CI_DB_oci8_driver extends CI_DB {
|
|||||||
* @access private called by the base class
|
* @access private called by the base class
|
||||||
* @return resource
|
* @return resource
|
||||||
*/
|
*/
|
||||||
function db_select()
|
public function db_select()
|
||||||
{
|
{
|
||||||
|
// Not in Oracle - schemas are actually usernames
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,7 +134,7 @@ class CI_DB_oci8_driver extends CI_DB {
|
|||||||
* @param string
|
* @param string
|
||||||
* @return resource
|
* @return resource
|
||||||
*/
|
*/
|
||||||
function db_set_charset($charset, $collation)
|
public function db_set_charset($charset, $collation)
|
||||||
{
|
{
|
||||||
// @todo - add support if needed
|
// @todo - add support if needed
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@@ -145,12 +145,12 @@ class CI_DB_oci8_driver extends CI_DB {
|
|||||||
/**
|
/**
|
||||||
* Version number query string
|
* Version number query string
|
||||||
*
|
*
|
||||||
* @access public
|
* @access protected
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function _version()
|
protected function _version()
|
||||||
{
|
{
|
||||||
return ociserverversion($this->conn_id);
|
return oci_server_version($this->conn_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@@ -158,18 +158,18 @@ class CI_DB_oci8_driver extends CI_DB {
|
|||||||
/**
|
/**
|
||||||
* Execute the query
|
* Execute the query
|
||||||
*
|
*
|
||||||
* @access private called by the base class
|
* @access protected called by the base class
|
||||||
* @param string an SQL query
|
* @param string an SQL query
|
||||||
* @return resource
|
* @return resource
|
||||||
*/
|
*/
|
||||||
function _execute($sql)
|
protected function _execute($sql)
|
||||||
{
|
{
|
||||||
// oracle must parse the query before it is run. All of the actions with
|
// oracle must parse the query before it is run. All of the actions with
|
||||||
// the query are based on the statement id returned by ociparse
|
// the query are based on the statement id returned by ociparse
|
||||||
$this->stmt_id = FALSE;
|
$this->stmt_id = FALSE;
|
||||||
$this->_set_stmt_id($sql);
|
$this->_set_stmt_id($sql);
|
||||||
ocisetprefetch($this->stmt_id, 1000);
|
oci_set_prefetch($this->stmt_id, 1000);
|
||||||
return @ociexecute($this->stmt_id, $this->_commit);
|
return @oci_execute($this->stmt_id, $this->_commit);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -179,11 +179,11 @@ class CI_DB_oci8_driver extends CI_DB {
|
|||||||
* @param string an SQL query
|
* @param string an SQL query
|
||||||
* @return none
|
* @return none
|
||||||
*/
|
*/
|
||||||
function _set_stmt_id($sql)
|
private function _set_stmt_id($sql)
|
||||||
{
|
{
|
||||||
if ( ! is_resource($this->stmt_id))
|
if ( ! is_resource($this->stmt_id))
|
||||||
{
|
{
|
||||||
$this->stmt_id = ociparse($this->conn_id, $this->_prep_query($sql));
|
$this->stmt_id = oci_parse($this->conn_id, $this->_prep_query($sql));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -198,7 +198,7 @@ class CI_DB_oci8_driver extends CI_DB {
|
|||||||
* @param string an SQL query
|
* @param string an SQL query
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function _prep_query($sql)
|
private function _prep_query($sql)
|
||||||
{
|
{
|
||||||
return $sql;
|
return $sql;
|
||||||
}
|
}
|
||||||
@@ -211,9 +211,9 @@ class CI_DB_oci8_driver extends CI_DB {
|
|||||||
* @access public
|
* @access public
|
||||||
* @return cursor id
|
* @return cursor id
|
||||||
*/
|
*/
|
||||||
function get_cursor()
|
public function get_cursor()
|
||||||
{
|
{
|
||||||
$this->curs_id = ocinewcursor($this->conn_id);
|
$this->curs_id = oci_new_cursor($this->conn_id);
|
||||||
return $this->curs_id;
|
return $this->curs_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -237,7 +237,7 @@ class CI_DB_oci8_driver extends CI_DB {
|
|||||||
* type yes the type of the parameter
|
* type yes the type of the parameter
|
||||||
* length yes the max size of the parameter
|
* length yes the max size of the parameter
|
||||||
*/
|
*/
|
||||||
function stored_procedure($package, $procedure, $params)
|
public function stored_procedure($package, $procedure, $params)
|
||||||
{
|
{
|
||||||
if ($package == '' OR $procedure == '' OR ! is_array($params))
|
if ($package == '' OR $procedure == '' OR ! is_array($params))
|
||||||
{
|
{
|
||||||
@@ -257,7 +257,7 @@ class CI_DB_oci8_driver extends CI_DB {
|
|||||||
{
|
{
|
||||||
$sql .= $param['name'] . ",";
|
$sql .= $param['name'] . ",";
|
||||||
|
|
||||||
if (array_key_exists('type', $param) && ($param['type'] == OCI_B_CURSOR))
|
if (array_key_exists('type', $param) && ($param['type'] === OCI_B_CURSOR))
|
||||||
{
|
{
|
||||||
$have_cursor = TRUE;
|
$have_cursor = TRUE;
|
||||||
}
|
}
|
||||||
@@ -278,7 +278,7 @@ class CI_DB_oci8_driver extends CI_DB {
|
|||||||
* @access private
|
* @access private
|
||||||
* @return none
|
* @return none
|
||||||
*/
|
*/
|
||||||
function _bind_params($params)
|
private function _bind_params($params)
|
||||||
{
|
{
|
||||||
if ( ! is_array($params) OR ! is_resource($this->stmt_id))
|
if ( ! is_array($params) OR ! is_resource($this->stmt_id))
|
||||||
{
|
{
|
||||||
@@ -295,7 +295,7 @@ class CI_DB_oci8_driver extends CI_DB {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ocibindbyname($this->stmt_id, $param['name'], $param['value'], $param['length'], $param['type']);
|
oci_bind_by_name($this->stmt_id, $param['name'], $param['value'], $param['length'], $param['type']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -307,7 +307,7 @@ class CI_DB_oci8_driver extends CI_DB {
|
|||||||
* @access public
|
* @access public
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
function trans_begin($test_mode = FALSE)
|
public function trans_begin($test_mode = FALSE)
|
||||||
{
|
{
|
||||||
if ( ! $this->trans_enabled)
|
if ( ! $this->trans_enabled)
|
||||||
{
|
{
|
||||||
@@ -337,7 +337,7 @@ class CI_DB_oci8_driver extends CI_DB {
|
|||||||
* @access public
|
* @access public
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
function trans_commit()
|
public function trans_commit()
|
||||||
{
|
{
|
||||||
if ( ! $this->trans_enabled)
|
if ( ! $this->trans_enabled)
|
||||||
{
|
{
|
||||||
@@ -350,7 +350,7 @@ class CI_DB_oci8_driver extends CI_DB {
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
$ret = OCIcommit($this->conn_id);
|
$ret = oci_commit($this->conn_id);
|
||||||
$this->_commit = OCI_COMMIT_ON_SUCCESS;
|
$this->_commit = OCI_COMMIT_ON_SUCCESS;
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
@@ -363,7 +363,7 @@ class CI_DB_oci8_driver extends CI_DB {
|
|||||||
* @access public
|
* @access public
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
function trans_rollback()
|
public function trans_rollback()
|
||||||
{
|
{
|
||||||
if ( ! $this->trans_enabled)
|
if ( ! $this->trans_enabled)
|
||||||
{
|
{
|
||||||
@@ -376,7 +376,7 @@ class CI_DB_oci8_driver extends CI_DB {
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
$ret = OCIrollback($this->conn_id);
|
$ret = oci_rollback($this->conn_id);
|
||||||
$this->_commit = OCI_COMMIT_ON_SUCCESS;
|
$this->_commit = OCI_COMMIT_ON_SUCCESS;
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
@@ -391,7 +391,7 @@ class CI_DB_oci8_driver extends CI_DB {
|
|||||||
* @param bool whether or not the string will be used in a LIKE condition
|
* @param bool whether or not the string will be used in a LIKE condition
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function escape_str($str, $like = FALSE)
|
public function escape_str($str, $like = FALSE)
|
||||||
{
|
{
|
||||||
if (is_array($str))
|
if (is_array($str))
|
||||||
{
|
{
|
||||||
@@ -424,9 +424,9 @@ class CI_DB_oci8_driver extends CI_DB {
|
|||||||
* @access public
|
* @access public
|
||||||
* @return integer
|
* @return integer
|
||||||
*/
|
*/
|
||||||
function affected_rows()
|
public function affected_rows()
|
||||||
{
|
{
|
||||||
return @ocirowcount($this->stmt_id);
|
return @oci_num_rows($this->stmt_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@@ -437,7 +437,7 @@ class CI_DB_oci8_driver extends CI_DB {
|
|||||||
* @access public
|
* @access public
|
||||||
* @return integer
|
* @return integer
|
||||||
*/
|
*/
|
||||||
function insert_id()
|
public function insert_id()
|
||||||
{
|
{
|
||||||
// not supported in oracle
|
// not supported in oracle
|
||||||
return $this->display_error('db_unsupported_function');
|
return $this->display_error('db_unsupported_function');
|
||||||
@@ -455,7 +455,7 @@ class CI_DB_oci8_driver extends CI_DB {
|
|||||||
* @param string
|
* @param string
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function count_all($table = '')
|
public function count_all($table = '')
|
||||||
{
|
{
|
||||||
if ($table == '')
|
if ($table == '')
|
||||||
{
|
{
|
||||||
@@ -470,6 +470,7 @@ class CI_DB_oci8_driver extends CI_DB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$row = $query->row();
|
$row = $query->row();
|
||||||
|
$this->_reset_select();
|
||||||
return (int) $row->numrows;
|
return (int) $row->numrows;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -480,11 +481,11 @@ class CI_DB_oci8_driver extends CI_DB {
|
|||||||
*
|
*
|
||||||
* Generates a platform-specific query string so that the table names can be fetched
|
* Generates a platform-specific query string so that the table names can be fetched
|
||||||
*
|
*
|
||||||
* @access private
|
* @access protected
|
||||||
* @param boolean
|
* @param boolean
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function _list_tables($prefix_limit = FALSE)
|
protected function _list_tables($prefix_limit = FALSE)
|
||||||
{
|
{
|
||||||
$sql = "SELECT TABLE_NAME FROM ALL_TABLES";
|
$sql = "SELECT TABLE_NAME FROM ALL_TABLES";
|
||||||
|
|
||||||
@@ -503,11 +504,11 @@ class CI_DB_oci8_driver extends CI_DB {
|
|||||||
*
|
*
|
||||||
* Generates a platform-specific query string so that the column names can be fetched
|
* Generates a platform-specific query string so that the column names can be fetched
|
||||||
*
|
*
|
||||||
* @access public
|
* @access protected
|
||||||
* @param string the table name
|
* @param string the table name
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function _list_columns($table = '')
|
protected function _list_columns($table = '')
|
||||||
{
|
{
|
||||||
return "SELECT COLUMN_NAME FROM all_tab_columns WHERE table_name = '$table'";
|
return "SELECT COLUMN_NAME FROM all_tab_columns WHERE table_name = '$table'";
|
||||||
}
|
}
|
||||||
@@ -523,7 +524,7 @@ class CI_DB_oci8_driver extends CI_DB {
|
|||||||
* @param string the table name
|
* @param string the table name
|
||||||
* @return object
|
* @return object
|
||||||
*/
|
*/
|
||||||
function _field_data($table)
|
protected function _field_data($table)
|
||||||
{
|
{
|
||||||
return "SELECT * FROM ".$table." where rownum = 1";
|
return "SELECT * FROM ".$table." where rownum = 1";
|
||||||
}
|
}
|
||||||
@@ -533,12 +534,13 @@ class CI_DB_oci8_driver extends CI_DB {
|
|||||||
/**
|
/**
|
||||||
* The error message string
|
* The error message string
|
||||||
*
|
*
|
||||||
* @access private
|
* @access protected
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function _error_message()
|
protected function _error_message()
|
||||||
{
|
{
|
||||||
$error = ocierror($this->conn_id);
|
// If the error was during connection, no conn_id should be passed
|
||||||
|
$error = is_resource($this->conn_id) ? oci_error($this->conn_id) : oci_error();
|
||||||
return $error['message'];
|
return $error['message'];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -547,12 +549,13 @@ class CI_DB_oci8_driver extends CI_DB {
|
|||||||
/**
|
/**
|
||||||
* The error message number
|
* The error message number
|
||||||
*
|
*
|
||||||
* @access private
|
* @access protected
|
||||||
* @return integer
|
* @return integer
|
||||||
*/
|
*/
|
||||||
function _error_number()
|
protected function _error_number()
|
||||||
{
|
{
|
||||||
$error = ocierror($this->conn_id);
|
// Same as _error_message()
|
||||||
|
$error = is_resource($this->conn_id) ? oci_error($this->conn_id) : oci_error();
|
||||||
return $error['code'];
|
return $error['code'];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -563,11 +566,11 @@ class CI_DB_oci8_driver extends CI_DB {
|
|||||||
*
|
*
|
||||||
* This function escapes column and table names
|
* This function escapes column and table names
|
||||||
*
|
*
|
||||||
* @access private
|
* @access protected
|
||||||
* @param string
|
* @param string
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function _escape_identifiers($item)
|
protected function _escape_identifiers($item)
|
||||||
{
|
{
|
||||||
if ($this->_escape_char == '')
|
if ($this->_escape_char == '')
|
||||||
{
|
{
|
||||||
@@ -606,11 +609,11 @@ class CI_DB_oci8_driver extends CI_DB {
|
|||||||
* This function implicitly groups FROM tables so there is no confusion
|
* This function implicitly groups FROM tables so there is no confusion
|
||||||
* about operator precedence in harmony with SQL standards
|
* about operator precedence in harmony with SQL standards
|
||||||
*
|
*
|
||||||
* @access public
|
* @access protected
|
||||||
* @param type
|
* @param type
|
||||||
* @return type
|
* @return type
|
||||||
*/
|
*/
|
||||||
function _from_tables($tables)
|
protected function _from_tables($tables)
|
||||||
{
|
{
|
||||||
if ( ! is_array($tables))
|
if ( ! is_array($tables))
|
||||||
{
|
{
|
||||||
@@ -633,9 +636,37 @@ class CI_DB_oci8_driver extends CI_DB {
|
|||||||
* @param array the insert values
|
* @param array the insert values
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function _insert($table, $keys, $values)
|
protected function _insert($table, $keys, $values)
|
||||||
{
|
{
|
||||||
return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")";
|
return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")";
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Insert_batch statement
|
||||||
|
*
|
||||||
|
* Generates a platform-specific insert string from the supplied data
|
||||||
|
*
|
||||||
|
* @access protected
|
||||||
|
* @param string the table name
|
||||||
|
* @param array the insert keys
|
||||||
|
* @param array the insert values
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function _insert_batch($table, $keys, $values)
|
||||||
|
{
|
||||||
|
$keys = implode(', ', $keys);
|
||||||
|
$sql = "INSERT ALL\n";
|
||||||
|
|
||||||
|
for ($i = 0, $c = count($values); $i < $c; $i++)
|
||||||
|
{
|
||||||
|
$sql .= ' INTO ' . $table . ' (' . $keys . ') VALUES ' . $values[$i] . "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql .= 'SELECT * FROM dual';
|
||||||
|
|
||||||
|
return $sql;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@@ -645,7 +676,7 @@ class CI_DB_oci8_driver extends CI_DB {
|
|||||||
*
|
*
|
||||||
* Generates a platform-specific update string from the supplied data
|
* Generates a platform-specific update string from the supplied data
|
||||||
*
|
*
|
||||||
* @access public
|
* @access protected
|
||||||
* @param string the table name
|
* @param string the table name
|
||||||
* @param array the update data
|
* @param array the update data
|
||||||
* @param array the where clause
|
* @param array the where clause
|
||||||
@@ -653,7 +684,7 @@ class CI_DB_oci8_driver extends CI_DB {
|
|||||||
* @param array the limit clause
|
* @param array the limit clause
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
|
protected function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
|
||||||
{
|
{
|
||||||
foreach ($values as $key => $val)
|
foreach ($values as $key => $val)
|
||||||
{
|
{
|
||||||
@@ -682,11 +713,11 @@ class CI_DB_oci8_driver extends CI_DB {
|
|||||||
* If the database does not support the truncate() command
|
* If the database does not support the truncate() command
|
||||||
* This function maps to "DELETE FROM table"
|
* This function maps to "DELETE FROM table"
|
||||||
*
|
*
|
||||||
* @access public
|
* @access protected
|
||||||
* @param string the table name
|
* @param string the table name
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function _truncate($table)
|
protected function _truncate($table)
|
||||||
{
|
{
|
||||||
return "TRUNCATE TABLE ".$table;
|
return "TRUNCATE TABLE ".$table;
|
||||||
}
|
}
|
||||||
@@ -698,13 +729,13 @@ class CI_DB_oci8_driver extends CI_DB {
|
|||||||
*
|
*
|
||||||
* Generates a platform-specific delete string from the supplied data
|
* Generates a platform-specific delete string from the supplied data
|
||||||
*
|
*
|
||||||
* @access public
|
* @access protected
|
||||||
* @param string the table name
|
* @param string the table name
|
||||||
* @param array the where clause
|
* @param array the where clause
|
||||||
* @param string the limit clause
|
* @param string the limit clause
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function _delete($table, $where = array(), $like = array(), $limit = FALSE)
|
protected function _delete($table, $where = array(), $like = array(), $limit = FALSE)
|
||||||
{
|
{
|
||||||
$conditions = '';
|
$conditions = '';
|
||||||
|
|
||||||
@@ -732,13 +763,13 @@ class CI_DB_oci8_driver extends CI_DB {
|
|||||||
*
|
*
|
||||||
* Generates a platform-specific LIMIT clause
|
* Generates a platform-specific LIMIT clause
|
||||||
*
|
*
|
||||||
* @access public
|
* @access protected
|
||||||
* @param string the sql query string
|
* @param string the sql query string
|
||||||
* @param integer the number of rows to limit the query to
|
* @param integer the number of rows to limit the query to
|
||||||
* @param integer the offset value
|
* @param integer the offset value
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function _limit($sql, $limit, $offset)
|
protected function _limit($sql, $limit, $offset)
|
||||||
{
|
{
|
||||||
$limit = $offset + $limit;
|
$limit = $offset + $limit;
|
||||||
$newsql = "SELECT * FROM (select inner_query.*, rownum rnum FROM ($sql) inner_query WHERE rownum < $limit)";
|
$newsql = "SELECT * FROM (select inner_query.*, rownum rnum FROM ($sql) inner_query WHERE rownum < $limit)";
|
||||||
@@ -759,13 +790,13 @@ class CI_DB_oci8_driver extends CI_DB {
|
|||||||
/**
|
/**
|
||||||
* Close DB Connection
|
* Close DB Connection
|
||||||
*
|
*
|
||||||
* @access public
|
* @access protected
|
||||||
* @param resource
|
* @param resource
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function _close($conn_id)
|
protected function _close($conn_id)
|
||||||
{
|
{
|
||||||
@ocilogoff($conn_id);
|
@oci_close($conn_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
0
system/database/drivers/oci8/oci8_forge.php
Executable file → Normal file
0
system/database/drivers/oci8/oci8_forge.php
Executable file → Normal file
96
system/database/drivers/oci8/oci8_result.php
Executable file → Normal file
96
system/database/drivers/oci8/oci8_result.php
Executable file → Normal file
@@ -40,14 +40,17 @@ class CI_DB_oci8_result extends CI_DB_result {
|
|||||||
* @access public
|
* @access public
|
||||||
* @return integer
|
* @return integer
|
||||||
*/
|
*/
|
||||||
function num_rows()
|
public function num_rows()
|
||||||
{
|
{
|
||||||
$rowcount = count($this->result_array());
|
if ($this->num_rows === 0 && count($this->result_array()) > 0)
|
||||||
@ociexecute($this->stmt_id);
|
|
||||||
|
|
||||||
if ($this->curs_id)
|
|
||||||
{
|
{
|
||||||
@ociexecute($this->curs_id);
|
$this->num_rows = count($this->result_array());
|
||||||
|
@oci_execute($this->stmt_id);
|
||||||
|
|
||||||
|
if ($this->curs_id)
|
||||||
|
{
|
||||||
|
@oci_execute($this->curs_id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $rowcount;
|
return $rowcount;
|
||||||
@@ -61,9 +64,9 @@ class CI_DB_oci8_result extends CI_DB_result {
|
|||||||
* @access public
|
* @access public
|
||||||
* @return integer
|
* @return integer
|
||||||
*/
|
*/
|
||||||
function num_fields()
|
public function num_fields()
|
||||||
{
|
{
|
||||||
$count = @ocinumcols($this->stmt_id);
|
$count = @oci_num_fields($this->stmt_id);
|
||||||
|
|
||||||
// if we used a limit we subtract it
|
// if we used a limit we subtract it
|
||||||
if ($this->limit_used)
|
if ($this->limit_used)
|
||||||
@@ -84,13 +87,12 @@ class CI_DB_oci8_result extends CI_DB_result {
|
|||||||
* @access public
|
* @access public
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function list_fields()
|
public function list_fields()
|
||||||
{
|
{
|
||||||
$field_names = array();
|
$field_names = array();
|
||||||
$fieldCount = $this->num_fields();
|
for ($c = 1, $fieldCount = $this->num_fields(); $c <= $fieldCount; $c++)
|
||||||
for ($c = 1; $c <= $fieldCount; $c++)
|
|
||||||
{
|
{
|
||||||
$field_names[] = ocicolumnname($this->stmt_id, $c);
|
$field_names[] = oci_field_name($this->stmt_id, $c);
|
||||||
}
|
}
|
||||||
return $field_names;
|
return $field_names;
|
||||||
}
|
}
|
||||||
@@ -105,16 +107,15 @@ class CI_DB_oci8_result extends CI_DB_result {
|
|||||||
* @access public
|
* @access public
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function field_data()
|
public function field_data()
|
||||||
{
|
{
|
||||||
$retval = array();
|
$retval = array();
|
||||||
$fieldCount = $this->num_fields();
|
for ($c = 1, $fieldCount = $this->num_fields(); $c <= $fieldCount; $c++)
|
||||||
for ($c = 1; $c <= $fieldCount; $c++)
|
|
||||||
{
|
{
|
||||||
$F = new stdClass();
|
$F = new stdClass();
|
||||||
$F->name = ocicolumnname($this->stmt_id, $c);
|
$F->name = oci_field_name($this->stmt_id, $c);
|
||||||
$F->type = ocicolumntype($this->stmt_id, $c);
|
$F->type = oci_field_type($this->stmt_id, $c);
|
||||||
$F->max_length = ocicolumnsize($this->stmt_id, $c);
|
$F->max_length = oci_field_size($this->stmt_id, $c);
|
||||||
|
|
||||||
$retval[] = $F;
|
$retval[] = $F;
|
||||||
}
|
}
|
||||||
@@ -129,11 +130,11 @@ class CI_DB_oci8_result extends CI_DB_result {
|
|||||||
*
|
*
|
||||||
* @return null
|
* @return null
|
||||||
*/
|
*/
|
||||||
function free_result()
|
public function free_result()
|
||||||
{
|
{
|
||||||
if (is_resource($this->result_id))
|
if (is_resource($this->result_id))
|
||||||
{
|
{
|
||||||
ocifreestatement($this->result_id);
|
oci_free_statement($this->result_id);
|
||||||
$this->result_id = FALSE;
|
$this->result_id = FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -145,14 +146,13 @@ class CI_DB_oci8_result extends CI_DB_result {
|
|||||||
*
|
*
|
||||||
* Returns the result set as an array
|
* Returns the result set as an array
|
||||||
*
|
*
|
||||||
* @access private
|
* @access protected
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function _fetch_assoc(&$row)
|
protected function _fetch_assoc()
|
||||||
{
|
{
|
||||||
$id = ($this->curs_id) ? $this->curs_id : $this->stmt_id;
|
$id = ($this->curs_id) ? $this->curs_id : $this->stmt_id;
|
||||||
|
return oci_fetch_assoc($id);
|
||||||
return ocifetchinto($id, $row, OCI_ASSOC + OCI_RETURN_NULLS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@@ -162,41 +162,13 @@ class CI_DB_oci8_result extends CI_DB_result {
|
|||||||
*
|
*
|
||||||
* Returns the result set as an object
|
* Returns the result set as an object
|
||||||
*
|
*
|
||||||
* @access private
|
* @access protected
|
||||||
* @return object
|
* @return object
|
||||||
*/
|
*/
|
||||||
function _fetch_object()
|
protected function _fetch_object()
|
||||||
{
|
{
|
||||||
$result = array();
|
$id = ($this->curs_id) ? $this->curs_id : $this->stmt_id;
|
||||||
|
return @oci_fetch_object($id);
|
||||||
// If PHP 5 is being used we can fetch an result object
|
|
||||||
if (function_exists('oci_fetch_object'))
|
|
||||||
{
|
|
||||||
$id = ($this->curs_id) ? $this->curs_id : $this->stmt_id;
|
|
||||||
|
|
||||||
return @oci_fetch_object($id);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If PHP 4 is being used we have to build our own result
|
|
||||||
foreach ($this->result_array() as $key => $val)
|
|
||||||
{
|
|
||||||
$obj = new stdClass();
|
|
||||||
if (is_array($val))
|
|
||||||
{
|
|
||||||
foreach ($val as $k => $v)
|
|
||||||
{
|
|
||||||
$obj->$k = $v;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$obj->$key = $val;
|
|
||||||
}
|
|
||||||
|
|
||||||
$result[] = $obj;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@@ -207,17 +179,15 @@ class CI_DB_oci8_result extends CI_DB_result {
|
|||||||
* @access public
|
* @access public
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function result_array()
|
public function result_array()
|
||||||
{
|
{
|
||||||
if (count($this->result_array) > 0)
|
if (count($this->result_array) > 0)
|
||||||
{
|
{
|
||||||
return $this->result_array;
|
return $this->result_array;
|
||||||
}
|
}
|
||||||
|
|
||||||
// oracle's fetch functions do not return arrays.
|
|
||||||
// The information is returned in reference parameters
|
|
||||||
$row = NULL;
|
$row = NULL;
|
||||||
while ($this->_fetch_assoc($row))
|
while ($row = $this->_fetch_assoc())
|
||||||
{
|
{
|
||||||
$this->result_array[] = $row;
|
$this->result_array[] = $row;
|
||||||
}
|
}
|
||||||
@@ -234,10 +204,10 @@ class CI_DB_oci8_result extends CI_DB_result {
|
|||||||
* this internally before fetching results to make sure the
|
* this internally before fetching results to make sure the
|
||||||
* result set starts at zero
|
* result set starts at zero
|
||||||
*
|
*
|
||||||
* @access private
|
* @access protected
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function _data_seek($n = 0)
|
protected function _data_seek($n = 0)
|
||||||
{
|
{
|
||||||
return FALSE; // Not needed
|
return FALSE; // Not needed
|
||||||
}
|
}
|
||||||
|
|||||||
0
system/database/drivers/oci8/oci8_utility.php
Executable file → Normal file
0
system/database/drivers/oci8/oci8_utility.php
Executable file → Normal file
0
system/database/drivers/odbc/index.html
Executable file → Normal file
0
system/database/drivers/odbc/index.html
Executable file → Normal file
5
system/database/drivers/odbc/odbc_driver.php
Executable file → Normal file
5
system/database/drivers/odbc/odbc_driver.php
Executable file → Normal file
@@ -48,9 +48,9 @@ class CI_DB_odbc_driver extends CI_DB {
|
|||||||
var $_random_keyword;
|
var $_random_keyword;
|
||||||
|
|
||||||
|
|
||||||
function CI_DB_odbc_driver($params)
|
function __construct($params)
|
||||||
{
|
{
|
||||||
parent::CI_DB($params);
|
parent::__construct($params);
|
||||||
|
|
||||||
$this->_random_keyword = ' RND('.time().')'; // database specific random keyword
|
$this->_random_keyword = ' RND('.time().')'; // database specific random keyword
|
||||||
}
|
}
|
||||||
@@ -339,6 +339,7 @@ class CI_DB_odbc_driver extends CI_DB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$row = $query->row();
|
$row = $query->row();
|
||||||
|
$this->_reset_select();
|
||||||
return (int) $row->numrows;
|
return (int) $row->numrows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
0
system/database/drivers/odbc/odbc_forge.php
Executable file → Normal file
0
system/database/drivers/odbc/odbc_forge.php
Executable file → Normal file
0
system/database/drivers/odbc/odbc_result.php
Executable file → Normal file
0
system/database/drivers/odbc/odbc_result.php
Executable file → Normal file
0
system/database/drivers/odbc/odbc_utility.php
Executable file → Normal file
0
system/database/drivers/odbc/odbc_utility.php
Executable file → Normal file
10
system/database/drivers/pdo/index.html
Normal file
10
system/database/drivers/pdo/index.html
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>403 Forbidden</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<p>Directory access is forbidden.</p>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
803
system/database/drivers/pdo/pdo_driver.php
Normal file
803
system/database/drivers/pdo/pdo_driver.php
Normal file
@@ -0,0 +1,803 @@
|
|||||||
|
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||||
|
/**
|
||||||
|
* CodeIgniter
|
||||||
|
*
|
||||||
|
* An open source application development framework for PHP 5.1.6 or newer
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
|
||||||
|
* @license http://codeigniter.com/user_guide/license.html
|
||||||
|
* @author EllisLab Dev Team
|
||||||
|
* @link http://codeigniter.com
|
||||||
|
* @since Version 2.1.0
|
||||||
|
* @filesource
|
||||||
|
*/
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PDO 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_pdo_driver extends CI_DB {
|
||||||
|
|
||||||
|
var $dbdriver = 'pdo';
|
||||||
|
|
||||||
|
// the character used to excape - not necessary for PDO
|
||||||
|
var $_escape_char = '';
|
||||||
|
var $_like_escape_str;
|
||||||
|
var $_like_escape_chr;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The syntax to count rows is slightly different across different
|
||||||
|
* database engines, so this string appears in each driver and is
|
||||||
|
* used for the count_all() and count_all_results() functions.
|
||||||
|
*/
|
||||||
|
var $_count_string = "SELECT COUNT(*) AS ";
|
||||||
|
var $_random_keyword;
|
||||||
|
|
||||||
|
var $options = array();
|
||||||
|
|
||||||
|
function __construct($params)
|
||||||
|
{
|
||||||
|
parent::__construct($params);
|
||||||
|
|
||||||
|
// clause and character used for LIKE escape sequences
|
||||||
|
if (strpos($this->hostname, 'mysql') !== FALSE)
|
||||||
|
{
|
||||||
|
$this->_like_escape_str = '';
|
||||||
|
$this->_like_escape_chr = '';
|
||||||
|
|
||||||
|
//Prior to this version, the charset can't be set in the dsn
|
||||||
|
if(is_php('5.3.6'))
|
||||||
|
{
|
||||||
|
$this->hostname .= ";charset={$this->char_set}";
|
||||||
|
}
|
||||||
|
|
||||||
|
//Set the charset with the connection options
|
||||||
|
$this->options['PDO::MYSQL_ATTR_INIT_COMMAND'] = "SET NAMES {$this->char_set}";
|
||||||
|
}
|
||||||
|
else if (strpos($this->hostname, 'odbc') !== FALSE)
|
||||||
|
{
|
||||||
|
$this->_like_escape_str = " {escape '%s'} ";
|
||||||
|
$this->_like_escape_chr = '!';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->_like_escape_str = " ESCAPE '%s' ";
|
||||||
|
$this->_like_escape_chr = '!';
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->hostname .= ";dbname=".$this->database;
|
||||||
|
|
||||||
|
$this->trans_enabled = FALSE;
|
||||||
|
|
||||||
|
$this->_random_keyword = ' RND('.time().')'; // database specific random keyword
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Non-persistent database connection
|
||||||
|
*
|
||||||
|
* @access private called by the base class
|
||||||
|
* @return resource
|
||||||
|
*/
|
||||||
|
function db_connect()
|
||||||
|
{
|
||||||
|
$this->options['PDO::ATTR_ERRMODE'] = PDO::ERRMODE_SILENT;
|
||||||
|
|
||||||
|
return new PDO($this->hostname, $this->username, $this->password, $this->options);
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Persistent database connection
|
||||||
|
*
|
||||||
|
* @access private called by the base class
|
||||||
|
* @return resource
|
||||||
|
*/
|
||||||
|
function db_pconnect()
|
||||||
|
{
|
||||||
|
$this->options['PDO::ATTR_ERRMODE'] = PDO::ERRMODE_SILENT;
|
||||||
|
$this->options['PDO::ATTR_PERSISTENT'] = TRUE;
|
||||||
|
|
||||||
|
return new PDO($this->hostname, $this->username, $this->password, $this->options);
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reconnect
|
||||||
|
*
|
||||||
|
* Keep / reestablish the db connection if no queries have been
|
||||||
|
* sent for a length of time exceeding the server's idle timeout
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function reconnect()
|
||||||
|
{
|
||||||
|
if ($this->db->db_debug)
|
||||||
|
{
|
||||||
|
return $this->db->display_error('db_unsuported_feature');
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Select the database
|
||||||
|
*
|
||||||
|
* @access private called by the base class
|
||||||
|
* @return resource
|
||||||
|
*/
|
||||||
|
function db_select()
|
||||||
|
{
|
||||||
|
// Not needed for PDO
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set client character set
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param string
|
||||||
|
* @param string
|
||||||
|
* @return resource
|
||||||
|
*/
|
||||||
|
function db_set_charset($charset, $collation)
|
||||||
|
{
|
||||||
|
// @todo - add support if needed
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Version number query string
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function _version()
|
||||||
|
{
|
||||||
|
return $this->conn_id->getAttribute(PDO::ATTR_CLIENT_VERSION);
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the query
|
||||||
|
*
|
||||||
|
* @access private called by the base class
|
||||||
|
* @param string an SQL query
|
||||||
|
* @return object
|
||||||
|
*/
|
||||||
|
function _execute($sql)
|
||||||
|
{
|
||||||
|
$sql = $this->_prep_query($sql);
|
||||||
|
$result_id = $this->conn_id->query($sql);
|
||||||
|
|
||||||
|
if (is_object($result_id))
|
||||||
|
{
|
||||||
|
$this->affect_rows = $result_id->rowCount();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->affect_rows = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prep the query
|
||||||
|
*
|
||||||
|
* If needed, each database adapter can prep the query string
|
||||||
|
*
|
||||||
|
* @access private called by execute()
|
||||||
|
* @param string an SQL query
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function _prep_query($sql)
|
||||||
|
{
|
||||||
|
return $sql;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Begin Transaction
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
function trans_begin($test_mode = FALSE)
|
||||||
|
{
|
||||||
|
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 = (bool) ($test_mode === TRUE);
|
||||||
|
|
||||||
|
return $this->conn_id->beginTransaction();
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Commit Transaction
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
$ret = $this->conn->commit();
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rollback Transaction
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
$ret = $this->conn_id->rollBack();
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Escape String
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param string
|
||||||
|
* @param bool whether or not the string will be used in a LIKE condition
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function escape_str($str, $like = FALSE)
|
||||||
|
{
|
||||||
|
if (is_array($str))
|
||||||
|
{
|
||||||
|
foreach ($str as $key => $val)
|
||||||
|
{
|
||||||
|
$str[$key] = $this->escape_str($val, $like);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $str;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Escape the string
|
||||||
|
$str = $this->conn_id->quote($str);
|
||||||
|
|
||||||
|
//If there are duplicated quotes, trim them away
|
||||||
|
if (strpos($str, "'") === 0)
|
||||||
|
{
|
||||||
|
$str = substr($str, 1, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// escape LIKE condition wildcards
|
||||||
|
if ($like === TRUE)
|
||||||
|
{
|
||||||
|
$str = str_replace( array('%', '_', $this->_like_escape_chr),
|
||||||
|
array($this->_like_escape_chr.'%', $this->_like_escape_chr.'_', $this->_like_escape_chr.$this->_like_escape_chr),
|
||||||
|
$str);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $str;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Affected Rows
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return integer
|
||||||
|
*/
|
||||||
|
function affected_rows()
|
||||||
|
{
|
||||||
|
return $this->affect_rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Insert ID
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return integer
|
||||||
|
*/
|
||||||
|
function insert_id($name=NULL)
|
||||||
|
{
|
||||||
|
//Convenience method for postgres insertid
|
||||||
|
if (strpos($this->hostname, 'pgsql') !== FALSE)
|
||||||
|
{
|
||||||
|
$v = $this->_version();
|
||||||
|
|
||||||
|
$table = func_num_args() > 0 ? func_get_arg(0) : NULL;
|
||||||
|
|
||||||
|
if ($table == NULL && $v >= '8.1')
|
||||||
|
{
|
||||||
|
$sql='SELECT LASTVAL() as ins_id';
|
||||||
|
}
|
||||||
|
$query = $this->query($sql);
|
||||||
|
$row = $query->row();
|
||||||
|
return $row->ins_id;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return $this->conn_id->lastInsertId($name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* "Count All" query
|
||||||
|
*
|
||||||
|
* Generates a platform-specific query string that counts all records in
|
||||||
|
* the specified database
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param string
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show table query
|
||||||
|
*
|
||||||
|
* Generates a platform-specific query string so that the table names can be fetched
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
* @param boolean
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function _list_tables($prefix_limit = FALSE)
|
||||||
|
{
|
||||||
|
$sql = "SHOW TABLES FROM `".$this->database."`";
|
||||||
|
|
||||||
|
if ($prefix_limit !== FALSE AND $this->dbprefix != '')
|
||||||
|
{
|
||||||
|
//$sql .= " LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr);
|
||||||
|
return FALSE; // not currently supported
|
||||||
|
}
|
||||||
|
|
||||||
|
return $sql;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show column query
|
||||||
|
*
|
||||||
|
* Generates a platform-specific query string so that the column names can be fetched
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param string the table name
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function _list_columns($table = '')
|
||||||
|
{
|
||||||
|
return "SHOW COLUMNS FROM ".$table;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Field data query
|
||||||
|
*
|
||||||
|
* Generates a platform-specific query so that the column data can be retrieved
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param string the table name
|
||||||
|
* @return object
|
||||||
|
*/
|
||||||
|
function _field_data($table)
|
||||||
|
{
|
||||||
|
return "SELECT TOP 1 FROM ".$table;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The error message string
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function _error_message()
|
||||||
|
{
|
||||||
|
$error_array = $this->conn_id->errorInfo();
|
||||||
|
return $error_array[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The error message number
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
* @return integer
|
||||||
|
*/
|
||||||
|
function _error_number()
|
||||||
|
{
|
||||||
|
return $this->conn_id->errorCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Escape the SQL Identifiers
|
||||||
|
*
|
||||||
|
* This function escapes column and table names
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
* @param string
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function _escape_identifiers($item)
|
||||||
|
{
|
||||||
|
if ($this->_escape_char == '')
|
||||||
|
{
|
||||||
|
return $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 function implicitly groups FROM tables so there is no confusion
|
||||||
|
* about operator precedence in harmony with SQL standards
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param type
|
||||||
|
* @return type
|
||||||
|
*/
|
||||||
|
function _from_tables($tables)
|
||||||
|
{
|
||||||
|
if ( ! is_array($tables))
|
||||||
|
{
|
||||||
|
$tables = array($tables);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (count($tables) == 1) ? $tables[0] : '('.implode(', ', $tables).')';
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Insert statement
|
||||||
|
*
|
||||||
|
* Generates a platform-specific insert string from the supplied data
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param string the table name
|
||||||
|
* @param array the insert keys
|
||||||
|
* @param array the insert values
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function _insert($table, $keys, $values)
|
||||||
|
{
|
||||||
|
return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")";
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Insert_batch statement
|
||||||
|
*
|
||||||
|
* Generates a platform-specific insert string from the supplied data
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param string the table name
|
||||||
|
* @param array the insert keys
|
||||||
|
* @param array the insert values
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function _insert_batch($table, $keys, $values)
|
||||||
|
{
|
||||||
|
return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES ".implode(', ', $values);
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update statement
|
||||||
|
*
|
||||||
|
* Generates a platform-specific update string from the supplied data
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param string the table name
|
||||||
|
* @param array the update data
|
||||||
|
* @param array the where clause
|
||||||
|
* @param array the orderby clause
|
||||||
|
* @param array the limit clause
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
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.$limit;
|
||||||
|
|
||||||
|
return $sql;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update_Batch statement
|
||||||
|
*
|
||||||
|
* Generates a platform-specific batch update string from the supplied data
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param string the table name
|
||||||
|
* @param array the update data
|
||||||
|
* @param array the where clause
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function _update_batch($table, $values, $index, $where = NULL)
|
||||||
|
{
|
||||||
|
$ids = array();
|
||||||
|
$where = ($where != '' AND count($where) >=1) ? implode(" ", $where).' AND ' : '';
|
||||||
|
|
||||||
|
foreach ($values as $key => $val)
|
||||||
|
{
|
||||||
|
$ids[] = $val[$index];
|
||||||
|
|
||||||
|
foreach (array_keys($val) as $field)
|
||||||
|
{
|
||||||
|
if ($field != $index)
|
||||||
|
{
|
||||||
|
$final[$field][] = 'WHEN '.$index.' = '.$val[$index].' THEN '.$val[$field];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql = "UPDATE ".$table." SET ";
|
||||||
|
$cases = '';
|
||||||
|
|
||||||
|
foreach ($final as $k => $v)
|
||||||
|
{
|
||||||
|
$cases .= $k.' = CASE '."\n";
|
||||||
|
foreach ($v as $row)
|
||||||
|
{
|
||||||
|
$cases .= $row."\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
$cases .= 'ELSE '.$k.' END, ';
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql .= substr($cases, 0, -2);
|
||||||
|
|
||||||
|
$sql .= ' WHERE '.$where.$index.' IN ('.implode(',', $ids).')';
|
||||||
|
|
||||||
|
return $sql;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Truncate statement
|
||||||
|
*
|
||||||
|
* Generates a platform-specific truncate string from the supplied data
|
||||||
|
* If the database does not support the truncate() command
|
||||||
|
* This function maps to "DELETE FROM table"
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param string the table name
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function _truncate($table)
|
||||||
|
{
|
||||||
|
return $this->_delete($table);
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete statement
|
||||||
|
*
|
||||||
|
* Generates a platform-specific delete string from the supplied data
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param string the table name
|
||||||
|
* @param array the where clause
|
||||||
|
* @param string the limit clause
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function _delete($table, $where = array(), $like = array(), $limit = FALSE)
|
||||||
|
{
|
||||||
|
$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;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Limit string
|
||||||
|
*
|
||||||
|
* Generates a platform-specific LIMIT clause
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param string the sql query string
|
||||||
|
* @param integer the number of rows to limit the query to
|
||||||
|
* @param integer the offset value
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function _limit($sql, $limit, $offset)
|
||||||
|
{
|
||||||
|
if (strpos($this->hostname, 'cubrid') !== FALSE || strpos($this->hostname, 'sqlite') !== FALSE)
|
||||||
|
{
|
||||||
|
if ($offset == 0)
|
||||||
|
{
|
||||||
|
$offset = '';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$offset .= ", ";
|
||||||
|
}
|
||||||
|
|
||||||
|
return $sql."LIMIT ".$offset.$limit;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$sql .= "LIMIT ".$limit;
|
||||||
|
|
||||||
|
if ($offset > 0)
|
||||||
|
{
|
||||||
|
$sql .= " OFFSET ".$offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $sql;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Close DB Connection
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @param resource
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function _close($conn_id)
|
||||||
|
{
|
||||||
|
$this->conn_id = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* End of file pdo_driver.php */
|
||||||
|
/* Location: ./system/database/drivers/pdo/pdo_driver.php */
|
||||||
266
system/database/drivers/pdo/pdo_forge.php
Normal file
266
system/database/drivers/pdo/pdo_forge.php
Normal file
@@ -0,0 +1,266 @@
|
|||||||
|
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||||
|
/**
|
||||||
|
* CodeIgniter
|
||||||
|
*
|
||||||
|
* An open source application development framework for PHP 5.1.6 or newer
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
|
||||||
|
* @license http://codeigniter.com/user_guide/license.html
|
||||||
|
* @author EllisLab Dev Team
|
||||||
|
* @link http://codeigniter.com
|
||||||
|
* @since Version 2.1.0
|
||||||
|
* @filesource
|
||||||
|
*/
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PDO Forge Class
|
||||||
|
*
|
||||||
|
* @category Database
|
||||||
|
* @author EllisLab Dev Team
|
||||||
|
* @link http://codeigniter.com/database/
|
||||||
|
*/
|
||||||
|
class CI_DB_pdo_forge extends CI_DB_forge {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create database
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
* @param string the database name
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
function _create_database()
|
||||||
|
{
|
||||||
|
// PDO has no "create database" command since it's
|
||||||
|
// designed to connect to an existing database
|
||||||
|
if ($this->db->db_debug)
|
||||||
|
{
|
||||||
|
return $this->db->display_error('db_unsuported_feature');
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Drop database
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
* @param string the database name
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
function _drop_database($name)
|
||||||
|
{
|
||||||
|
// PDO has no "drop database" command since it's
|
||||||
|
// designed to connect to an existing database
|
||||||
|
if ($this->db->db_debug)
|
||||||
|
{
|
||||||
|
return $this->db->display_error('db_unsuported_feature');
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create Table
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
* @param string the table name
|
||||||
|
* @param array the fields
|
||||||
|
* @param mixed primary key(s)
|
||||||
|
* @param mixed key(s)
|
||||||
|
* @param boolean should 'IF NOT EXISTS' be added to the SQL
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
|
||||||
|
{
|
||||||
|
$sql = 'CREATE TABLE ';
|
||||||
|
|
||||||
|
if ($if_not_exists === TRUE)
|
||||||
|
{
|
||||||
|
$sql .= 'IF NOT EXISTS ';
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql .= $this->db->_escape_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\tFOREIGN KEY (" . implode(', ', $key) . ")";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql .= "\n)";
|
||||||
|
|
||||||
|
return $sql;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Drop Table
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
function _drop_table($table)
|
||||||
|
{
|
||||||
|
// Not a supported PDO feature
|
||||||
|
if ($this->db->db_debug)
|
||||||
|
{
|
||||||
|
return $this->db->display_error('db_unsuported_feature');
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alter table query
|
||||||
|
*
|
||||||
|
* Generates a platform-specific query so that a table can be altered
|
||||||
|
* Called by add_column(), drop_column(), and column_alter(),
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
* @param string the ALTER type (ADD, DROP, CHANGE)
|
||||||
|
* @param string the column name
|
||||||
|
* @param string the table name
|
||||||
|
* @param string the column definition
|
||||||
|
* @param string the default value
|
||||||
|
* @param boolean should 'NOT NULL' be added
|
||||||
|
* @param string the field after which we should add the new field
|
||||||
|
* @return object
|
||||||
|
*/
|
||||||
|
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);
|
||||||
|
|
||||||
|
// DROP has everything it needs now.
|
||||||
|
if ($alter_type == 'DROP')
|
||||||
|
{
|
||||||
|
return $sql;
|
||||||
|
}
|
||||||
|
|
||||||
|
$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
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
* @param string the old table name
|
||||||
|
* @param string the new table name
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* End of file pdo_forge.php */
|
||||||
|
/* Location: ./system/database/drivers/pdo/pdo_forge.php */
|
||||||
171
system/database/drivers/pdo/pdo_result.php
Normal file
171
system/database/drivers/pdo/pdo_result.php
Normal file
@@ -0,0 +1,171 @@
|
|||||||
|
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||||
|
/**
|
||||||
|
* CodeIgniter
|
||||||
|
*
|
||||||
|
* An open source application development framework for PHP 5.1.6 or newer
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
|
||||||
|
* @license http://codeigniter.com/user_guide/license.html
|
||||||
|
* @author EllisLab Dev Team
|
||||||
|
* @link http://codeigniter.com
|
||||||
|
* @since Version 2.1.0
|
||||||
|
* @filesource
|
||||||
|
*/
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PDO 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_pdo_result extends CI_DB_result {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Number of rows in the result set
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return integer
|
||||||
|
*/
|
||||||
|
function num_rows()
|
||||||
|
{
|
||||||
|
return $this->result_id->rowCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Number of fields in the result set
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return integer
|
||||||
|
*/
|
||||||
|
function num_fields()
|
||||||
|
{
|
||||||
|
return $this->result_id->columnCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch Field Names
|
||||||
|
*
|
||||||
|
* Generates an array of column names
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
function list_fields()
|
||||||
|
{
|
||||||
|
if ($this->db->db_debug)
|
||||||
|
{
|
||||||
|
return $this->db->display_error('db_unsuported_feature');
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Field data
|
||||||
|
*
|
||||||
|
* Generates an array of objects containing field meta-data
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
function field_data()
|
||||||
|
{
|
||||||
|
$data = array();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
for($i = 0; $i < $this->num_fields(); $i++)
|
||||||
|
{
|
||||||
|
$data[] = $this->result_id->getColumnMeta($i);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
catch (Exception $e)
|
||||||
|
{
|
||||||
|
if ($this->db->db_debug)
|
||||||
|
{
|
||||||
|
return $this->db->display_error('db_unsuported_feature');
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Free the result
|
||||||
|
*
|
||||||
|
* @return null
|
||||||
|
*/
|
||||||
|
function free_result()
|
||||||
|
{
|
||||||
|
if (is_object($this->result_id))
|
||||||
|
{
|
||||||
|
$this->result_id = FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
function _data_seek($n = 0)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Result - associative array
|
||||||
|
*
|
||||||
|
* Returns the result set as an array
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
function _fetch_assoc()
|
||||||
|
{
|
||||||
|
return $this->result_id->fetch(PDO::FETCH_ASSOC);
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Result - object
|
||||||
|
*
|
||||||
|
* Returns the result set as an object
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
* @return object
|
||||||
|
*/
|
||||||
|
function _fetch_object()
|
||||||
|
{
|
||||||
|
return $this->result_id->fetchObject();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* End of file pdo_result.php */
|
||||||
|
/* Location: ./system/database/drivers/pdo/pdo_result.php */
|
||||||
103
system/database/drivers/pdo/pdo_utility.php
Normal file
103
system/database/drivers/pdo/pdo_utility.php
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||||
|
/**
|
||||||
|
* CodeIgniter
|
||||||
|
*
|
||||||
|
* An open source application development framework for PHP 5.1.6 or newer
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
|
||||||
|
* @license http://codeigniter.com/user_guide/license.html
|
||||||
|
* @author EllisLab Dev Team
|
||||||
|
* @link http://codeigniter.com
|
||||||
|
* @since Version 2.1.0
|
||||||
|
* @filesource
|
||||||
|
*/
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PDO Utility Class
|
||||||
|
*
|
||||||
|
* @category Database
|
||||||
|
* @author EllisLab Dev Team
|
||||||
|
* @link http://codeigniter.com/database/
|
||||||
|
*/
|
||||||
|
class CI_DB_pdo_utility extends CI_DB_utility {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List databases
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
function _list_databases()
|
||||||
|
{
|
||||||
|
// Not sure if PDO lets you list all databases...
|
||||||
|
if ($this->db->db_debug)
|
||||||
|
{
|
||||||
|
return $this->db->display_error('db_unsuported_feature');
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Optimize table query
|
||||||
|
*
|
||||||
|
* Generates a platform-specific query so that a table can be optimized
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
* @param string the table name
|
||||||
|
* @return object
|
||||||
|
*/
|
||||||
|
function _optimize_table($table)
|
||||||
|
{
|
||||||
|
// Not a supported PDO feature
|
||||||
|
if ($this->db->db_debug)
|
||||||
|
{
|
||||||
|
return $this->db->display_error('db_unsuported_feature');
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Repair table query
|
||||||
|
*
|
||||||
|
* Generates a platform-specific query so that a table can be repaired
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
* @param string the table name
|
||||||
|
* @return object
|
||||||
|
*/
|
||||||
|
function _repair_table($table)
|
||||||
|
{
|
||||||
|
// Not a supported PDO feature
|
||||||
|
if ($this->db->db_debug)
|
||||||
|
{
|
||||||
|
return $this->db->display_error('db_unsuported_feature');
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PDO Export
|
||||||
|
*
|
||||||
|
* @access private
|
||||||
|
* @param array Preferences
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
function _backup($params = array())
|
||||||
|
{
|
||||||
|
// Currently unsupported
|
||||||
|
return $this->db->display_error('db_unsuported_feature');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* End of file pdo_utility.php */
|
||||||
|
/* Location: ./system/database/drivers/pdo/pdo_utility.php */
|
||||||
0
system/database/drivers/postgre/index.html
Executable file → Normal file
0
system/database/drivers/postgre/index.html
Executable file → Normal file
1
system/database/drivers/postgre/postgre_driver.php
Executable file → Normal file
1
system/database/drivers/postgre/postgre_driver.php
Executable file → Normal file
@@ -385,6 +385,7 @@ class CI_DB_postgre_driver extends CI_DB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$row = $query->row();
|
$row = $query->row();
|
||||||
|
$this->_reset_select();
|
||||||
return (int) $row->numrows;
|
return (int) $row->numrows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
0
system/database/drivers/postgre/postgre_forge.php
Executable file → Normal file
0
system/database/drivers/postgre/postgre_forge.php
Executable file → Normal file
0
system/database/drivers/postgre/postgre_result.php
Executable file → Normal file
0
system/database/drivers/postgre/postgre_result.php
Executable file → Normal file
0
system/database/drivers/postgre/postgre_utility.php
Executable file → Normal file
0
system/database/drivers/postgre/postgre_utility.php
Executable file → Normal file
0
system/database/drivers/sqlite/index.html
Executable file → Normal file
0
system/database/drivers/sqlite/index.html
Executable file → Normal file
1
system/database/drivers/sqlite/sqlite_driver.php
Executable file → Normal file
1
system/database/drivers/sqlite/sqlite_driver.php
Executable file → Normal file
@@ -354,6 +354,7 @@ class CI_DB_sqlite_driver extends CI_DB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$row = $query->row();
|
$row = $query->row();
|
||||||
|
$this->_reset_select();
|
||||||
return (int) $row->numrows;
|
return (int) $row->numrows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
0
system/database/drivers/sqlite/sqlite_forge.php
Executable file → Normal file
0
system/database/drivers/sqlite/sqlite_forge.php
Executable file → Normal file
0
system/database/drivers/sqlite/sqlite_result.php
Executable file → Normal file
0
system/database/drivers/sqlite/sqlite_result.php
Executable file → Normal file
0
system/database/drivers/sqlite/sqlite_utility.php
Executable file → Normal file
0
system/database/drivers/sqlite/sqlite_utility.php
Executable file → Normal file
0
system/database/drivers/sqlsrv/index.html
Executable file → Normal file
0
system/database/drivers/sqlsrv/index.html
Executable file → Normal file
1
system/database/drivers/sqlsrv/sqlsrv_driver.php
Executable file → Normal file
1
system/database/drivers/sqlsrv/sqlsrv_driver.php
Executable file → Normal file
@@ -344,6 +344,7 @@ class CI_DB_sqlsrv_driver extends CI_DB {
|
|||||||
return '0';
|
return '0';
|
||||||
|
|
||||||
$row = $query->row();
|
$row = $query->row();
|
||||||
|
$this->_reset_select();
|
||||||
return $row->numrows;
|
return $row->numrows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
0
system/database/drivers/sqlsrv/sqlsrv_forge.php
Executable file → Normal file
0
system/database/drivers/sqlsrv/sqlsrv_forge.php
Executable file → Normal file
0
system/database/drivers/sqlsrv/sqlsrv_result.php
Executable file → Normal file
0
system/database/drivers/sqlsrv/sqlsrv_result.php
Executable file → Normal file
0
system/database/drivers/sqlsrv/sqlsrv_utility.php
Executable file → Normal file
0
system/database/drivers/sqlsrv/sqlsrv_utility.php
Executable file → Normal file
0
system/database/index.html
Executable file → Normal file
0
system/database/index.html
Executable file → Normal file
0
system/fonts/index.html
Executable file → Normal file
0
system/fonts/index.html
Executable file → Normal file
0
system/fonts/texb.ttf
Executable file → Normal file
0
system/fonts/texb.ttf
Executable file → Normal file
0
system/helpers/array_helper.php
Executable file → Normal file
0
system/helpers/array_helper.php
Executable file → Normal file
0
system/helpers/captcha_helper.php
Executable file → Normal file
0
system/helpers/captcha_helper.php
Executable file → Normal file
0
system/helpers/cookie_helper.php
Executable file → Normal file
0
system/helpers/cookie_helper.php
Executable file → Normal file
2
system/helpers/date_helper.php
Executable file → Normal file
2
system/helpers/date_helper.php
Executable file → Normal file
@@ -116,7 +116,7 @@ if ( ! function_exists('standard_date'))
|
|||||||
'DATE_COOKIE' => '%l, %d-%M-%y %H:%i:%s UTC',
|
'DATE_COOKIE' => '%l, %d-%M-%y %H:%i:%s UTC',
|
||||||
'DATE_ISO8601' => '%Y-%m-%dT%H:%i:%s%Q',
|
'DATE_ISO8601' => '%Y-%m-%dT%H:%i:%s%Q',
|
||||||
'DATE_RFC822' => '%D, %d %M %y %H:%i:%s %O',
|
'DATE_RFC822' => '%D, %d %M %y %H:%i:%s %O',
|
||||||
'DATE_RFC850' => '%l, %d-%M-%y %H:%m:%i UTC',
|
'DATE_RFC850' => '%l, %d-%M-%y %H:%i:%s UTC',
|
||||||
'DATE_RFC1036' => '%D, %d %M %y %H:%i:%s %O',
|
'DATE_RFC1036' => '%D, %d %M %y %H:%i:%s %O',
|
||||||
'DATE_RFC1123' => '%D, %d %M %Y %H:%i:%s %O',
|
'DATE_RFC1123' => '%D, %d %M %Y %H:%i:%s %O',
|
||||||
'DATE_RSS' => '%D, %d %M %Y %H:%i:%s %O',
|
'DATE_RSS' => '%D, %d %M %Y %H:%i:%s %O',
|
||||||
|
|||||||
0
system/helpers/directory_helper.php
Executable file → Normal file
0
system/helpers/directory_helper.php
Executable file → Normal file
0
system/helpers/download_helper.php
Executable file → Normal file
0
system/helpers/download_helper.php
Executable file → Normal file
0
system/helpers/email_helper.php
Executable file → Normal file
0
system/helpers/email_helper.php
Executable file → Normal file
0
system/helpers/file_helper.php
Executable file → Normal file
0
system/helpers/file_helper.php
Executable file → Normal file
8
system/helpers/form_helper.php
Executable file → Normal file
8
system/helpers/form_helper.php
Executable file → Normal file
@@ -64,8 +64,8 @@ if ( ! function_exists('form_open'))
|
|||||||
|
|
||||||
$form .= '>';
|
$form .= '>';
|
||||||
|
|
||||||
// CSRF
|
// Add CSRF field if enabled, but leave it out for GET requests and requests to external websites
|
||||||
if ($CI->config->item('csrf_protection') === TRUE)
|
if ($CI->config->item('csrf_protection') === TRUE AND ! (strpos($action, $CI->config->site_url()) === FALSE OR strpos($form, 'method="get"')))
|
||||||
{
|
{
|
||||||
$hidden[$CI->security->get_csrf_token_name()] = $CI->security->get_csrf_hash();
|
$hidden[$CI->security->get_csrf_token_name()] = $CI->security->get_csrf_hash();
|
||||||
}
|
}
|
||||||
@@ -94,7 +94,7 @@ if ( ! function_exists('form_open'))
|
|||||||
*/
|
*/
|
||||||
if ( ! function_exists('form_open_multipart'))
|
if ( ! function_exists('form_open_multipart'))
|
||||||
{
|
{
|
||||||
function form_open_multipart($action, $attributes = array(), $hidden = array())
|
function form_open_multipart($action = '', $attributes = array(), $hidden = array())
|
||||||
{
|
{
|
||||||
if (is_string($attributes))
|
if (is_string($attributes))
|
||||||
{
|
{
|
||||||
@@ -249,7 +249,7 @@ if ( ! function_exists('form_textarea'))
|
|||||||
{
|
{
|
||||||
function form_textarea($data = '', $value = '', $extra = '')
|
function form_textarea($data = '', $value = '', $extra = '')
|
||||||
{
|
{
|
||||||
$defaults = array('name' => (( ! is_array($data)) ? $data : ''), 'cols' => '90', 'rows' => '12');
|
$defaults = array('name' => (( ! is_array($data)) ? $data : ''), 'cols' => '40', 'rows' => '10');
|
||||||
|
|
||||||
if ( ! is_array($data) OR ! isset($data['value']))
|
if ( ! is_array($data) OR ! isset($data['value']))
|
||||||
{
|
{
|
||||||
|
|||||||
0
system/helpers/html_helper.php
Executable file → Normal file
0
system/helpers/html_helper.php
Executable file → Normal file
0
system/helpers/index.html
Executable file → Normal file
0
system/helpers/index.html
Executable file → Normal file
0
system/helpers/inflector_helper.php
Executable file → Normal file
0
system/helpers/inflector_helper.php
Executable file → Normal file
0
system/helpers/language_helper.php
Executable file → Normal file
0
system/helpers/language_helper.php
Executable file → Normal file
0
system/helpers/number_helper.php
Executable file → Normal file
0
system/helpers/number_helper.php
Executable file → Normal file
0
system/helpers/path_helper.php
Executable file → Normal file
0
system/helpers/path_helper.php
Executable file → Normal file
0
system/helpers/security_helper.php
Executable file → Normal file
0
system/helpers/security_helper.php
Executable file → Normal file
0
system/helpers/smiley_helper.php
Executable file → Normal file
0
system/helpers/smiley_helper.php
Executable file → Normal file
17
system/helpers/string_helper.php
Executable file → Normal file
17
system/helpers/string_helper.php
Executable file → Normal file
@@ -242,6 +242,23 @@ if ( ! function_exists('random_string'))
|
|||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add's _1 to a string or increment the ending number to allow _2, _3, etc
|
||||||
|
*
|
||||||
|
* @param string $str required
|
||||||
|
* @param string $separator What should the duplicate number be appended with
|
||||||
|
* @param string $first Which number should be used for the first dupe increment
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function increment_string($str, $separator = '_', $first = 1)
|
||||||
|
{
|
||||||
|
preg_match('/(.+)'.$separator.'([0-9]+)$/', $str, $match);
|
||||||
|
|
||||||
|
return isset($match[2]) ? $match[1].$separator.($match[2] + 1) : $str.$separator.$first;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Alternator
|
* Alternator
|
||||||
*
|
*
|
||||||
|
|||||||
0
system/helpers/text_helper.php
Executable file → Normal file
0
system/helpers/text_helper.php
Executable file → Normal file
0
system/helpers/typography_helper.php
Executable file → Normal file
0
system/helpers/typography_helper.php
Executable file → Normal file
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user