summaryrefslogtreecommitdiffstats
path: root/system/database/drivers/odbc
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@server-speed.net>2011-01-28 22:51:06 +0100
committerFlorian Pritz <bluewind@server-speed.net>2011-01-28 22:58:52 +0100
commitce2b69675075444c9e40b72bcdd42ab7edbbe633 (patch)
tree2932f13b0db14fe53dc0622d888318db638a017f /system/database/drivers/odbc
parentb6b8a6587c399bfd89e13e92ce04ee8486688e6e (diff)
update to CI 2.0
Signed-off-by: Florian Pritz <bluewind@server-speed.net>
Diffstat (limited to 'system/database/drivers/odbc')
-rwxr-xr-x[-rw-r--r--]system/database/drivers/odbc/index.html0
-rwxr-xr-x[-rw-r--r--]system/database/drivers/odbc/odbc_driver.php119
-rwxr-xr-x[-rw-r--r--]system/database/drivers/odbc/odbc_forge.php42
-rwxr-xr-x[-rw-r--r--]system/database/drivers/odbc/odbc_result.php22
-rwxr-xr-x[-rw-r--r--]system/database/drivers/odbc/odbc_utility.php55
5 files changed, 95 insertions, 143 deletions
diff --git a/system/database/drivers/odbc/index.html b/system/database/drivers/odbc/index.html
index c942a79ce..c942a79ce 100644..100755
--- a/system/database/drivers/odbc/index.html
+++ b/system/database/drivers/odbc/index.html
diff --git a/system/database/drivers/odbc/odbc_driver.php b/system/database/drivers/odbc/odbc_driver.php
index 6cb3080d4..c8e03c356 100644..100755
--- a/system/database/drivers/odbc/odbc_driver.php
+++ b/system/database/drivers/odbc/odbc_driver.php
@@ -2,11 +2,11 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 4.3.2 or newer
+ * An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
- * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
+ * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
@@ -31,14 +31,14 @@
class CI_DB_odbc_driver extends CI_DB {
var $dbdriver = 'odbc';
-
+
// the character used to excape - not necessary for ODBC
var $_escape_char = '';
-
+
// clause and character used for LIKE escape sequences
var $_like_escape_str = " {escape '%s'} ";
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
@@ -51,7 +51,7 @@ class CI_DB_odbc_driver extends CI_DB {
function CI_DB_odbc_driver($params)
{
parent::CI_DB($params);
-
+
$this->_random_keyword = ' RND('.time().')'; // database specific random keyword
}
@@ -60,12 +60,12 @@ class CI_DB_odbc_driver extends CI_DB {
*
* @access private called by the base class
* @return resource
- */
+ */
function db_connect()
{
return @odbc_connect($this->hostname, $this->username, $this->password);
}
-
+
// --------------------------------------------------------------------
/**
@@ -73,12 +73,12 @@ class CI_DB_odbc_driver extends CI_DB {
*
* @access private called by the base class
* @return resource
- */
+ */
function db_pconnect()
{
return @odbc_pconnect($this->hostname, $this->username, $this->password);
}
-
+
// --------------------------------------------------------------------
/**
@@ -102,7 +102,7 @@ class CI_DB_odbc_driver extends CI_DB {
*
* @access private called by the base class
* @return resource
- */
+ */
function db_select()
{
// Not needed for ODBC
@@ -126,7 +126,7 @@ class CI_DB_odbc_driver extends CI_DB {
}
// --------------------------------------------------------------------
-
+
/**
* Version number query string
*
@@ -146,13 +146,13 @@ class CI_DB_odbc_driver extends CI_DB {
* @access private called by the base class
* @param string an SQL query
* @return resource
- */
+ */
function _execute($sql)
{
$sql = $this->_prep_query($sql);
return @odbc_exec($this->conn_id, $sql);
}
-
+
// --------------------------------------------------------------------
/**
@@ -163,7 +163,7 @@ class CI_DB_odbc_driver extends CI_DB {
* @access private called by execute()
* @param string an SQL query
* @return string
- */
+ */
function _prep_query($sql)
{
return $sql;
@@ -175,15 +175,15 @@ class CI_DB_odbc_driver extends CI_DB {
* Begin Transaction
*
* @access public
- * @return bool
- */
+ * @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)
{
@@ -204,8 +204,8 @@ class CI_DB_odbc_driver extends CI_DB {
* Commit Transaction
*
* @access public
- * @return bool
- */
+ * @return bool
+ */
function trans_commit()
{
if ( ! $this->trans_enabled)
@@ -230,8 +230,8 @@ class CI_DB_odbc_driver extends CI_DB {
* Rollback Transaction
*
* @access public
- * @return bool
- */
+ * @return bool
+ */
function trans_rollback()
{
if ( ! $this->trans_enabled)
@@ -265,19 +265,16 @@ class CI_DB_odbc_driver extends CI_DB {
if (is_array($str))
{
foreach($str as $key => $val)
- {
+ {
$str[$key] = $this->escape_str($val, $like);
- }
-
- return $str;
- }
-
- // Access the CI object
- $CI =& get_instance();
-
+ }
+
+ return $str;
+ }
+
// ODBC doesn't require escaping
- $str = $CI->input->_remove_invisible_characters($str);
-
+ $str = remove_invisible_characters($str);
+
// escape LIKE condition wildcards
if ($like === TRUE)
{
@@ -285,10 +282,10 @@ class CI_DB_odbc_driver extends CI_DB {
array($this->_like_escape_chr.'%', $this->_like_escape_chr.'_', $this->_like_escape_chr.$this->_like_escape_chr),
$str);
}
-
+
return $str;
}
-
+
// --------------------------------------------------------------------
/**
@@ -301,7 +298,7 @@ class CI_DB_odbc_driver extends CI_DB {
{
return @odbc_num_rows($this->conn_id);
}
-
+
// --------------------------------------------------------------------
/**
@@ -362,13 +359,13 @@ class CI_DB_odbc_driver extends CI_DB {
if ($prefix_limit !== FALSE AND $this->dbprefix != '')
{
- //$sql .= " LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_char);
+ //$sql .= " LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr);
return FALSE; // not currently supported
}
-
+
return $sql;
}
-
+
// --------------------------------------------------------------------
/**
@@ -413,7 +410,7 @@ class CI_DB_odbc_driver extends CI_DB {
{
return odbc_errormsg($this->conn_id);
}
-
+
// --------------------------------------------------------------------
/**
@@ -449,26 +446,26 @@ class CI_DB_odbc_driver extends CI_DB {
{
if (strpos($item, '.'.$id) !== FALSE)
{
- $str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item);
-
+ $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;
+ $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);
}
-
+
// --------------------------------------------------------------------
/**
@@ -487,12 +484,12 @@ class CI_DB_odbc_driver extends CI_DB {
{
$tables = array($tables);
}
-
+
return '('.implode(', ', $tables).')';
}
// --------------------------------------------------------------------
-
+
/**
* Insert statement
*
@@ -505,10 +502,10 @@ class CI_DB_odbc_driver extends CI_DB {
* @return string
*/
function _insert($table, $keys, $values)
- {
+ {
return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")";
}
-
+
// --------------------------------------------------------------------
/**
@@ -530,21 +527,21 @@ class CI_DB_odbc_driver extends CI_DB {
{
$valstr[] = $key." = ".$val;
}
-
+
$limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
-
+
$orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):'';
-
+
$sql = "UPDATE ".$table." SET ".implode(', ', $valstr);
$sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : '';
$sql .= $orderby.$limit;
-
+
return $sql;
}
-
+
// --------------------------------------------------------------------
/**
@@ -557,12 +554,12 @@ class CI_DB_odbc_driver extends CI_DB {
* @access public
* @param string the table name
* @return string
- */
+ */
function _truncate($table)
{
return $this->_delete($table);
}
-
+
// --------------------------------------------------------------------
/**
@@ -575,7 +572,7 @@ class CI_DB_odbc_driver extends CI_DB {
* @param array the where clause
* @param string the limit clause
* @return string
- */
+ */
function _delete($table, $where = array(), $like = array(), $limit = FALSE)
{
$conditions = '';
@@ -593,7 +590,7 @@ class CI_DB_odbc_driver extends CI_DB {
}
$limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
-
+
return "DELETE FROM ".$table.$conditions.$limit;
}
@@ -630,7 +627,7 @@ class CI_DB_odbc_driver extends CI_DB {
@odbc_close($conn_id);
}
-
+
}
diff --git a/system/database/drivers/odbc/odbc_forge.php b/system/database/drivers/odbc/odbc_forge.php
index 1ae559b6e..3ec86b4e9 100644..100755
--- a/system/database/drivers/odbc/odbc_forge.php
+++ b/system/database/drivers/odbc/odbc_forge.php
@@ -2,11 +2,11 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 4.3.2 or newer
+ * An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
- * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
+ * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
@@ -54,7 +54,7 @@ class CI_DB_odbc_forge extends CI_DB_forge {
function _drop_database($name)
{
// ODBC has no "drop database" command since it's
- // designed to connect to an existing database
+ // designed to connect to an existing database
if ($this->db->db_debug)
{
return $this->db->display_error('db_unsuported_feature');
@@ -78,12 +78,12 @@ class CI_DB_odbc_forge extends CI_DB_forge {
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;
@@ -99,41 +99,41 @@ class CI_DB_odbc_forge extends CI_DB_forge {
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';
+ $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))
{
@@ -146,24 +146,24 @@ class CI_DB_odbc_forge extends CI_DB_forge {
$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);
+ $key = $this->db->_protect_identifiers($key);
}
else
{
$key = array($this->db->_protect_identifiers($key));
}
-
+
$sql .= ",\n\tFOREIGN KEY (" . implode(', ', $key) . ")";
}
}
-
+
$sql .= "\n)";
return $sql;
@@ -179,7 +179,7 @@ class CI_DB_odbc_forge extends CI_DB_forge {
*/
function _drop_table($table)
{
- // Not a supported ODBC feature
+ // Not a supported ODBC feature
if ($this->db->db_debug)
{
return $this->db->display_error('db_unsuported_feature');
@@ -235,9 +235,9 @@ class CI_DB_odbc_forge extends CI_DB_forge {
{
$sql .= ' AFTER ' . $this->db->_protect_identifiers($after_field);
}
-
+
return $sql;
-
+
}
diff --git a/system/database/drivers/odbc/odbc_result.php b/system/database/drivers/odbc/odbc_result.php
index 5ae46df62..a81a2b8b7 100644..100755
--- a/system/database/drivers/odbc/odbc_result.php
+++ b/system/database/drivers/odbc/odbc_result.php
@@ -2,11 +2,11 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 4.3.2 or newer
+ * An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
- * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
+ * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
@@ -25,7 +25,7 @@
* @link http://codeigniter.com/user_guide/database/
*/
class CI_DB_odbc_result extends CI_DB_result {
-
+
/**
* Number of rows in the result set
*
@@ -36,7 +36,7 @@ class CI_DB_odbc_result extends CI_DB_result {
{
return @odbc_num_rows($this->result_id);
}
-
+
// --------------------------------------------------------------------
/**
@@ -65,9 +65,9 @@ class CI_DB_odbc_result extends CI_DB_result {
$field_names = array();
for ($i = 0; $i < $this->num_fields(); $i++)
{
- $field_names[] = odbc_field_name($this->result_id, $i);
+ $field_names[] = odbc_field_name($this->result_id, $i);
}
-
+
return $field_names;
}
@@ -86,16 +86,16 @@ class CI_DB_odbc_result extends CI_DB_result {
$retval = array();
for ($i = 0; $i < $this->num_fields(); $i++)
{
- $F = new stdClass();
- $F->name = odbc_field_name($this->result_id, $i);
- $F->type = odbc_field_type($this->result_id, $i);
+ $F = new stdClass();
+ $F->name = odbc_field_name($this->result_id, $i);
+ $F->type = odbc_field_type($this->result_id, $i);
$F->max_length = odbc_field_len($this->result_id, $i);
$F->primary_key = 0;
$F->default = '';
$retval[] = $F;
}
-
+
return $retval;
}
@@ -105,7 +105,7 @@ class CI_DB_odbc_result extends CI_DB_result {
* Free the result
*
* @return null
- */
+ */
function free_result()
{
if (is_resource($this->result_id))
diff --git a/system/database/drivers/odbc/odbc_utility.php b/system/database/drivers/odbc/odbc_utility.php
index 4e6848e82..d335bed99 100644..100755
--- a/system/database/drivers/odbc/odbc_utility.php
+++ b/system/database/drivers/odbc/odbc_utility.php
@@ -2,11 +2,11 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 4.3.2 or newer
+ * An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
- * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
+ * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
@@ -32,7 +32,7 @@ class CI_DB_odbc_utility extends CI_DB_utility {
*/
function _list_databases()
{
- // Not sure if ODBC lets you list all databases...
+ // Not sure if ODBC lets you list all databases...
if ($this->db->db_debug)
{
return $this->db->display_error('db_unsuported_feature');
@@ -53,7 +53,7 @@ class CI_DB_odbc_utility extends CI_DB_utility {
*/
function _optimize_table($table)
{
- // Not a supported ODBC feature
+ // Not a supported ODBC feature
if ($this->db->db_debug)
{
return $this->db->display_error('db_unsuported_feature');
@@ -74,7 +74,7 @@ class CI_DB_odbc_utility extends CI_DB_utility {
*/
function _repair_table($table)
{
- // Not a supported ODBC feature
+ // Not a supported ODBC feature
if ($this->db->db_debug)
{
return $this->db->display_error('db_unsuported_feature');
@@ -96,52 +96,7 @@ class CI_DB_odbc_utility extends CI_DB_utility {
// Currently unsupported
return $this->db->display_error('db_unsuported_feature');
}
-
- /**
- *
- * The functions below have been deprecated as of 1.6, and are only here for backwards
- * compatibility. They now reside in dbforge(). The use of dbutils for database manipulation
- * is STRONGLY discouraged in favour if using dbforge.
- *
- */
- /**
- * Create database
- *
- * @access private
- * @param string the database name
- * @return bool
- */
- function _create_database()
- {
- // ODBC 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)
- {
- // ODBC 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;
- }
}
/* End of file odbc_utility.php */