CI_DB_active_record Class Reference

Inheritance diagram for CI_DB_active_record:
Collaboration diagram for CI_DB_active_record:

List of all members.


Public Member Functions

 dbprefix ($table= '')
 DB Prefix.
 select ($select= '*', $protect_identifiers=TRUE)
 Select.
 select_max ($select= '', $alias='')
 Select Max.
 select_min ($select= '', $alias='')
 Select Min.
 select_avg ($select= '', $alias='')
 Select Average.
 select_sum ($select= '', $alias='')
 Select Sum.
 distinct ($val=TRUE)
 DISTINCT.
 from ($from)
 From.
 join ($table, $cond, $type= '')
 Join.
 where ($key, $value=NULL, $escape=TRUE)
 Where.
 or_where ($key, $value=NULL, $escape=TRUE)
 OR Where.
 orwhere ($key, $value=NULL, $escape=TRUE)
 orwhere() is an alias of or_where() this function is here for backwards compatibility, as orwhere() has been deprecated
 _where ($key, $value=NULL, $type= 'AND ', $escape=TRUE)
 Where.
 where_in ($key=NULL, $values=NULL)
 Where_in.
 or_where_in ($key=NULL, $values=NULL)
 Where_in_or.
 where_not_in ($key=NULL, $values=NULL)
 Where_not_in.
 or_where_not_in ($key=NULL, $values=NULL)
 Where_not_in_or.
 _where_in ($key=NULL, $values=NULL, $not=FALSE, $type= 'AND ')
 Where_in.
 like ($field, $match= '', $side= 'both')
 Like.
 not_like ($field, $match= '', $side= 'both')
 Not Like.
 or_like ($field, $match= '', $side= 'both')
 OR Like.
 or_not_like ($field, $match= '', $side= 'both')
 OR Not Like.
 orlike ($field, $match= '', $side= 'both')
 orlike() is an alias of or_like() this function is here for backwards compatibility, as orlike() has been deprecated
 _like ($field, $match= '', $type= 'AND ', $side= 'both', $not= '')
 Like.
 group_by ($by)
 GROUP BY.
 groupby ($by)
 groupby() is an alias of group_by() this function is here for backwards compatibility, as groupby() has been deprecated
 having ($key, $value= '', $escape=TRUE)
 Sets the HAVING value.
 orhaving ($key, $value= '', $escape=TRUE)
 orhaving() is an alias of or_having() this function is here for backwards compatibility, as orhaving() has been deprecated
 or_having ($key, $value= '', $escape=TRUE)
 Sets the OR HAVING value.
 _having ($key, $value= '', $type= 'AND ', $escape=TRUE)
 Sets the HAVING values.
 order_by ($orderby, $direction= '')
 Sets the ORDER BY value.
 orderby ($orderby, $direction= '')
 orderby() is an alias of order_by() this function is here for backwards compatibility, as orderby() has been deprecated
 limit ($value, $offset= '')
 Sets the LIMIT value.
 offset ($offset)
 Sets the OFFSET value.
 set ($key, $value= '', $escape=TRUE)
 The "set" function.
 get ($table= '', $limit=null, $offset=null)
 Get.
 count_all_results ($table= '')
 "Count All Results" query
 get_where ($table= '', $where=null, $limit=null, $offset=null)
 Get_Where.
 getwhere ($table= '', $where=null, $limit=null, $offset=null)
 getwhere() is an alias of get_where() this function is here for backwards compatibility, as getwhere() has been deprecated
 insert ($table= '', $set=NULL)
 Insert.
 update ($table= '', $set=NULL, $where=NULL, $limit=NULL)
 Update.
 empty_table ($table= '')
 Empty Table.
 truncate ($table= '')
 Truncate.
 delete ($table= '', $where= '', $limit=NULL, $reset_data=TRUE)
 Delete.
 use_table ($table)
 Use Table - DEPRECATED.
 _track_aliases ($table)
 Track Aliases.
 _filter_table_aliases ($statements)
 Filter Table Aliases.
 _compile_select ($select_override=FALSE)
 Compile the SELECT statement.
 _object_to_array ($object)
 Object to Array.
 start_cache ()
 Start Cache.
 stop_cache ()
 Stop Cache.
 flush_cache ()
 Flush Cache.
 _merge_cache ()
 Merge Cache.
 _reset_run ($ar_reset_items)
 Resets the active record values.
 _reset_select ()
 Resets the active record values.
 _reset_write ()
 Resets the active record "write" values.

Public Attributes

 $ar_select = array()
 $ar_distinct = FALSE
 $ar_from = array()
 $ar_join = array()
 $ar_where = array()
 $ar_like = array()
 $ar_groupby = array()
 $ar_having = array()
 $ar_limit = FALSE
 $ar_offset = FALSE
 $ar_order = FALSE
 $ar_orderby = array()
 $ar_set = array()
 $ar_wherein = array()
 $ar_aliased_tables = array()
 $ar_store_array = array()
 $ar_caching = FALSE
 $ar_cache_select = array()
 $ar_cache_from = array()
 $ar_cache_join = array()
 $ar_cache_where = array()
 $ar_cache_like = array()
 $ar_cache_groupby = array()
 $ar_cache_having = array()
 $ar_cache_limit = FALSE
 $ar_cache_offset = FALSE
 $ar_cache_order = FALSE
 $ar_cache_orderby = array()
 $ar_cache_set = array()

Detailed Description

Definition at line 29 of file DB_active_rec.php.


Member Function Documentation

CI_DB_active_record::_compile_select ( select_override = FALSE  ) 

Compile the SELECT statement.

Generates a query string based on which functions were used. Should not be called directly. The get() function calls it.

private

Returns:
string

Definition at line 1456 of file DB_active_rec.php.

References _filter_table_aliases(), _merge_cache(), and dbprefix().

Referenced by count_all_results(), get(), and get_where().

01457         {
01458                 $this->_merge_cache();
01459 
01460                 $sql = ( ! $this->ar_distinct) ? 'SELECT ' : 'SELECT DISTINCT ';
01461         
01462                 $sql .= (count($this->ar_select) == 0) ? '*' : implode(', ', $this->_filter_table_aliases($this->ar_select));
01463 
01464                 if ($select_override !== FALSE)
01465                 {
01466                         $sql = $select_override;
01467                 }
01468 
01469                 if (count($this->ar_from) > 0)
01470                 {
01471                         $sql .= "\nFROM ";
01472                         $sql .= $this->_from_tables($this->ar_from);
01473                 }
01474 
01475                 if (count($this->ar_join) > 0)
01476                 {
01477                         $sql .= "\n";
01478 
01479                         // special consideration for table aliases
01480                         if (count($this->ar_aliased_tables) > 0 && $this->dbprefix)
01481                         {
01482                                 $sql .= implode("\n", $this->_filter_table_aliases($this->ar_join));
01483                         }
01484                         else
01485                         {
01486                                 $sql .= implode("\n", $this->ar_join);
01487                         }
01488 
01489                 }
01490 
01491                 if (count($this->ar_where) > 0 OR count($this->ar_like) > 0)
01492                 {
01493                         $sql .= "\nWHERE ";
01494                 }
01495 
01496                 $sql .= implode("\n", $this->ar_where);
01497                 
01498                 if (count($this->ar_like) > 0)
01499                 {
01500                         if (count($this->ar_where) > 0)
01501                         {
01502                                 $sql .= " AND ";
01503                         }
01504 
01505                         $sql .= implode("\n", $this->ar_like);
01506                 }
01507                 
01508                 if (count($this->ar_groupby) > 0)
01509                 {
01510 
01511                         $sql .= "\nGROUP BY ";
01512                         
01513                         // special consideration for table aliases
01514                         if (count($this->ar_aliased_tables) > 0 && $this->dbprefix)
01515                         {
01516                                 $sql .= implode(", ", $this->_filter_table_aliases($this->ar_groupby));
01517                         }
01518                         else
01519                         {
01520                                 $sql .= implode(', ', $this->ar_groupby);
01521                         }
01522                 }
01523                 
01524                 if (count($this->ar_having) > 0)
01525                 {
01526                         $sql .= "\nHAVING ";
01527                         $sql .= implode("\n", $this->ar_having);
01528                 }
01529 
01530                 if (count($this->ar_orderby) > 0)
01531                 {
01532                         $sql .= "\nORDER BY ";
01533                         $sql .= implode(', ', $this->ar_orderby);
01534                         
01535                         if ($this->ar_order !== FALSE)
01536                         {
01537                                 $sql .= ($this->ar_order == 'desc') ? ' DESC' : ' ASC';
01538                         }               
01539                 }
01540                 
01541                 if (is_numeric($this->ar_limit))
01542                 {
01543                         $sql .= "\n";
01544                         $sql = $this->_limit($sql, $this->ar_limit, $this->ar_offset);
01545                 }
01546 
01547                 return $sql;
01548         }

Here is the call graph for this function:

Here is the caller graph for this function:

CI_DB_active_record::_filter_table_aliases ( statements  ) 

Filter Table Aliases.

Intelligently removes database prefixes from aliased tables

private

Parameters:
array An array of compiled SQL
Returns:
array Cleaned up statement with aliases accounted for

Definition at line 1431 of file DB_active_rec.php.

References dbprefix().

Referenced by _compile_select().

01432         {
01433 
01434                 foreach ($statements as $k => $v)
01435                 {
01436                         foreach ($this->ar_aliased_tables as $table)
01437                         {
01438                                 $statements[$k] = preg_replace('/(\w+\.\w+)/', $this->_protect_identifiers('$0'), $statements[$k]); // makes `table.field`
01439                                 $statements[$k] = str_replace($this->dbprefix.$table.'.', $table.'.', $statements[$k]);
01440                         }
01441                 }
01442                 return $statements;
01443         }

Here is the call graph for this function:

Here is the caller graph for this function:

CI_DB_active_record::_having ( key,
value = '',
type = 'AND ',
escape = TRUE 
)

Sets the HAVING values.

Called by having() or orhaving()

private

Parameters:
string 
string 
Returns:
object

Definition at line 832 of file DB_active_rec.php.

References CI_DB_driver::_has_operator().

Referenced by having(), and or_having().

00833         {
00834                 if ( ! is_array($key))
00835                 {
00836                         $key = array($key => $value);
00837                 }
00838         
00839                 foreach ($key as $k => $v)
00840                 {
00841                         $prefix = (count($this->ar_having) == 0) ? '' : $type;
00842 
00843                         if ($escape === TRUE)
00844                         {
00845                                 $k = $this->_protect_identifiers($k);
00846                         }
00847 
00848                         if ( ! $this->_has_operator($k))
00849                         {
00850                                 $k .= ' = ';
00851                         }
00852 
00853                         if ($v != '')
00854                         {
00855                                 $v = ' '.$this->escape_str($v);
00856                         }
00857                         
00858                         $this->ar_having[] = $prefix.$k.$v;
00859                         if ($this->ar_caching === TRUE)
00860                         {
00861                                 $this->ar_cache_having[] = $prefix.$k.$v;
00862                         }
00863                 }
00864                 
00865                 return $this;
00866         }

Here is the call graph for this function:

Here is the caller graph for this function:

CI_DB_active_record::_like ( field,
match = '',
type = 'AND ',
side = 'both',
not = '' 
)

Like.

Called by like() or orlike()

private

Parameters:
mixed 
mixed 
string 
Returns:
object

Definition at line 690 of file DB_active_rec.php.

Referenced by like(), not_like(), or_like(), and or_not_like().

00691         {
00692                 if ( ! is_array($field))
00693                 {
00694                         $field = array($field => $match);
00695                 }
00696         
00697                 foreach ($field as $k => $v)
00698                 {               
00699 
00700                         $k = $this->_protect_identifiers($k);
00701 
00702                         $prefix = (count($this->ar_like) == 0) ? '' : $type;
00703 
00704                         $v = $this->escape_str($v);
00705 
00706                         if ($side == 'before')
00707                         {
00708                                 $like_statement = $prefix." $k $not LIKE '%{$v}'";
00709                         }
00710                         elseif ($side == 'after')
00711                         {
00712                                 $like_statement = $prefix." $k $not LIKE '{$v}%'";
00713                         }
00714                         else
00715                         {
00716                                 $like_statement = $prefix." $k $not LIKE '%{$v}%'";
00717                         }
00718                         
00719                         $this->ar_like[] = $like_statement;
00720                         if ($this->ar_caching === TRUE)
00721                         {
00722                                 $this->ar_cache_like[] = $like_statement;
00723                         }
00724                         
00725                 }
00726                 return $this;
00727         }

Here is the caller graph for this function:

CI_DB_active_record::_merge_cache (  ) 

Merge Cache.

When called, this function merges any cached AR arrays with locally called ones.

private

Returns:
void

Definition at line 1651 of file DB_active_rec.php.

Referenced by _compile_select().

01652         {
01653                 $ar_items = array('select', 'from', 'join', 'where', 'like', 'groupby', 'having', 'orderby', 'set');
01654 
01655                 foreach ($ar_items as $ar_item)
01656                 {
01657                         $ar_cache_item = 'ar_cache_'.$ar_item;
01658                         $ar_item = 'ar_'.$ar_item;
01659                         $this->$ar_item = array_unique(array_merge($this->$ar_item, $this->$ar_cache_item));
01660                 }
01661         }

Here is the caller graph for this function:

CI_DB_active_record::_object_to_array ( object  ) 

Object to Array.

Takes an object as input and converts the class variables to array key/vals

public

Parameters:
object 
Returns:
array

Definition at line 1561 of file DB_active_rec.php.

Referenced by set().

01562         {
01563                 if ( ! is_object($object))
01564                 {
01565                         return $object;
01566                 }
01567                 
01568                 $array = array();
01569                 foreach (get_object_vars($object) as $key => $val)
01570                 {
01571                         // There are some built in keys we need to ignore for this conversion
01572                         if ( ! is_object($val) && ! is_array($val) && $key != '_parent_name' && $key != '_ci_scaffolding' && $key != '_ci_scaff_table')
01573   
01574                         {
01575                                 $array[$key] = $val;
01576                         }
01577                 }
01578         
01579                 return $array;
01580         }

Here is the caller graph for this function:

CI_DB_active_record::_reset_run ( ar_reset_items  ) 

Resets the active record values.

Called by the get() function

private

Parameters:
array An array of fields to reset
Returns:
void

Definition at line 1672 of file DB_active_rec.php.

Referenced by _reset_select(), _reset_write(), and flush_cache().

01673         {
01674                 foreach ($ar_reset_items as $item => $default_value)
01675                 {
01676                         if ( ! in_array($item, $this->ar_store_array))
01677                         {
01678                                 $this->$item = $default_value;
01679                         }
01680                 }
01681         }

Here is the caller graph for this function:

CI_DB_active_record::_reset_select (  ) 

Resets the active record values.

Called by the get() function

private

Returns:
void

Definition at line 1691 of file DB_active_rec.php.

References _reset_run().

Referenced by count_all_results(), get(), and get_where().

01692         {
01693                 $ar_reset_items = array(
01694                         'ar_select' => array(), 
01695                         'ar_from' => array(), 
01696                         'ar_join' => array(), 
01697                         'ar_where' => array(), 
01698                         'ar_like' => array(), 
01699                         'ar_groupby' => array(), 
01700                         'ar_having' => array(), 
01701                         'ar_orderby' => array(), 
01702                         'ar_wherein' => array(), 
01703                         'ar_aliased_tables' => array(),
01704                         'ar_distinct' => FALSE, 
01705                         'ar_limit' => FALSE, 
01706                         'ar_offset' => FALSE, 
01707                         'ar_order' => FALSE,
01708                 );
01709                 
01710                 $this->_reset_run($ar_reset_items);
01711         }

Here is the call graph for this function:

Here is the caller graph for this function:

CI_DB_active_record::_reset_write (  ) 

Resets the active record "write" values.

Called by the insert() update() and delete() functions

private

Returns:
void

Definition at line 1723 of file DB_active_rec.php.

References _reset_run().

Referenced by delete(), empty_table(), insert(), truncate(), and update().

01724         {       
01725                 $ar_reset_items = array(
01726                         'ar_set' => array(), 
01727                         'ar_from' => array(), 
01728                         'ar_where' => array(), 
01729                         'ar_like' => array(),
01730                         'ar_orderby' => array(), 
01731                         'ar_limit' => FALSE, 
01732                         'ar_order' => FALSE
01733                 );
01734 
01735                 $this->_reset_run($ar_reset_items);
01736         }

Here is the call graph for this function:

Here is the caller graph for this function:

CI_DB_active_record::_track_aliases ( table  ) 

Track Aliases.

Used to track SQL statements written with aliased tables.

private

Parameters:
string The table to inspect
Returns:
string

Definition at line 1406 of file DB_active_rec.php.

References dbprefix().

Referenced by count_all_results(), from(), get(), get_where(), and join().

01407         {
01408                 // if a table alias is used we can recognize it by a space
01409                 if (strpos($table, " ") !== FALSE)
01410                 {
01411                         // if the alias is written with the AS keyowrd, get it out
01412                         $table = preg_replace('/ AS /i', ' ', $table); 
01413 
01414                         $this->ar_aliased_tables[] = trim(strrchr($table, " "));
01415                 }
01416 
01417                 return $this->dbprefix.$table;
01418         }

Here is the call graph for this function:

Here is the caller graph for this function:

CI_DB_active_record::_where ( key,
value = NULL,
type = 'AND ',
escape = TRUE 
)

Where.

Called by where() or orwhere()

private

Parameters:
mixed 
mixed 
string 
Returns:
object

Definition at line 419 of file DB_active_rec.php.

References CI_DB_driver::_has_operator().

Referenced by or_where(), and where().

00420         {
00421                 if ( ! is_array($key))
00422                 {
00423                         $key = array($key => $value);
00424                 }
00425 
00426                 foreach ($key as $k => $v)
00427                 {
00428                         $prefix = (count($this->ar_where) == 0) ? '' : $type;
00429 
00430                         if (is_null($v) && ! $this->_has_operator($k))
00431                         {
00432                                 // value appears not to have been set, assign the test to IS NULL
00433                                 $k .= ' IS NULL';
00434                         }
00435                         
00436                         if ( ! is_null($v))
00437                         {
00438                                 if ($escape === TRUE)
00439                                 {
00440                                         // exception for "field<=" keys
00441                                         if ($this->_has_operator($k))
00442                                         {
00443                                                 $k =  preg_replace("/([A-Za-z_0-9]+)/", $this->_protect_identifiers('$1'), $k);
00444                                         }
00445                                         else
00446                                         {
00447                                                 $k = $this->_protect_identifiers($k);
00448                                         }
00449                                         
00450                                         $v = ' '.$this->escape($v);
00451                                 }
00452 
00453                                 if ( ! $this->_has_operator($k))
00454                                 {
00455                                         $k .= ' =';
00456                                 }
00457                         }
00458                         else
00459                         {
00460                                 if ($escape === TRUE)
00461                                 {
00462                                         $k = $this->_protect_identifiers($k, TRUE);
00463                                 }                               
00464                         }
00465 
00466                         $this->ar_where[] = $prefix.$k.$v;
00467                         
00468                         if ($this->ar_caching === TRUE)
00469                         {
00470                                 $this->ar_cache_where[] = $prefix.$k.$v;
00471                         }
00472                         
00473                 }
00474                 
00475                 return $this;
00476         }

Here is the call graph for this function:

Here is the caller graph for this function:

CI_DB_active_record::_where_in ( key = NULL,
values = NULL,
not = FALSE,
type = 'AND ' 
)

Where_in.

Called by where_in, where_in_or, where_not_in, where_not_in_or

public

Parameters:
string The field to search
array The values searched on
boolean If the statement whould be IN or NOT IN
string 
Returns:
object

Definition at line 564 of file DB_active_rec.php.

References CI_DB_driver::escape().

Referenced by or_where_in(), or_where_not_in(), where_in(), and where_not_in().

00565         {
00566                 if ($key === NULL OR ! is_array($values))
00567                 {
00568                         return;
00569                 }
00570 
00571                 $not = ($not) ? ' NOT ' : '';
00572 
00573                 foreach ($values as $value)
00574                 {
00575                         $this->ar_wherein[] = $this->escape($value);
00576                 }
00577 
00578                 $prefix = (count($this->ar_where) == 0) ? '' : $type;
00579  
00580                 $where_in = $prefix . $this->_protect_identifiers($key) . $not . " IN (" . implode(", ", $this->ar_wherein) . ") ";
00581 
00582                 $this->ar_where[] = $where_in;
00583                 if ($this->ar_caching === TRUE)
00584                 {
00585                         $this->ar_cache_where[] = $where_in;
00586                 }
00587 
00588                 // reset the array for multiple calls
00589                 $this->ar_wherein = array();
00590                 return $this;
00591         }

Here is the call graph for this function:

Here is the caller graph for this function:

CI_DB_active_record::count_all_results ( table = ''  ) 

"Count All Results" query

Generates a platform-specific query string that counts all records returned by an Active Record query.

public

Parameters:
string 
Returns:
string

Definition at line 1050 of file DB_active_rec.php.

References _compile_select(), _reset_select(), _track_aliases(), from(), and CI_DB_driver::query().

01051         {
01052                 if ($table != '')
01053                 {
01054                         $this->_track_aliases($table);
01055                         $this->from($table);
01056                 }
01057                 
01058                 $sql = $this->_compile_select($this->_count_string . $this->_protect_identifiers('numrows'));
01059 
01060                 $query = $this->query($sql);
01061                 $this->_reset_select();
01062         
01063                 if ($query->num_rows() == 0)
01064                 {
01065                         return '0';
01066                 }
01067 
01068                 $row = $query->row();
01069                 return $row->numrows;
01070         }

Here is the call graph for this function:

CI_DB_active_record::dbprefix ( table = ''  ) 

DB Prefix.

Prepends a database prefix if one exists in configuration

public

Parameters:
string the table
Returns:
string

Definition at line 73 of file DB_active_rec.php.

References CI_DB_driver::display_error().

Referenced by _compile_select(), _filter_table_aliases(), _track_aliases(), delete(), empty_table(), insert(), join(), select(), truncate(), and update().

00074         {
00075                 if ($table == '')
00076                 {
00077                         $this->display_error('db_table_name_required');
00078                 }
00079 
00080                 return $this->dbprefix.$table;
00081         }

Here is the call graph for this function:

Here is the caller graph for this function:

CI_DB_active_record::delete ( table = '',
where = '',
limit = NULL,
reset_data = TRUE 
)

Delete.

Compiles a delete string and runs the query

public

Parameters:
mixed the table(s) to delete from. String or array
mixed the where clause
mixed the limit clause
boolean 
Returns:
object

Definition at line 1323 of file DB_active_rec.php.

References _reset_write(), dbprefix(), CI_DB_driver::display_error(), limit(), CI_DB_driver::query(), and where().

01324         {
01325                 if ($table == '')
01326                 {
01327                         if ( ! isset($this->ar_from[0]))
01328                         {
01329                                 if ($this->db_debug)
01330                                 {
01331                                         return $this->display_error('db_must_set_table');
01332                                 }
01333                                 return FALSE;
01334                         }
01335 
01336                         $table = $this->ar_from[0];
01337                 }
01338                 elseif (is_array($table))
01339                 {
01340                         foreach($table as $single_table)
01341                         {
01342                                 $this->delete($single_table, $where, $limit, FALSE);
01343                         }
01344 
01345                         $this->_reset_write();
01346                         return;
01347                 }
01348                 else
01349                 {
01350                         $table = $this->_protect_identifiers($this->dbprefix.$table);
01351                 }
01352 
01353                 if ($where != '')
01354                 {
01355                         $this->where($where);
01356                 }
01357 
01358                 if ($limit != NULL)
01359                 {
01360                         $this->limit($limit);
01361                 }
01362 
01363                 if (count($this->ar_where) == 0 && count($this->ar_like) == 0)
01364                 {
01365                         if ($this->db_debug)
01366                         {
01367                                 return $this->display_error('db_del_must_use_where');
01368                         }
01369 
01370                         return FALSE;
01371                 }               
01372 
01373                 $sql = $this->_delete($table, $this->ar_where, $this->ar_like, $this->ar_limit);
01374 
01375                 if ($reset_data)
01376                 {
01377                         $this->_reset_write();
01378                 }
01379                 
01380                 return $this->query($sql);
01381         }

Here is the call graph for this function:

CI_DB_active_record::distinct ( val = TRUE  ) 

DISTINCT.

Sets a flag which tells the query string compiler to add DISTINCT

public

Parameters:
bool 
Returns:
object

Definition at line 275 of file DB_active_rec.php.

00276         {
00277                 $this->ar_distinct = (is_bool($val)) ? $val : TRUE;
00278                 return $this;
00279         }

CI_DB_active_record::empty_table ( table = ''  ) 

Empty Table.

Compiles a delete string and runs "DELETE FROM table"

public

Parameters:
string the table to empty
Returns:
object

Definition at line 1240 of file DB_active_rec.php.

References _reset_write(), dbprefix(), CI_DB_driver::display_error(), and CI_DB_driver::query().

01241         {
01242                 if ($table == '')
01243                 {
01244                         if ( ! isset($this->ar_from[0]))
01245                         {
01246                                 if ($this->db_debug)
01247                                 {
01248                                         return $this->display_error('db_must_set_table');
01249                                 }
01250                                 return FALSE;
01251                         }
01252 
01253                         $table = $this->ar_from[0];
01254                 }
01255                 else
01256                 {
01257                         $table = $this->_protect_identifiers($this->dbprefix.$table);
01258                 }
01259 
01260 
01261                 $sql = $this->_delete($table);
01262 
01263                 $this->_reset_write();
01264                 
01265                 return $this->query($sql);
01266         }

Here is the call graph for this function:

CI_DB_active_record::flush_cache (  ) 

Flush Cache.

Empties the AR cache

public

Returns:
void

Definition at line 1623 of file DB_active_rec.php.

References _reset_run().

01624         {       
01625                 $ar_reset_items = array(
01626                         'ar_cache_select' => array(), 
01627                         'ar_cache_from' => array(), 
01628                         'ar_cache_join' => array(),
01629                         'ar_cache_where' => array(), 
01630                         'ar_cache_like' => array(), 
01631                         'ar_cache_groupby' => array(), 
01632                         'ar_cache_having' =>array(), 
01633                         'ar_cache_orderby' => array(), 
01634                         'ar_cache_set' => array()
01635                 );
01636 
01637                 $this->_reset_run($ar_reset_items);     
01638         }

Here is the call graph for this function:

CI_DB_active_record::from ( from  ) 

From.

Generates the FROM portion of the query

public

Parameters:
mixed can be a string or array
Returns:
object

Definition at line 292 of file DB_active_rec.php.

References _track_aliases().

Referenced by count_all_results(), get(), get_where(), and use_table().

00293         {
00294                 foreach ((array)$from as $val)
00295                 {
00296                         $this->ar_from[] = $this->_protect_identifiers($this->_track_aliases($val));
00297                         if ($this->ar_caching === TRUE)
00298                         {
00299                                 $this->ar_cache_from[] = $this->_protect_identifiers($this->_track_aliases($val));
00300                         }
00301                 }
00302 
00303                 return $this;
00304         }

Here is the call graph for this function:

Here is the caller graph for this function:

CI_DB_active_record::get ( table = '',
limit = null,
offset = null 
)

Get.

Compiles the select statement based on the other functions called and runs the query

public

Parameters:
string the table
string the limit clause
string the offset clause
Returns:
object

Definition at line 1020 of file DB_active_rec.php.

References _compile_select(), _reset_select(), _track_aliases(), from(), limit(), and CI_DB_driver::query().

01021         {
01022                 if ($table != '')
01023                 {
01024                         $this->_track_aliases($table);
01025                         $this->from($table);
01026                 }
01027                 
01028                 if ( ! is_null($limit))
01029                 {
01030                         $this->limit($limit, $offset);
01031                 }
01032                         
01033                 $sql = $this->_compile_select();
01034 
01035                 $result = $this->query($sql);
01036                 $this->_reset_select();
01037                 return $result;
01038         }

Here is the call graph for this function:

CI_DB_active_record::get_where ( table = '',
where = null,
limit = null,
offset = null 
)

Get_Where.

Allows the where clause, limit and offset to be added directly

public

Parameters:
string the where clause
string the limit clause
string the offset clause
Returns:
object

Definition at line 1085 of file DB_active_rec.php.

References _compile_select(), _reset_select(), _track_aliases(), from(), limit(), CI_DB_driver::query(), and where().

Referenced by getwhere().

01086         {
01087                 if ($table != '')
01088                 {
01089                         $this->_track_aliases($table);
01090                         $this->from($table);
01091                 }
01092 
01093                 if ( ! is_null($where))
01094                 {
01095                         $this->where($where);
01096                 }
01097                 
01098                 if ( ! is_null($limit))
01099                 {
01100                         $this->limit($limit, $offset);
01101                 }
01102                         
01103                 $sql = $this->_compile_select();
01104 
01105                 $result = $this->query($sql);
01106                 $this->_reset_select();
01107                 return $result;
01108         }

Here is the call graph for this function:

Here is the caller graph for this function:

CI_DB_active_record::getwhere ( table = '',
where = null,
limit = null,
offset = null 
)

getwhere() is an alias of get_where() this function is here for backwards compatibility, as getwhere() has been deprecated

Definition at line 1117 of file DB_active_rec.php.

References get_where().

01118         {
01119                 return $this->get_where($table, $where, $limit, $offset);
01120         }

Here is the call graph for this function:

CI_DB_active_record::group_by ( by  ) 

GROUP BY.

public

Parameters:
string 
Returns:
object

Definition at line 738 of file DB_active_rec.php.

Referenced by groupby().

00739         {
00740                 if (is_string($by))
00741                 {
00742                         $by = explode(',', $by);
00743                 }
00744         
00745                 foreach ($by as $val)
00746                 {
00747                         $val = trim($val);
00748                 
00749                         if ($val != '')
00750                         {
00751                                 $this->ar_groupby[] = $this->_protect_identifiers($val);
00752                                 if ($this->ar_caching === TRUE)
00753                                 {
00754                                         $this->ar_cache_groupby[] = $this->_protect_identifiers($val);
00755                                 }
00756                         }
00757                 }
00758                 return $this;
00759         }

Here is the caller graph for this function:

CI_DB_active_record::groupby ( by  ) 

groupby() is an alias of group_by() this function is here for backwards compatibility, as groupby() has been deprecated

Definition at line 768 of file DB_active_rec.php.

References group_by().

00769         {
00770                 return $this->group_by($by);
00771         }       

Here is the call graph for this function:

CI_DB_active_record::having ( key,
value = '',
escape = TRUE 
)

Sets the HAVING value.

Separates multiple calls with AND

public

Parameters:
string 
string 
Returns:
object

Definition at line 785 of file DB_active_rec.php.

References _having().

00786         {
00787                 return $this->_having($key, $value, 'AND ', $escape);
00788         }

Here is the call graph for this function:

CI_DB_active_record::insert ( table = '',
set = NULL 
)

Insert.

Compiles an insert string and runs the query

public

Parameters:
string the table to retrieve the results from
array an associative array of insert values
Returns:
object

Definition at line 1134 of file DB_active_rec.php.

References _reset_write(), dbprefix(), CI_DB_driver::display_error(), and CI_DB_driver::query().

01135         {
01136                 if ( ! is_null($set))
01137                 {
01138                         $this->set($set);
01139                 }
01140         
01141                 if (count($this->ar_set) == 0)
01142                 {
01143                         if ($this->db_debug)
01144                         {
01145                                 return $this->display_error('db_must_use_set');
01146                         }
01147                         return FALSE;
01148                 }
01149 
01150                 if ($table == '')
01151                 {
01152                         if ( ! isset($this->ar_from[0]))
01153                         {
01154                                 if ($this->db_debug)
01155                                 {
01156                                         return $this->display_error('db_must_set_table');
01157                                 }
01158                                 return FALSE;
01159                         }
01160                         
01161                         $table = $this->ar_from[0];
01162                 }
01163 
01164                 $sql = $this->_insert($this->_protect_identifiers($this->dbprefix.$table), array_keys($this->ar_set), array_values($this->ar_set));
01165                 
01166                 $this->_reset_write();
01167                 return $this->query($sql);              
01168         }

Here is the call graph for this function:

CI_DB_active_record::join ( table,
cond,
type = '' 
)

Join.

Generates the JOIN portion of the query

public

Parameters:
string 
string the join condition
string the type of join
Returns:
object

Definition at line 319 of file DB_active_rec.php.

References _track_aliases(), and dbprefix().

00320         {               
00321                 if ($type != '')
00322                 {
00323                         $type = strtoupper(trim($type));
00324 
00325                         if ( ! in_array($type, array('LEFT', 'RIGHT', 'OUTER', 'INNER', 'LEFT OUTER', 'RIGHT OUTER'), TRUE))
00326                         {
00327                                 $type = '';
00328                         }
00329                         else
00330                         {
00331                                 $type .= ' ';
00332                         }
00333                 }
00334 
00335                 // If a DB prefix is used we might need to add it to the column names
00336                 if ($this->dbprefix)
00337                 {
00338                         $this->_track_aliases($table);
00339 
00340                         // First we remove any existing prefixes in the condition to avoid duplicates
00341                         $cond = preg_replace('|('.$this->dbprefix.')([\w\.]+)([\W\s]+)|', "$2$3", $cond);
00342 
00343                         // Next we add the prefixes to the condition
00344                         $cond = preg_replace('|([\w\.]+)([\W\s]+)(.+)|', $this->dbprefix . "$1$2" . $this->dbprefix . "$3", $cond);
00345                 }
00346 
00347                 $join = $type.'JOIN '.$this->_protect_identifiers($this->dbprefix.$table, TRUE).' ON '.$cond;
00348 
00349                 $this->ar_join[] = $join;
00350                 if ($this->ar_caching === TRUE)
00351                 {
00352                         $this->ar_cache_join[] = $join;
00353                 }
00354 
00355                 return $this;
00356         }

Here is the call graph for this function:

CI_DB_active_record::like ( field,
match = '',
side = 'both' 
)

Like.

Generates a LIKE% portion of the query. Separates multiple calls with AND

public

Parameters:
mixed 
mixed 
Returns:
object

Definition at line 606 of file DB_active_rec.php.

References _like().

00607         {
00608                 return $this->_like($field, $match, 'AND ', $side);
00609         }

Here is the call graph for this function:

CI_DB_active_record::limit ( value,
offset = '' 
)

Sets the LIMIT value.

public

Parameters:
integer the limit value
integer the offset value
Returns:
object

Definition at line 923 of file DB_active_rec.php.

Referenced by delete(), get(), get_where(), and update().

00924         {
00925                 $this->ar_limit = $value;
00926                 if ($this->ar_caching === TRUE)
00927                 {
00928                         $this->ar_cache_limit[] = $value;
00929                 }
00930 
00931                 if ($offset != '')
00932                 {
00933                         $this->ar_offset = $offset;
00934                         if ($this->ar_caching === TRUE)
00935                         {
00936                                 $this->ar_cache_offset[] = $offset;
00937                         }
00938                 }
00939                 
00940                 return $this;
00941         }

Here is the caller graph for this function:

CI_DB_active_record::not_like ( field,
match = '',
side = 'both' 
)

Not Like.

Generates a NOT LIKE portion of the query. Separates multiple calls with AND

public

Parameters:
mixed 
mixed 
Returns:
object

Definition at line 624 of file DB_active_rec.php.

References _like().

00625         {
00626                 return $this->_like($field, $match, 'AND ', $side, ' NOT');
00627         }

Here is the call graph for this function:

CI_DB_active_record::offset ( offset  ) 

Sets the OFFSET value.

public

Parameters:
integer the offset value
Returns:
object

Definition at line 952 of file DB_active_rec.php.

00953         {
00954                 $this->ar_offset = $offset;
00955                 if ($this->ar_caching === TRUE)
00956                 {
00957                         $this->ar_cache_offset[] = $offset;
00958                 }
00959                         
00960                 return $this;
00961         }

CI_DB_active_record::or_having ( key,
value = '',
escape = TRUE 
)

Sets the OR HAVING value.

Separates multiple calls with OR

public

Parameters:
string 
string 
Returns:
object

Definition at line 814 of file DB_active_rec.php.

References _having().

Referenced by orhaving().

00815         {
00816                 return $this->_having($key, $value, 'OR ', $escape);
00817         }

Here is the call graph for this function:

Here is the caller graph for this function:

CI_DB_active_record::or_like ( field,
match = '',
side = 'both' 
)

OR Like.

Generates a LIKE% portion of the query. Separates multiple calls with OR

public

Parameters:
mixed 
mixed 
Returns:
object

Definition at line 642 of file DB_active_rec.php.

References _like().

Referenced by orlike().

00643         {
00644                 return $this->_like($field, $match, 'OR ', $side);
00645         }

Here is the call graph for this function:

Here is the caller graph for this function:

CI_DB_active_record::or_not_like ( field,
match = '',
side = 'both' 
)

OR Not Like.

Generates a NOT LIKE portion of the query. Separates multiple calls with OR

public

Parameters:
mixed 
mixed 
Returns:
object

Definition at line 660 of file DB_active_rec.php.

References _like().

00661         {
00662                 return $this->_like($field, $match, 'OR ', $side, 'NOT ');
00663         }

Here is the call graph for this function:

CI_DB_active_record::or_where ( key,
value = NULL,
escape = TRUE 
)

OR Where.

Generates the WHERE portion of the query. Separates multiple calls with OR

public

Parameters:
mixed 
mixed 
Returns:
object

Definition at line 389 of file DB_active_rec.php.

References _where().

Referenced by orwhere().

00390         {
00391                 return $this->_where($key, $value, 'OR ', $escape);
00392         }

Here is the call graph for this function:

Here is the caller graph for this function:

CI_DB_active_record::or_where_in ( key = NULL,
values = NULL 
)

Where_in_or.

Generates a WHERE field IN ('item', 'item') SQL query joined with OR if appropriate

public

Parameters:
string The field to search
array The values searched on
Returns:
object

Definition at line 509 of file DB_active_rec.php.

References _where_in().

00510         {
00511                 return $this->_where_in($key, $values, FALSE, 'OR ');
00512         }

Here is the call graph for this function:

CI_DB_active_record::or_where_not_in ( key = NULL,
values = NULL 
)

Where_not_in_or.

Generates a WHERE field NOT IN ('item', 'item') SQL query joined with OR if appropriate

public

Parameters:
string The field to search
array The values searched on
Returns:
object

Definition at line 545 of file DB_active_rec.php.

References _where_in().

00546         {
00547                 return $this->_where_in($key, $values, TRUE, 'OR ');
00548         }

Here is the call graph for this function:

CI_DB_active_record::order_by ( orderby,
direction = '' 
)

Sets the ORDER BY value.

public

Parameters:
string 
string direction: asc or desc
Returns:
object

Definition at line 878 of file DB_active_rec.php.

Referenced by orderby().

00879         {
00880                 if (strtolower($direction) == 'random')
00881                 {
00882                         $orderby = ''; // Random results want or don't need a field name
00883                         $direction = $this->_random_keyword;
00884                 }
00885                 elseif (trim($direction) != '')
00886                 {
00887                         $direction = (in_array(strtoupper(trim($direction)), array('ASC', 'DESC'), TRUE)) ? ' '.$direction : ' ASC';
00888                 }
00889                 
00890                 $orderby_statement = $this->_protect_identifiers($orderby, TRUE).$direction;
00891                 
00892                 $this->ar_orderby[] = $orderby_statement;
00893                 if ($this->ar_caching === TRUE)
00894                 {
00895                         $this->ar_cache_orderby[] = $orderby_statement;
00896                 }
00897 
00898                 return $this;
00899         }

Here is the caller graph for this function:

CI_DB_active_record::orderby ( orderby,
direction = '' 
)

orderby() is an alias of order_by() this function is here for backwards compatibility, as orderby() has been deprecated

Definition at line 908 of file DB_active_rec.php.

References order_by().

00909         {
00910                 return $this->order_by($orderby, $direction);
00911         }

Here is the call graph for this function:

CI_DB_active_record::orhaving ( key,
value = '',
escape = TRUE 
)

orhaving() is an alias of or_having() this function is here for backwards compatibility, as orhaving() has been deprecated

Definition at line 798 of file DB_active_rec.php.

References or_having().

00799         {
00800                 return $this->or_having($key, $value, $escape);
00801         }       

Here is the call graph for this function:

CI_DB_active_record::orlike ( field,
match = '',
side = 'both' 
)

orlike() is an alias of or_like() this function is here for backwards compatibility, as orlike() has been deprecated

Definition at line 672 of file DB_active_rec.php.

References or_like().

00673         {
00674                 return $this->or_like($field, $match, $side);
00675         }

Here is the call graph for this function:

CI_DB_active_record::orwhere ( key,
value = NULL,
escape = TRUE 
)

orwhere() is an alias of or_where() this function is here for backwards compatibility, as orwhere() has been deprecated

Definition at line 401 of file DB_active_rec.php.

References or_where().

00402         {
00403                 return $this->or_where($key, $value, $escape);
00404         }

Here is the call graph for this function:

CI_DB_active_record::select ( select = '*',
protect_identifiers = TRUE 
)

Select.

Generates the SELECT portion of the query

public

Parameters:
string 
Returns:
object

Definition at line 94 of file DB_active_rec.php.

References dbprefix().

00095         {
00096                 if (is_string($select))
00097                 {
00098                         if ($protect_identifiers !== FALSE)
00099                         {
00100                                 $select = explode(',', $select);
00101                         }
00102                         else
00103                         {
00104                                 $select = array($select);
00105                         }
00106                 }
00107 
00108                 foreach ($select as $val)
00109                 {
00110                         $val = trim($val);
00111 
00112                         if ($val != '*' && $protect_identifiers !== FALSE)
00113                         {
00114                                 if (strpos($val, '.') !== FALSE)
00115                                 {
00116                                         $val = $this->dbprefix.$val;
00117                                 }
00118                                 else
00119                                 {
00120                                         $val = $this->_protect_identifiers($val);
00121                                 }
00122                         }
00123 
00124                         if ($val != '')
00125                         {
00126                                 $this->ar_select[] = $val;
00127                                 if ($this->ar_caching === TRUE)
00128                                 {
00129                                         $this->ar_cache_select[] = $val;
00130                                 }
00131                         }
00132                 }
00133                 return $this;
00134         }

Here is the call graph for this function:

CI_DB_active_record::select_avg ( select = '',
alias = '' 
)

Select Average.

Generates a SELECT AVG(field) portion of a query

public

Parameters:
string the field
string an alias
Returns:
object

Definition at line 212 of file DB_active_rec.php.

References CI_DB_driver::display_error().

00213         {
00214                 if ( ! is_string($select) OR $select == '')
00215                 {
00216                         $this->display_error('db_invalid_query');
00217                 }
00218 
00219                 $alias = ($alias != '') ? $alias : $select;
00220 
00221                 $sql = 'AVG('.$this->_protect_identifiers(trim($select)).') AS '.$this->_protect_identifiers(trim($alias));
00222 
00223                 $this->ar_select[] = $sql;
00224                 if ($this->ar_caching === TRUE)
00225                 {
00226                         $this->ar_cache_select[] = $sql;
00227                 }
00228 
00229                 return $this;
00230         }

Here is the call graph for this function:

CI_DB_active_record::select_max ( select = '',
alias = '' 
)

Select Max.

Generates a SELECT MAX(field) portion of a query

public

Parameters:
string the field
string an alias
Returns:
object

Definition at line 148 of file DB_active_rec.php.

References CI_DB_driver::display_error().

00149         {
00150                 if ( ! is_string($select) OR $select == '')
00151                 {
00152                         $this->display_error('db_invalid_query');
00153                 }
00154         
00155                 $alias = ($alias != '') ? $alias : $select;
00156         
00157                 $sql = 'MAX('.$this->_protect_identifiers(trim($select)).') AS '.$this->_protect_identifiers(trim($alias));
00158 
00159                 $this->ar_select[] = $sql;
00160                 if ($this->ar_caching === TRUE)
00161                 {
00162                         $this->ar_cache_select[] = $sql;
00163                 }
00164                 
00165                 return $this;
00166         }

Here is the call graph for this function:

CI_DB_active_record::select_min ( select = '',
alias = '' 
)

Select Min.

Generates a SELECT MIN(field) portion of a query

public

Parameters:
string the field
string an alias
Returns:
object

Definition at line 180 of file DB_active_rec.php.

References CI_DB_driver::display_error().

00181         {
00182                 if ( ! is_string($select) OR $select == '')
00183                 {
00184                         $this->display_error('db_invalid_query');
00185                 }
00186 
00187                 $alias = ($alias != '') ? $alias : $select;
00188         
00189                 $sql = 'MIN('.$this->_protect_identifiers(trim($select)).') AS '.$this->_protect_identifiers(trim($alias));
00190 
00191                 $this->ar_select[] = $sql;
00192                 if ($this->ar_caching === TRUE)
00193                 {
00194                         $this->ar_cache_select[] = $sql;
00195                 }
00196 
00197                 return $this;
00198         }

Here is the call graph for this function:

CI_DB_active_record::select_sum ( select = '',
alias = '' 
)

Select Sum.

Generates a SELECT SUM(field) portion of a query

public

Parameters:
string the field
string an alias
Returns:
object

Definition at line 244 of file DB_active_rec.php.

References CI_DB_driver::display_error().

00245         {
00246                 if ( ! is_string($select) OR $select == '')
00247                 {
00248                         $this->display_error('db_invalid_query');
00249                 }
00250 
00251                 $alias = ($alias != '') ? $alias : $select;
00252         
00253                 $sql = 'SUM('.$this->_protect_identifiers(trim($select)).') AS '.$this->_protect_identifiers(trim($alias));
00254 
00255                 $this->ar_select[] = $sql;
00256                 if ($this->ar_caching === TRUE)
00257                 {
00258                         $this->ar_cache_select[] = $sql;
00259                 }
00260 
00261                 return $this;
00262         }

Here is the call graph for this function:

CI_DB_active_record::set ( key,
value = '',
escape = TRUE 
)

The "set" function.

Allows key/value pairs to be set for inserting or updating

public

Parameters:
mixed 
string 
boolean 
Returns:
object

Definition at line 974 of file DB_active_rec.php.

References _object_to_array(), and CI_DB_driver::escape().

00975         {
00976                 $key = $this->_object_to_array($key);
00977         
00978                 if ( ! is_array($key))
00979                 {
00980                         $key = array($key => $value);
00981                 }       
00982 
00983                 foreach ($key as $k => $v)
00984                 {
00985                         if ($escape === FALSE)
00986                         {
00987                                 $this->ar_set[$this->_protect_identifiers($k)] = $v;
00988                                 if ($this->ar_caching === TRUE)
00989                                 {
00990                                         $this->ar_cache_offset[$this->_protect_identifiers($k)] = $v;
00991                                 }
00992                         }
00993                         else
00994                         {
00995                                 $this->ar_set[$this->_protect_identifiers($k)] = $this->escape($v);
00996                                 if ($this->ar_caching === TRUE)
00997                                 {
00998                                         $this->ar_cache_offset[$this->_protect_identifiers($k)] = $this->escape($v);
00999                                 }
01000                         }
01001                 }
01002                 
01003                 return $this;
01004         }

Here is the call graph for this function:

CI_DB_active_record::start_cache (  ) 

Start Cache.

Starts AR caching

public

Returns:
void

Definition at line 1592 of file DB_active_rec.php.

01593         {
01594                 $this->ar_caching = TRUE;
01595         }

CI_DB_active_record::stop_cache (  ) 

Stop Cache.

Stops AR caching

public

Returns:
void

Definition at line 1607 of file DB_active_rec.php.

01608         {
01609                 $this->ar_caching = FALSE;
01610         }

CI_DB_active_record::truncate ( table = ''  ) 

Truncate.

Compiles a truncate string and runs the query If the database does not support the truncate() command This function maps to "DELETE FROM table"

public

Parameters:
string the table to truncate
Returns:
object

Definition at line 1281 of file DB_active_rec.php.

References _reset_write(), dbprefix(), CI_DB_driver::display_error(), and CI_DB_driver::query().

01282         {
01283                 if ($table == '')
01284                 {
01285                         if ( ! isset($this->ar_from[0]))
01286                         {
01287                                 if ($this->db_debug)
01288                                 {
01289                                         return $this->display_error('db_must_set_table');
01290                                 }
01291                                 return FALSE;
01292                         }
01293 
01294                         $table = $this->ar_from[0];
01295                 }
01296                 else
01297                 {
01298                         $table = $this->_protect_identifiers($this->dbprefix.$table);
01299                 }
01300 
01301 
01302                 $sql = $this->_truncate($table);
01303 
01304                 $this->_reset_write();
01305                 
01306                 return $this->query($sql);
01307         }

Here is the call graph for this function:

CI_DB_active_record::update ( table = '',
set = NULL,
where = NULL,
limit = NULL 
)

Update.

Compiles an update string and runs the query

public

Parameters:
string the table to retrieve the results from
array an associative array of update values
mixed the where clause
Returns:
object

Definition at line 1183 of file DB_active_rec.php.

References _reset_write(), dbprefix(), CI_DB_driver::display_error(), limit(), CI_DB_driver::query(), and where().

01184         {
01185                 if ( ! is_null($set))
01186                 {
01187                         $this->set($set);
01188                 }
01189         
01190                 if (count($this->ar_set) == 0)
01191                 {
01192                         if ($this->db_debug)
01193                         {
01194                                 return $this->display_error('db_must_use_set');
01195                         }
01196                         return FALSE;
01197                 }
01198 
01199                 if ($table == '')
01200                 {
01201                         if ( ! isset($this->ar_from[0]))
01202                         {
01203                                 if ($this->db_debug)
01204                                 {
01205                                         return $this->display_error('db_must_set_table');
01206                                 }
01207                                 return FALSE;
01208                         }
01209                         
01210                         $table = $this->ar_from[0];
01211                 }
01212                 
01213                 if ($where != NULL)
01214                 {
01215                         $this->where($where);
01216                 }
01217 
01218                 if ($limit != NULL)
01219                 {
01220                         $this->limit($limit);
01221                 }
01222                 
01223                 $sql = $this->_update($this->_protect_identifiers($this->dbprefix.$table), $this->ar_set, $this->ar_where, $this->ar_orderby, $this->ar_limit);
01224                 
01225                 $this->_reset_write();
01226                 return $this->query($sql);
01227         }

Here is the call graph for this function:

CI_DB_active_record::use_table ( table  ) 

Use Table - DEPRECATED.

Deprecated:
use $this->db->from instead

Definition at line 1390 of file DB_active_rec.php.

References from().

01391         {
01392                 return $this->from($table);
01393         }

Here is the call graph for this function:

CI_DB_active_record::where ( key,
value = NULL,
escape = TRUE 
)

Where.

Generates the WHERE portion of the query. Separates multiple calls with AND

public

Parameters:
mixed 
mixed 
Returns:
object

Definition at line 371 of file DB_active_rec.php.

References _where().

Referenced by delete(), get_where(), and update().

00372         {
00373                 return $this->_where($key, $value, 'AND ', $escape);
00374         }

Here is the call graph for this function:

Here is the caller graph for this function:

CI_DB_active_record::where_in ( key = NULL,
values = NULL 
)

Where_in.

Generates a WHERE field IN ('item', 'item') SQL query joined with AND if appropriate

public

Parameters:
string The field to search
array The values searched on
Returns:
object

Definition at line 491 of file DB_active_rec.php.

References _where_in().

00492         {               
00493                 return $this->_where_in($key, $values);
00494         }

Here is the call graph for this function:

CI_DB_active_record::where_not_in ( key = NULL,
values = NULL 
)

Where_not_in.

Generates a WHERE field NOT IN ('item', 'item') SQL query joined with AND if appropriate

public

Parameters:
string The field to search
array The values searched on
Returns:
object

Definition at line 527 of file DB_active_rec.php.

References _where_in().

00528         {
00529                 return $this->_where_in($key, $values, TRUE);
00530         }

Here is the call graph for this function:


Member Data Documentation

CI_DB_active_record::$ar_aliased_tables = array()

Definition at line 45 of file DB_active_rec.php.

CI_DB_active_record::$ar_cache_from = array()

Definition at line 51 of file DB_active_rec.php.

CI_DB_active_record::$ar_cache_groupby = array()

Definition at line 55 of file DB_active_rec.php.

CI_DB_active_record::$ar_cache_having = array()

Definition at line 56 of file DB_active_rec.php.

CI_DB_active_record::$ar_cache_join = array()

Definition at line 52 of file DB_active_rec.php.

CI_DB_active_record::$ar_cache_like = array()

Definition at line 54 of file DB_active_rec.php.

CI_DB_active_record::$ar_cache_limit = FALSE

Definition at line 57 of file DB_active_rec.php.

CI_DB_active_record::$ar_cache_offset = FALSE

Definition at line 58 of file DB_active_rec.php.

CI_DB_active_record::$ar_cache_order = FALSE

Definition at line 59 of file DB_active_rec.php.

CI_DB_active_record::$ar_cache_orderby = array()

Definition at line 60 of file DB_active_rec.php.

CI_DB_active_record::$ar_cache_select = array()

Definition at line 50 of file DB_active_rec.php.

CI_DB_active_record::$ar_cache_set = array()

Definition at line 61 of file DB_active_rec.php.

CI_DB_active_record::$ar_cache_where = array()

Definition at line 53 of file DB_active_rec.php.

CI_DB_active_record::$ar_caching = FALSE

Definition at line 49 of file DB_active_rec.php.

CI_DB_active_record::$ar_distinct = FALSE

Definition at line 32 of file DB_active_rec.php.

CI_DB_active_record::$ar_from = array()

Definition at line 33 of file DB_active_rec.php.

CI_DB_active_record::$ar_groupby = array()

Definition at line 37 of file DB_active_rec.php.

CI_DB_active_record::$ar_having = array()

Definition at line 38 of file DB_active_rec.php.

CI_DB_active_record::$ar_join = array()

Definition at line 34 of file DB_active_rec.php.

CI_DB_active_record::$ar_like = array()

Definition at line 36 of file DB_active_rec.php.

CI_DB_active_record::$ar_limit = FALSE

Definition at line 39 of file DB_active_rec.php.

CI_DB_active_record::$ar_offset = FALSE

Definition at line 40 of file DB_active_rec.php.

CI_DB_active_record::$ar_order = FALSE

Definition at line 41 of file DB_active_rec.php.

CI_DB_active_record::$ar_orderby = array()

Definition at line 42 of file DB_active_rec.php.

CI_DB_active_record::$ar_select = array()

Definition at line 31 of file DB_active_rec.php.

CI_DB_active_record::$ar_set = array()

Definition at line 43 of file DB_active_rec.php.

CI_DB_active_record::$ar_store_array = array()

Definition at line 46 of file DB_active_rec.php.

CI_DB_active_record::$ar_where = array()

Definition at line 35 of file DB_active_rec.php.

CI_DB_active_record::$ar_wherein = array()

Definition at line 44 of file DB_active_rec.php.


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