summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--system/database/drivers/odbc/odbc_driver.php206
-rw-r--r--system/database/drivers/odbc/odbc_forge.php131
-rw-r--r--system/database/drivers/odbc/odbc_result.php92
-rw-r--r--system/database/drivers/odbc/odbc_utility.php44
-rw-r--r--user_guide_src/source/changelog.rst1
5 files changed, 164 insertions, 310 deletions
diff --git a/system/database/drivers/odbc/odbc_driver.php b/system/database/drivers/odbc/odbc_driver.php
index 2575f431d..01515221b 100644
--- a/system/database/drivers/odbc/odbc_driver.php
+++ b/system/database/drivers/odbc/odbc_driver.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* ODBC Database Adapter Class
*
@@ -42,40 +40,44 @@
*/
class CI_DB_odbc_driver extends CI_DB {
- var $dbdriver = 'odbc';
+ public $dbdriver = 'odbc';
// the character used to excape - not necessary for ODBC
- var $_escape_char = '';
+ protected $_escape_char = '';
// clause and character used for LIKE escape sequences
- var $_like_escape_str = " {escape '%s'} ";
- var $_like_escape_chr = '!';
+ protected $_like_escape_str = ' {escape \'%s\'} ';
+ protected $_like_escape_chr = '!';
/**
* The syntax to count rows is slightly different across different
* database engines, so this string appears in each driver and is
* used for the count_all() and count_all_results() functions.
*/
- var $_count_string = "SELECT COUNT(*) AS ";
- var $_random_keyword;
-
+ protected $_count_string = 'SELECT COUNT(*) AS ';
+ protected $_random_keyword;
function __construct($params)
{
parent::__construct($params);
$this->_random_keyword = ' RND('.time().')'; // database specific random keyword
+
+ // Legacy support for DSN in the hostname field
+ if ($this->dsn == '')
+ {
+ $this->dsn = $this->hostname;
+ }
}
/**
* Non-persistent database connection
*
- * @access private called by the base class
* @return resource
*/
- function db_connect()
+ public function db_connect()
{
- return @odbc_connect($this->hostname, $this->username, $this->password);
+ return @odbc_connect($this->dsn, $this->username, $this->password);
}
// --------------------------------------------------------------------
@@ -83,12 +85,11 @@ class CI_DB_odbc_driver extends CI_DB {
/**
* Persistent database connection
*
- * @access private called by the base class
* @return resource
*/
- function db_pconnect()
+ public function db_pconnect()
{
- return @odbc_pconnect($this->hostname, $this->username, $this->password);
+ return @odbc_pconnect($this->dsn, $this->username, $this->password);
}
// --------------------------------------------------------------------
@@ -99,10 +100,9 @@ class CI_DB_odbc_driver extends CI_DB {
* Keep / reestablish the db connection if no queries have been
* sent for a length of time exceeding the server's idle timeout
*
- * @access public
* @return void
*/
- function reconnect()
+ public function reconnect()
{
// not implemented in odbc
}
@@ -112,10 +112,9 @@ class CI_DB_odbc_driver extends CI_DB {
/**
* Select the database
*
- * @access private called by the base class
* @return resource
*/
- function db_select()
+ public function db_select()
{
// Not needed for ODBC
return TRUE;
@@ -126,14 +125,12 @@ class CI_DB_odbc_driver extends CI_DB {
/**
* Execute the query
*
- * @access private called by the base class
* @param string an SQL query
* @return resource
*/
- function _execute($sql)
+ protected function _execute($sql)
{
- $sql = $this->_prep_query($sql);
- return @odbc_exec($this->conn_id, $sql);
+ return @odbc_exec($this->conn_id, $this->_prep_query($sql));
}
// --------------------------------------------------------------------
@@ -143,11 +140,10 @@ class CI_DB_odbc_driver extends CI_DB {
*
* If needed, each database adapter can prep the query string
*
- * @access private called by execute()
* @param string an SQL query
* @return string
*/
- function _prep_query($sql)
+ protected function _prep_query($sql)
{
return $sql;
}
@@ -157,18 +153,12 @@ class CI_DB_odbc_driver extends CI_DB {
/**
* Begin Transaction
*
- * @access public
* @return bool
*/
- function trans_begin($test_mode = FALSE)
+ public function trans_begin($test_mode = FALSE)
{
- if ( ! $this->trans_enabled)
- {
- return TRUE;
- }
-
// When transactions are nested we only begin/commit/rollback the outermost ones
- if ($this->_trans_depth > 0)
+ if ( ! $this->trans_enabled OR $this->_trans_depth > 0)
{
return TRUE;
}
@@ -176,7 +166,7 @@ class CI_DB_odbc_driver extends CI_DB {
// Reset the transaction failure flag.
// If the $test_mode flag is set to TRUE transactions will be rolled back
// even if the queries produce a successful result.
- $this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE;
+ $this->_trans_failure = ($test_mode === TRUE);
return odbc_autocommit($this->conn_id, FALSE);
}
@@ -186,18 +176,12 @@ class CI_DB_odbc_driver extends CI_DB {
/**
* Commit Transaction
*
- * @access public
* @return bool
*/
- function trans_commit()
+ public function trans_commit()
{
- if ( ! $this->trans_enabled)
- {
- return TRUE;
- }
-
// When transactions are nested we only begin/commit/rollback the outermost ones
- if ($this->_trans_depth > 0)
+ if ( ! $this->trans_enabled OR $this->_trans_depth > 0)
{
return TRUE;
}
@@ -212,18 +196,12 @@ class CI_DB_odbc_driver extends CI_DB {
/**
* Rollback Transaction
*
- * @access public
* @return bool
*/
- function trans_rollback()
+ public function trans_rollback()
{
- if ( ! $this->trans_enabled)
- {
- return TRUE;
- }
-
// When transactions are nested we only begin/commit/rollback the outermost ones
- if ($this->_trans_depth > 0)
+ if ( ! $this->trans_enabled OR $this->_trans_depth > 0)
{
return TRUE;
}
@@ -238,12 +216,11 @@ class CI_DB_odbc_driver extends CI_DB {
/**
* Escape String
*
- * @access public
* @param string
* @param bool whether or not the string will be used in a LIKE condition
* @return string
*/
- function escape_str($str, $like = FALSE)
+ public function escape_str($str, $like = FALSE)
{
if (is_array($str))
{
@@ -261,9 +238,9 @@ class CI_DB_odbc_driver extends CI_DB {
// escape LIKE condition wildcards
if ($like === TRUE)
{
- $str = str_replace( array('%', '_', $this->_like_escape_chr),
- array($this->_like_escape_chr.'%', $this->_like_escape_chr.'_', $this->_like_escape_chr.$this->_like_escape_chr),
- $str);
+ return str_replace(array('%', '_', $this->_like_escape_chr),
+ array($this->_like_escape_chr.'%', $this->_like_escape_chr.'_', $this->_like_escape_chr.$this->_like_escape_chr),
+ $str);
}
return $str;
@@ -274,10 +251,9 @@ class CI_DB_odbc_driver extends CI_DB {
/**
* Affected Rows
*
- * @access public
- * @return integer
+ * @return int
*/
- function affected_rows()
+ public function affected_rows()
{
return @odbc_num_rows($this->conn_id);
}
@@ -302,27 +278,25 @@ class CI_DB_odbc_driver extends CI_DB {
* Generates a platform-specific query string that counts all records in
* the specified database
*
- * @access public
* @param string
- * @return string
+ * @return int
*/
- function count_all($table = '')
+ public function count_all($table = '')
{
if ($table == '')
{
return 0;
}
- $query = $this->query($this->_count_string . $this->protect_identifiers('numrows') . " FROM " . $this->protect_identifiers($table, TRUE, NULL, FALSE));
-
+ $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();
+ $query = $query->row();
$this->_reset_select();
- return (int) $row->numrows;
+ return (int) $query->numrows;
}
// --------------------------------------------------------------------
@@ -336,11 +310,11 @@ class CI_DB_odbc_driver extends CI_DB {
* @param boolean
* @return string
*/
- function _list_tables($prefix_limit = FALSE)
+ protected function _list_tables($prefix_limit = FALSE)
{
- $sql = "SHOW TABLES FROM `".$this->database."`";
+ $sql = 'SHOW TABLES FROM `'.$this->database.'`';
- if ($prefix_limit !== FALSE AND $this->dbprefix != '')
+ if ($prefix_limit !== FALSE && $this->dbprefix != '')
{
//$sql .= " LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr);
return FALSE; // not currently supported
@@ -356,13 +330,12 @@ class CI_DB_odbc_driver extends CI_DB {
*
* Generates a platform-specific query string so that the column names can be fetched
*
- * @access public
* @param string the table name
* @return string
*/
- function _list_columns($table = '')
+ protected function _list_columns($table = '')
{
- return "SHOW COLUMNS FROM ".$table;
+ return 'SHOW COLUMNS FROM '.$table;
}
// --------------------------------------------------------------------
@@ -372,13 +345,12 @@ class CI_DB_odbc_driver extends CI_DB {
*
* Generates a platform-specific query so that the column data can be retrieved
*
- * @access public
* @param string the table name
- * @return object
+ * @return string
*/
- function _field_data($table)
+ protected function _field_data($table)
{
- return "SELECT TOP 1 FROM ".$table;
+ return 'SELECT TOP 1 FROM '.$table;
}
// --------------------------------------------------------------------
@@ -403,11 +375,10 @@ class CI_DB_odbc_driver extends CI_DB {
*
* This function escapes column and table names
*
- * @access private
* @param string
* @return string
*/
- function _escape_identifiers($item)
+ public function _escape_identifiers($item)
{
if ($this->_escape_char == '')
{
@@ -418,24 +389,20 @@ class CI_DB_odbc_driver extends CI_DB {
{
if (strpos($item, '.'.$id) !== FALSE)
{
- $str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item);
+ $item = str_replace('.', $this->_escape_char.'.', $item);
// remove duplicates if the user already included the escape
- return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
+ return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $this->_escape_char.$item);
}
}
if (strpos($item, '.') !== FALSE)
{
- $str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char;
- }
- else
- {
- $str = $this->_escape_char.$item.$this->_escape_char;
+ $item = str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item);
}
// remove duplicates if the user already included the escape
- return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
+ return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $this->_escape_char.$item.$this->_escape_char);
}
// --------------------------------------------------------------------
@@ -446,11 +413,10 @@ class CI_DB_odbc_driver extends CI_DB {
* This function implicitly groups FROM tables so there is no confusion
* about operator precedence in harmony with SQL standards
*
- * @access public
- * @param type
- * @return type
+ * @param string the table name
+ * @return string
*/
- function _from_tables($tables)
+ protected function _from_tables($tables)
{
if ( ! is_array($tables))
{
@@ -467,15 +433,14 @@ class CI_DB_odbc_driver extends CI_DB {
*
* Generates a platform-specific insert string from the supplied data
*
- * @access public
* @param string the table name
* @param array the insert keys
* @param array the insert values
* @return string
*/
- function _insert($table, $keys, $values)
+ protected function _insert($table, $keys, $values)
{
- return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")";
+ return 'INSERT INTO '.$table.' ('.implode(', ', $keys).') VALUES ('.implode(', ', $values).')';
}
// --------------------------------------------------------------------
@@ -485,7 +450,6 @@ class CI_DB_odbc_driver extends CI_DB {
*
* Generates a platform-specific update string from the supplied data
*
- * @access public
* @param string the table name
* @param array the update data
* @param array the where clause
@@ -493,24 +457,17 @@ class CI_DB_odbc_driver extends CI_DB {
* @param array the limit clause
* @return string
*/
- function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
+ protected function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
{
foreach ($values as $key => $val)
{
- $valstr[] = $key." = ".$val;
+ $valstr[] = $key.' = '.$val;
}
- $limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
-
- $orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):'';
-
- $sql = "UPDATE ".$table." SET ".implode(', ', $valstr);
-
- $sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : '';
-
- $sql .= $orderby.$limit;
-
- return $sql;
+ return 'UPDATE '.$table.' SET '.implode(', ', $valstr)
+ .(($where != '' && count($where) > 0) ? ' WHERE '.implode(' ', $where) : '')
+ .(count($orderby) > 0 ? ' ORDER BY '.implode(', ', $orderby) : '')
+ .( ! $limit ? '' : ' LIMIT '.$limit);
}
@@ -523,11 +480,10 @@ class CI_DB_odbc_driver extends CI_DB {
* If the database does not support the truncate() command
* This function maps to "DELETE FROM table"
*
- * @access public
* @param string the table name
* @return string
*/
- function _truncate($table)
+ protected function _truncate($table)
{
return $this->_delete($table);
}
@@ -539,31 +495,27 @@ class CI_DB_odbc_driver extends CI_DB {
*
* Generates a platform-specific delete string from the supplied data
*
- * @access public
* @param string the table name
* @param array the where clause
* @param string the limit clause
* @return string
*/
- function _delete($table, $where = array(), $like = array(), $limit = FALSE)
+ protected function _delete($table, $where = array(), $like = array(), $limit = FALSE)
{
$conditions = '';
if (count($where) > 0 OR count($like) > 0)
{
- $conditions = "\nWHERE ";
- $conditions .= implode("\n", $this->ar_where);
+ $conditions = "\nWHERE ".implode("\n", $this->ar_where);
if (count($where) > 0 && count($like) > 0)
{
- $conditions .= " AND ";
+ $conditions .= ' AND ';
}
$conditions .= implode("\n", $like);
}
- $limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
-
- return "DELETE FROM ".$table.$conditions.$limit;
+ return 'DELETE FROM '.$table.$conditions.( ! $limit ? '' : ' LIMIT '.$limit);
}
// --------------------------------------------------------------------
@@ -573,16 +525,14 @@ class CI_DB_odbc_driver extends CI_DB {
*
* Generates a platform-specific LIMIT clause
*
- * @access public
* @param string the sql query string
- * @param integer the number of rows to limit the query to
- * @param integer the offset value
+ * @param int the number of rows to limit the query to
+ * @param int the offset value
* @return string
*/
- function _limit($sql, $limit, $offset)
+ protected function _limit($sql, $limit, $offset)
{
- // Does ODBC doesn't use the LIMIT clause?
- return $sql;
+ return $sql.($offset == 0 ? '' : $offset.', ').$limit;
}
// --------------------------------------------------------------------
@@ -590,19 +540,15 @@ class CI_DB_odbc_driver extends CI_DB {
/**
* Close DB Connection
*
- * @access public
* @param resource
* @return void
*/
- function _close($conn_id)
+ protected function _close($conn_id)
{
@odbc_close($conn_id);
}
-
}
-
-
/* End of file odbc_driver.php */
/* Location: ./system/database/drivers/odbc/odbc_driver.php */
diff --git a/system/database/drivers/odbc/odbc_forge.php b/system/database/drivers/odbc/odbc_forge.php
index 51addf03d..49e5c3e72 100644
--- a/system/database/drivers/odbc/odbc_forge.php
+++ b/system/database/drivers/odbc/odbc_forge.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* ODBC Forge Class
*
@@ -39,19 +37,14 @@ class CI_DB_odbc_forge extends CI_DB_forge {
/**
* Create database
*
- * @access private
* @param string the database name
* @return bool
*/
- function _create_database()
+ public function _create_database()
{
// ODBC has no "create database" command since it's
// designed to connect to an existing database
- if ($this->db->db_debug)
- {
- return $this->db->display_error('db_unsuported_feature');
- }
- return FALSE;
+ return ($this->db->db_debug) ? $this->db->display_error('db_unsuported_feature') : FALSE;
}
// --------------------------------------------------------------------
@@ -59,19 +52,14 @@ class CI_DB_odbc_forge extends CI_DB_forge {
/**
* Drop database
*
- * @access private
* @param string the database name
* @return bool
*/
- function _drop_database($name)
+ public function _drop_database($name)
{
// ODBC has no "drop database" command since it's
// designed to connect to an existing database
- if ($this->db->db_debug)
- {
- return $this->db->display_error('db_unsuported_feature');
- }
- return FALSE;
+ return ($this->db->db_debug) ? $this->db->display_error('db_unsuported_feature') : FALSE;
}
// --------------------------------------------------------------------
@@ -79,7 +67,6 @@ class CI_DB_odbc_forge extends CI_DB_forge {
/**
* Create Table
*
- * @access private
* @param string the table name
* @param array the fields
* @param mixed primary key(s)
@@ -87,7 +74,7 @@ class CI_DB_odbc_forge extends CI_DB_forge {
* @param boolean should 'IF NOT EXISTS' be added to the SQL
* @return bool
*/
- function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
+ public function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists)
{
$sql = 'CREATE TABLE ';
@@ -96,54 +83,29 @@ class CI_DB_odbc_forge extends CI_DB_forge {
$sql .= 'IF NOT EXISTS ';
}
- $sql .= $this->db->_escape_identifiers($table)." (";
+ $sql .= $this->db->_escape_identifiers($table).' (';
$current_field_count = 0;
- foreach ($fields as $field=>$attributes)
+ foreach ($fields as $field => $attributes)
{
// Numeric field names aren't allowed in databases, so if the key is
// numeric, we know it was assigned by PHP and the developer manually
// entered the field information, so we'll simply add it to the list
if (is_numeric($field))
{
- $sql .= "\n\t$attributes";
+ $sql .= "\n\t".$attributes;
}
else
{
$attributes = array_change_key_case($attributes, CASE_UPPER);
- $sql .= "\n\t".$this->db->protect_identifiers($field);
-
- $sql .= ' '.$attributes['TYPE'];
-
- if (array_key_exists('CONSTRAINT', $attributes))
- {
- $sql .= '('.$attributes['CONSTRAINT'].')';
- }
-
- if (array_key_exists('UNSIGNED', $attributes) && $attributes['UNSIGNED'] === TRUE)
- {
- $sql .= ' UNSIGNED';
- }
-
- if (array_key_exists('DEFAULT', $attributes))
- {
- $sql .= ' DEFAULT \''.$attributes['DEFAULT'].'\'';
- }
-
- if (array_key_exists('NULL', $attributes) && $attributes['NULL'] === TRUE)
- {
- $sql .= ' NULL';
- }
- else
- {
- $sql .= ' NOT NULL';
- }
-
- if (array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE)
- {
- $sql .= ' AUTO_INCREMENT';
- }
+ $sql .= "\n\t".$this->db->protect_identifiers($field)
+ .' '.$attributes['TYPE']
+ .( ! empty($attributes['CONSTRAINT']) ? '('.$attributes['CONSTRAINT'].')' : '')
+ .(( ! empty($attributes['UNSIGNED']) && $attributes['UNSIGNED'] === TRUE) ? ' UNSIGNED' : '')
+ .(isset($attributes['DEFAULT'], $attributes) ? " DEFAULT '".$attributes['DEFAULT']."'" : '')
+ .(( ! empty($attributes['NULL']) && $attributes['NULL'] === TRUE) ? ' NULL' : ' NOT NULL')
+ .(( ! empty($attributes['AUTO_INCREMENT']) && $attributes['AUTO_INCREMENT'] === TRUE) ? ' AUTO_INCREMENT' : '');
}
// don't add a comma on the end of the last field
@@ -155,8 +117,7 @@ class CI_DB_odbc_forge extends CI_DB_forge {
if (count($primary_keys) > 0)
{
- $primary_keys = $this->db->protect_identifiers($primary_keys);
- $sql .= ",\n\tPRIMARY KEY (" . implode(', ', $primary_keys) . ")";
+ $sql .= ",\n\tPRIMARY KEY (".implode(', ', $this->protect_identifiers($primary_keys)).')';
}
if (is_array($keys) && count($keys) > 0)
@@ -172,13 +133,11 @@ class CI_DB_odbc_forge extends CI_DB_forge {
$key = array($this->db->protect_identifiers($key));
}
- $sql .= ",\n\tFOREIGN KEY (" . implode(', ', $key) . ")";
+ $sql .= ",\n\tFOREIGN KEY (".implode(', ', $key).')';
}
}
- $sql .= "\n)";
-
- return $sql;
+ return $sql."\n)";
}
// --------------------------------------------------------------------
@@ -186,17 +145,12 @@ class CI_DB_odbc_forge extends CI_DB_forge {
/**
* Drop Table
*
- * @access private
* @return bool
*/
- function _drop_table($table)
+ public function _drop_table($table)
{
// Not a supported ODBC feature
- if ($this->db->db_debug)
- {
- return $this->db->display_error('db_unsuported_feature');
- }
- return FALSE;
+ return ($this->db->db_debug) ? $this->db->display_error('db_unsuported_feature') : FALSE;
}
// --------------------------------------------------------------------
@@ -207,49 +161,29 @@ class CI_DB_odbc_forge extends CI_DB_forge {
* Generates a platform-specific query so that a table can be altered
* Called by add_column(), drop_column(), and column_alter(),
*
- * @access private
* @param string the ALTER type (ADD, DROP, CHANGE)
* @param string the column name
* @param string the table name
* @param string the column definition
* @param string the default value
- * @param boolean should 'NOT NULL' be added
+ * @param bool should 'NOT NULL' be added
* @param string the field after which we should add the new field
- * @return object
+ * @return string
*/
- function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '')
+ public function _alter_table($alter_type, $table, $column_name, $column_definition = '', $default_value = '', $null = '', $after_field = '')
{
$sql = 'ALTER TABLE '.$this->db->protect_identifiers($table).' '.$alter_type.' '.$this->db->protect_identifiers($column_name);
// DROP has everything it needs now.
- if ($alter_type == 'DROP')
+ 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 != '')
- {
- return $sql.' AFTER '.$this->db->protect_identifiers($after_field);
- }
-
- return $sql;
-
+ return $sql.' '.$column_definition
+ .($default_value != '' ? ' DEFAULT "'.$default_value.'"' : '')
+ .($null === NULL ? ' NULL' : ' NOT NULL')
+ .($after_field != '' ? ' AFTER '.$this->db->protect_identifiers($after_field) : '');
}
@@ -260,12 +194,11 @@ class CI_DB_odbc_forge extends CI_DB_forge {
*
* Generates a platform-specific query so that a table can be renamed
*
- * @access private
* @param string the old table name
* @param string the new table name
* @return string
*/
- function _rename_table($table_name, $new_table_name)
+ public function _rename_table($table_name, $new_table_name)
{
return 'ALTER TABLE '.$this->db->protect_identifiers($table_name).' RENAME TO '.$this->db->protect_identifiers($new_table_name);
}
diff --git a/system/database/drivers/odbc/odbc_result.php b/system/database/drivers/odbc/odbc_result.php
index de2c58cb9..219d16fa3 100644
--- a/system/database/drivers/odbc/odbc_result.php
+++ b/system/database/drivers/odbc/odbc_result.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* ODBC Result Class
*
@@ -61,8 +59,6 @@ class CI_DB_odbc_result extends CI_DB_result {
return $this->num_rows;
}
- // --------------------------------------------------------------------
-
/**
* Number of fields in the result set
*
@@ -128,9 +124,9 @@ class CI_DB_odbc_result extends CI_DB_result {
/**
* Free the result
*
- * @return null
+ * @return void
*/
- function free_result()
+ public function free_result()
{
if (is_resource($this->result_id))
{
@@ -144,15 +140,15 @@ class CI_DB_odbc_result extends CI_DB_result {
/**
* Data Seek
*
- * Moves the internal pointer to the desired offset. We call
+ * Moves the internal pointer to the desired offset. We call
* this internally before fetching results to make sure the
* result set starts at zero
*
- * @access private
* @return array
*/
- function _data_seek($n = 0)
+ protected function _data_seek($n = 0)
{
+ // Not supported
return FALSE;
}
@@ -163,19 +159,13 @@ class CI_DB_odbc_result extends CI_DB_result {
*
* Returns the result set as an array
*
- * @access private
* @return array
*/
- function _fetch_assoc()
+ protected function _fetch_assoc()
{
- if (function_exists('odbc_fetch_object'))
- {
- return odbc_fetch_array($this->result_id);
- }
- else
- {
- return $this->_odbc_fetch_array($this->result_id);
- }
+ return function_exists('odbc_fetch_array')
+ ? odbc_fetch_array($this->result_id)
+ : $this->_odbc_fetch_array($this->result_id);
}
// --------------------------------------------------------------------
@@ -185,40 +175,38 @@ class CI_DB_odbc_result extends CI_DB_result {
*
* Returns the result set as an object
*
- * @access private
* @return object
*/
- function _fetch_object()
+ protected function _fetch_object()
{
- if (function_exists('odbc_fetch_object'))
- {
- return odbc_fetch_object($this->result_id);
- }
- else
- {
- return $this->_odbc_fetch_object($this->result_id);
- }
+ return function_exists('odbc_fetch_object')
+ ? odbc_fetch_object($this->result_id)
+ : $this->_odbc_fetch_object($this->result_id);
}
-
/**
* Result - object
*
* subsititutes the odbc_fetch_object function when
* not available (odbc_fetch_object requires unixODBC)
*
- * @access private
* @return object
*/
- function _odbc_fetch_object(& $odbc_result) {
+ private function _odbc_fetch_object(& $odbc_result)
+ {
$rs = array();
- $rs_obj = FALSE;
- if (odbc_fetch_into($odbc_result, $rs)) {
- foreach ($rs as $k=>$v) {
- $field_name= odbc_field_name($odbc_result, $k+1);
- $rs_obj->$field_name = $v;
- }
+ if ( ! odbc_fetch_into($odbc_result, $rs))
+ {
+ return FALSE;
}
+
+ $rs_obj = new stdClass();
+ foreach ($rs as $k => $v)
+ {
+ $field_name = odbc_field_name($odbc_result, $k+1);
+ $rs_obj->$field_name = $v;
+ }
+
return $rs_obj;
}
@@ -229,19 +217,23 @@ class CI_DB_odbc_result extends CI_DB_result {
* subsititutes the odbc_fetch_array function when
* not available (odbc_fetch_array requires unixODBC)
*
- * @access private
* @return array
*/
- function _odbc_fetch_array(& $odbc_result) {
+ private function _odbc_fetch_array(& $odbc_result)
+ {
$rs = array();
- $rs_assoc = FALSE;
- if (odbc_fetch_into($odbc_result, $rs)) {
- $rs_assoc=array();
- foreach ($rs as $k=>$v) {
- $field_name= odbc_field_name($odbc_result, $k+1);
- $rs_assoc[$field_name] = $v;
- }
+ if ( ! odbc_fetch_into($odbc_result, $rs))
+ {
+ return FALSE;
}
+
+ $rs_assoc = array();
+ foreach ($rs as $k => $v)
+ {
+ $field_name = odbc_field_name($odbc_result, $k+1);
+ $rs_assoc[$field_name] = $v;
+ }
+
return $rs_assoc;
}
diff --git a/system/database/drivers/odbc/odbc_utility.php b/system/database/drivers/odbc/odbc_utility.php
index bae3fe853..e71bc5a03 100644
--- a/system/database/drivers/odbc/odbc_utility.php
+++ b/system/database/drivers/odbc/odbc_utility.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* ODBC Utility Class
*
@@ -39,17 +37,12 @@ class CI_DB_odbc_utility extends CI_DB_utility {
/**
* List databases
*
- * @access private
* @return bool
*/
- function _list_databases()
+ public function _list_databases()
{
// Not sure if ODBC lets you list all databases...
- if ($this->db->db_debug)
- {
- return $this->db->display_error('db_unsuported_feature');
- }
- return FALSE;
+ return ($this->db->db_debug) ? $this->db->display_error('db_unsuported_feature') : FALSE;
}
// --------------------------------------------------------------------
@@ -59,18 +52,13 @@ class CI_DB_odbc_utility extends CI_DB_utility {
*
* Generates a platform-specific query so that a table can be optimized
*
- * @access private
* @param string the table name
- * @return object
+ * @return bool
*/
- function _optimize_table($table)
+ public function _optimize_table($table)
{
// Not a supported ODBC feature
- if ($this->db->db_debug)
- {
- return $this->db->display_error('db_unsuported_feature');
- }
- return FALSE;
+ return ($this->db->db_debug) ? $this->db->display_error('db_unsuported_feature') : FALSE;
}
// --------------------------------------------------------------------
@@ -80,18 +68,13 @@ class CI_DB_odbc_utility extends CI_DB_utility {
*
* Generates a platform-specific query so that a table can be repaired
*
- * @access private
* @param string the table name
- * @return object
+ * @return bool
*/
- function _repair_table($table)
+ public function _repair_table($table)
{
// Not a supported ODBC feature
- if ($this->db->db_debug)
- {
- return $this->db->display_error('db_unsuported_feature');
- }
- return FALSE;
+ return ($this->db->db_debug) ? $this->db->display_error('db_unsuported_feature') : FALSE;
}
// --------------------------------------------------------------------
@@ -99,11 +82,10 @@ class CI_DB_odbc_utility extends CI_DB_utility {
/**
* ODBC Export
*
- * @access private
* @param array Preferences
* @return mixed
*/
- function _backup($params = array())
+ public function _backup($params = array())
{
// Currently unsupported
return $this->db->display_error('db_unsuported_feature');
@@ -112,4 +94,4 @@ class CI_DB_odbc_utility extends CI_DB_utility {
}
/* End of file odbc_utility.php */
-/* Location: ./system/database/drivers/odbc/odbc_utility.php */ \ No newline at end of file
+/* Location: ./system/database/drivers/odbc/odbc_utility.php */
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index 587c64c5a..f4ae10e46 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -65,6 +65,7 @@ Release Date: Not Released
- Added a constructor to the DB_result class and moved all driver-specific properties and logic out of the base DB_driver class to allow better abstraction.
- Removed limit() and order_by() support for UPDATE and DELETE queries in PostgreSQL driver. Postgres does not support those features.
- Removed protect_identifiers() and renamed _protect_identifiers() to it instead - it was just an alias.
+ - Added DSN string support for ODBC.
- Libraries