CI_DB_odbc_driver Class Reference

Inheritance diagram for CI_DB_odbc_driver:
Collaboration diagram for CI_DB_odbc_driver:

List of all members.


Public Member Functions

 CI_DB_odbc_driver ($params)
 db_connect ()
 Non-persistent database connection.
 db_pconnect ()
 Persistent database connection.
 db_select ()
 Select the database.
 db_set_charset ($charset, $collation)
 Set client character set.
 _version ()
 Version number query string.
 _execute ($sql)
 Execute the query.
 _prep_query ($sql)
 Prep the query.
 trans_begin ($test_mode=FALSE)
 Begin Transaction.
 trans_commit ()
 Commit Transaction.
 trans_rollback ()
 Rollback Transaction.
 escape_str ($str)
 Escape String.
 affected_rows ()
 Affected Rows.
 insert_id ()
 Insert ID.
 count_all ($table= '')
 "Count All" query
 _list_tables ($prefix_limit=FALSE)
 Show table query.
 _list_columns ($table= '')
 Show column query.
 _field_data ($table)
 Field data query.
 _error_message ()
 The error message string.
 _error_number ()
 The error message number.
 _escape_identifiers ($item)
 Escape the SQL Identifiers.
 _from_tables ($tables)
 From Tables.
 _insert ($table, $keys, $values)
 Insert statement.
 _update ($table, $values, $where, $orderby=array(), $limit=FALSE)
 Update statement.
 _truncate ($table)
 Truncate statement.
 _delete ($table, $where=array(), $like=array(), $limit=FALSE)
 Delete statement.
 _limit ($sql, $limit, $offset)
 Limit string.
 _close ($conn_id)
 Close DB Connection.

Public Attributes

 $dbdriver = 'odbc'
 $_escape_char = ''
 $_count_string = "SELECT COUNT(*) AS "
 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.
 $_random_keyword

Detailed Description

Definition at line 31 of file odbc_driver.php.


Member Function Documentation

CI_DB_odbc_driver::_close ( conn_id  ) 

Close DB Connection.

public

Parameters:
resource 
Returns:
void

Definition at line 572 of file odbc_driver.php.

00573         {
00574                 @odbc_close($conn_id);
00575         }

CI_DB_odbc_driver::_delete ( table,
where = array(),
like = array(),
limit = FALSE 
)

Delete statement.

Generates a platform-specific delete string from the supplied data

public

Parameters:
string the table name
array the where clause
string the limit clause
Returns:
string

Definition at line 523 of file odbc_driver.php.

Referenced by _truncate().

00524         {
00525                 $conditions = '';
00526 
00527                 if (count($where) > 0 OR count($like) > 0)
00528                 {
00529                         $conditions = "\nWHERE ";
00530                         $conditions .= implode("\n", $this->ar_where);
00531 
00532                         if (count($where) > 0 && count($like) > 0)
00533                         {
00534                                 $conditions .= " AND ";
00535                         }
00536                         $conditions .= implode("\n", $like);
00537                 }
00538 
00539                 $limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
00540         
00541                 return "DELETE FROM ".$table.$conditions.$limit;
00542         }

Here is the caller graph for this function:

CI_DB_odbc_driver::_error_message (  ) 

The error message string.

private

Returns:
string

Definition at line 367 of file odbc_driver.php.

00368         {
00369                 return odbc_errormsg($this->conn_id);
00370         }

CI_DB_odbc_driver::_error_number (  ) 

The error message number.

private

Returns:
integer

Definition at line 380 of file odbc_driver.php.

00381         {
00382                 return odbc_error($this->conn_id);
00383         }

CI_DB_odbc_driver::_escape_identifiers ( item  ) 

Escape the SQL Identifiers.

This function escapes column and table names

private

Parameters:
string 
Returns:
string

Definition at line 396 of file odbc_driver.php.

00397         {
00398                 if ($this->_escape_char == '')
00399                 {
00400                         return $item;
00401                 }
00402         
00403                 if (strpos($item, '.') !== FALSE)
00404                 {
00405                         $str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char;                    
00406                 }
00407                 else
00408                 {
00409                         $str = $this->_escape_char.$item.$this->_escape_char;
00410                 }
00411                 
00412                 // remove duplicates if the user already included the escape
00413                 return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
00414         }

CI_DB_odbc_driver::_execute ( sql  ) 

Execute the query.

private called by the base class

Parameters:
string an SQL query
Returns:
resource

Definition at line 130 of file odbc_driver.php.

References _prep_query().

00131         {
00132                 $sql = $this->_prep_query($sql);
00133                 return @odbc_exec($this->conn_id, $sql);
00134         }

Here is the call graph for this function:

CI_DB_odbc_driver::_field_data ( table  ) 

Field data query.

Generates a platform-specific query so that the column data can be retrieved

public

Parameters:
string the table name
Returns:
object

Definition at line 354 of file odbc_driver.php.

00355         {
00356                 return "SELECT TOP 1 FROM ".$table;
00357         }

CI_DB_odbc_driver::_from_tables ( tables  ) 

From Tables.

This function implicitly groups FROM tables so there is no confusion about operator precedence in harmony with SQL standards

public

Parameters:
type 
Returns:
type

Definition at line 428 of file odbc_driver.php.

00429         {
00430                 if ( ! is_array($tables))
00431                 {
00432                         $tables = array($tables);
00433                 }
00434                 
00435                 return '('.implode(', ', $tables).')';
00436         }

CI_DB_odbc_driver::_insert ( table,
keys,
values 
)

Insert statement.

Generates a platform-specific insert string from the supplied data

public

Parameters:
string the table name
array the insert keys
array the insert values
Returns:
string

Definition at line 451 of file odbc_driver.php.

00452         {       
00453                 return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")";
00454         }

CI_DB_odbc_driver::_limit ( sql,
limit,
offset 
)

Limit string.

Generates a platform-specific LIMIT clause

public

Parameters:
string the sql query string
integer the number of rows to limit the query to
integer the offset value
Returns:
string

Definition at line 557 of file odbc_driver.php.

00558         {
00559                 // Does ODBC doesn't use the LIMIT clause?
00560                 return $sql;
00561         }

CI_DB_odbc_driver::_list_columns ( table = ''  ) 

Show column query.

Generates a platform-specific query string so that the column names can be fetched

public

Parameters:
string the table name
Returns:
string

Definition at line 338 of file odbc_driver.php.

00339         {
00340                 return "SHOW COLUMNS FROM ".$table;
00341         }

CI_DB_odbc_driver::_list_tables ( prefix_limit = FALSE  ) 

Show table query.

Generates a platform-specific query string so that the table names can be fetched

private

Parameters:
boolean 
Returns:
string

Definition at line 314 of file odbc_driver.php.

00315         {
00316                 $sql = "SHOW TABLES FROM `".$this->database."`";
00317 
00318                 if ($prefix_limit !== FALSE AND $this->dbprefix != '')
00319                 {
00320                         //$sql .= " LIKE '".$this->dbprefix."%'";
00321                         return FALSE; // not currently supported
00322                 }
00323                 
00324                 return $sql;
00325         }

CI_DB_odbc_driver::_prep_query ( sql  ) 

Prep the query.

If needed, each database adapter can prep the query string

private called by execute()

Parameters:
string an SQL query
Returns:
string

Definition at line 147 of file odbc_driver.php.

Referenced by _execute().

00148         {
00149                 return $sql;
00150         }

Here is the caller graph for this function:

CI_DB_odbc_driver::_truncate ( table  ) 

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"

public

Parameters:
string the table name
Returns:
string

Definition at line 505 of file odbc_driver.php.

References _delete().

00506         {
00507                 return $this->_delete($table);
00508         }

Here is the call graph for this function:

CI_DB_odbc_driver::_update ( table,
values,
where,
orderby = array(),
limit = FALSE 
)

Update statement.

Generates a platform-specific update string from the supplied data

public

Parameters:
string the table name
array the update data
array the where clause
array the orderby clause
array the limit clause
Returns:
string

Definition at line 471 of file odbc_driver.php.

00472         {
00473                 foreach($values as $key => $val)
00474                 {
00475                         $valstr[] = $key." = ".$val;
00476                 }
00477                 
00478                 $limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
00479                 
00480                 $orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):'';
00481         
00482                 $sql = "UPDATE ".$table." SET ".implode(', ', $valstr);
00483 
00484                 $sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : '';
00485 
00486                 $sql .= $orderby.$limit;
00487                 
00488                 return $sql;
00489         }

CI_DB_odbc_driver::_version (  ) 

Version number query string.

public

Returns:
string

Definition at line 116 of file odbc_driver.php.

00117         {
00118                 return "SELECT version() AS ver";
00119         }

CI_DB_odbc_driver::affected_rows (  ) 

Affected Rows.

public

Returns:
integer

Definition at line 259 of file odbc_driver.php.

00260         {
00261                 return @odbc_num_rows($this->conn_id);
00262         }

CI_DB_odbc_driver::CI_DB_odbc_driver ( params  ) 

Definition at line 47 of file odbc_driver.php.

00048         {
00049                 parent::CI_DB($params);
00050                 
00051                 $this->_random_keyword = ' RND('.time().')'; // database specific random keyword
00052         }

CI_DB_odbc_driver::count_all ( table = ''  ) 

"Count All" query

Generates a platform-specific query string that counts all records in the specified database

public

Parameters:
string 
Returns:
string

Definition at line 289 of file odbc_driver.php.

00290         {
00291                 if ($table == '')
00292                         return '0';
00293         
00294                 $query = $this->query($this->_count_string . $this->_protect_identifiers('numrows'). " FROM " . $this->_protect_identifiers($table, TRUE, NULL, FALSE));
00295         
00296                 if ($query->num_rows() == 0)
00297                         return '0';
00298 
00299                 $row = $query->row();
00300                 return $row->numrows;
00301         }

CI_DB_odbc_driver::db_connect (  ) 

Non-persistent database connection.

private called by the base class

Returns:
resource

Definition at line 60 of file odbc_driver.php.

00061         {
00062                 return @odbc_connect($this->hostname, $this->username, $this->password);
00063         }

CI_DB_odbc_driver::db_pconnect (  ) 

Persistent database connection.

private called by the base class

Returns:
resource

Definition at line 73 of file odbc_driver.php.

00074         {
00075                 return @odbc_pconnect($this->hostname, $this->username, $this->password);
00076         }

CI_DB_odbc_driver::db_select (  ) 

Select the database.

private called by the base class

Returns:
resource

Definition at line 86 of file odbc_driver.php.

00087         {
00088                 // Not needed for ODBC
00089                 return TRUE;
00090         }

CI_DB_odbc_driver::db_set_charset ( charset,
collation 
)

Set client character set.

public

Parameters:
string 
string 
Returns:
resource

Definition at line 102 of file odbc_driver.php.

00103         {
00104                 // @todo - add support if needed
00105                 return TRUE;
00106         }

CI_DB_odbc_driver::escape_str ( str  ) 

Escape String.

public

Parameters:
string 
Returns:
string

Definition at line 242 of file odbc_driver.php.

References $CI, and get_instance().

00243         {
00244                 // Access the CI object
00245                 $CI =& get_instance();
00246 
00247                 // ODBC doesn't require escaping
00248                 return $CI->_remove_invisible_characters($str);
00249         }

Here is the call graph for this function:

CI_DB_odbc_driver::insert_id (  ) 

Insert ID.

public

Returns:
integer

Definition at line 272 of file odbc_driver.php.

00273         {
00274                 return @odbc_insert_id($this->conn_id);
00275         }

CI_DB_odbc_driver::trans_begin ( test_mode = FALSE  ) 

Begin Transaction.

public

Returns:
bool

Definition at line 160 of file odbc_driver.php.

00161         {
00162                 if ( ! $this->trans_enabled)
00163                 {
00164                         return TRUE;
00165                 }
00166                 
00167                 // When transactions are nested we only begin/commit/rollback the outermost ones
00168                 if ($this->_trans_depth > 0)
00169                 {
00170                         return TRUE;
00171                 }
00172 
00173                 // Reset the transaction failure flag.
00174                 // If the $test_mode flag is set to TRUE transactions will be rolled back
00175                 // even if the queries produce a successful result.
00176                 $this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE;
00177 
00178                 return odbc_autocommit($this->conn_id, FALSE);
00179         }

CI_DB_odbc_driver::trans_commit (  ) 

Commit Transaction.

public

Returns:
bool

Definition at line 189 of file odbc_driver.php.

00190         {
00191                 if ( ! $this->trans_enabled)
00192                 {
00193                         return TRUE;
00194                 }
00195 
00196                 // When transactions are nested we only begin/commit/rollback the outermost ones
00197                 if ($this->_trans_depth > 0)
00198                 {
00199                         return TRUE;
00200                 }
00201 
00202                 $ret = odbc_commit($this->conn_id);
00203                 odbc_autocommit($this->conn_id, TRUE);
00204                 return $ret;
00205         }

CI_DB_odbc_driver::trans_rollback (  ) 

Rollback Transaction.

public

Returns:
bool

Definition at line 215 of file odbc_driver.php.

00216         {
00217                 if ( ! $this->trans_enabled)
00218                 {
00219                         return TRUE;
00220                 }
00221 
00222                 // When transactions are nested we only begin/commit/rollback the outermost ones
00223                 if ($this->_trans_depth > 0)
00224                 {
00225                         return TRUE;
00226                 }
00227 
00228                 $ret = odbc_rollback($this->conn_id);
00229                 odbc_autocommit($this->conn_id, TRUE);
00230                 return $ret;
00231         }


Member Data Documentation

CI_DB_odbc_driver::$_count_string = "SELECT COUNT(*) AS "

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.

Definition at line 43 of file odbc_driver.php.

CI_DB_odbc_driver::$_escape_char = ''

Definition at line 36 of file odbc_driver.php.

CI_DB_odbc_driver::$_random_keyword

Definition at line 44 of file odbc_driver.php.

CI_DB_odbc_driver::$dbdriver = 'odbc'

Definition at line 33 of file odbc_driver.php.


The documentation for this class was generated from the following file: