DB_active_rec.php

Go to the documentation of this file.
00001 <?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
00002 /**
00003  * CodeIgniter
00004  *
00005  * An open source application development framework for PHP 4.3.2 or newer
00006  *
00007  * @package             CodeIgniter
00008  * @author              ExpressionEngine Dev Team
00009  * @copyright   Copyright (c) 2008, EllisLab, Inc.
00010  * @license             http://codeigniter.com/user_guide/license.html
00011  * @link                http://codeigniter.com
00012  * @since               Version 1.0
00013  * @filesource
00014  */
00015 
00016 // ------------------------------------------------------------------------
00017 
00018 /**
00019  * Active Record Class
00020  *
00021  * This is the platform-independent base Active Record implementation class.
00022  *
00023  * @package             CodeIgniter
00024  * @subpackage  Drivers
00025  * @category    Database
00026  * @author              ExpressionEngine Dev Team
00027  * @link                http://codeigniter.com/user_guide/database/
00028  */
00029 class CI_DB_active_record extends CI_DB_driver {
00030 
00031         var $ar_select                          = array();
00032         var $ar_distinct                        = FALSE;
00033         var $ar_from                            = array();
00034         var $ar_join                            = array();
00035         var $ar_where                           = array();
00036         var $ar_like                            = array();
00037         var $ar_groupby                         = array();
00038         var $ar_having                          = array();
00039         var $ar_limit                           = FALSE;
00040         var $ar_offset                          = FALSE;
00041         var $ar_order                           = FALSE;
00042         var $ar_orderby                         = array();
00043         var $ar_set                                     = array();      
00044         var $ar_wherein                         = array();
00045         var $ar_aliased_tables          = array();
00046         var $ar_store_array                     = array();
00047         
00048         // Active Record Caching variables
00049         var $ar_caching                         = FALSE;
00050         var $ar_cache_exists            = array();
00051         var $ar_cache_select            = array();
00052         var $ar_cache_from                      = array();
00053         var $ar_cache_join                      = array();
00054         var $ar_cache_where                     = array();
00055         var $ar_cache_like                      = array();
00056         var $ar_cache_groupby           = array();
00057         var $ar_cache_having            = array();
00058         var $ar_cache_orderby           = array();
00059         var $ar_cache_set                       = array();      
00060 
00061 
00062         // --------------------------------------------------------------------
00063 
00064         /**
00065          * Select
00066          *
00067          * Generates the SELECT portion of the query
00068          *
00069          * @access      public
00070          * @param       string
00071          * @return      object
00072          */
00073         function select($select = '*', $escape = NULL)
00074         {
00075                 // Set the global value if this was sepecified  
00076                 if (is_bool($escape))
00077                 {
00078                         $this->_protect_identifiers = $escape;
00079                 }
00080                 
00081                 if (is_string($select))
00082                 {
00083                         $select = explode(',', $select);
00084                 }
00085 
00086                 foreach ($select as $val)
00087                 {
00088                         $val = trim($val);
00089 
00090                         if ($val != '')
00091                         {
00092                                 $this->ar_select[] = $val;
00093 
00094                                 if ($this->ar_caching === TRUE)
00095                                 {
00096                                         $this->ar_cache_select[] = $val;
00097                                         $this->ar_cache_exists[] = 'select';
00098                                 }
00099                         }
00100                 }
00101                 return $this;
00102         }
00103 
00104         // --------------------------------------------------------------------
00105 
00106         /**
00107          * Select Max
00108          *
00109          * Generates a SELECT MAX(field) portion of a query
00110          *
00111          * @access      public
00112          * @param       string  the field
00113          * @param       string  an alias
00114          * @return      object
00115          */
00116         function select_max($select = '', $alias = '')
00117         {
00118                 return $this->_max_min_avg_sum($select, $alias, 'MAX');
00119         }
00120                 
00121         // --------------------------------------------------------------------
00122 
00123         /**
00124          * Select Min
00125          *
00126          * Generates a SELECT MIN(field) portion of a query
00127          *
00128          * @access      public
00129          * @param       string  the field
00130          * @param       string  an alias
00131          * @return      object
00132          */
00133         function select_min($select = '', $alias = '')
00134         {
00135                 return $this->_max_min_avg_sum($select, $alias, 'MIN');
00136         }
00137 
00138         // --------------------------------------------------------------------
00139 
00140         /**
00141          * Select Average
00142          *
00143          * Generates a SELECT AVG(field) portion of a query
00144          *
00145          * @access      public
00146          * @param       string  the field
00147          * @param       string  an alias
00148          * @return      object
00149          */
00150         function select_avg($select = '', $alias = '')
00151         {
00152                 return $this->_max_min_avg_sum($select, $alias, 'AVG');
00153         }
00154 
00155         // --------------------------------------------------------------------
00156 
00157         /**
00158          * Select Sum
00159          *
00160          * Generates a SELECT SUM(field) portion of a query
00161          *
00162          * @access      public
00163          * @param       string  the field
00164          * @param       string  an alias
00165          * @return      object
00166          */
00167         function select_sum($select = '', $alias = '')
00168         {
00169                 return $this->_max_min_avg_sum($select, $alias, 'SUM');
00170         }
00171 
00172         // --------------------------------------------------------------------
00173 
00174         /**
00175          * Processing Function for the four functions above:
00176          *
00177          *      select_max()
00178          *      select_min()
00179          *      select_avg()
00180          *  select_sum()
00181          *      
00182          * @access      public
00183          * @param       string  the field
00184          * @param       string  an alias
00185          * @return      object
00186          */
00187         function _max_min_avg_sum($select = '', $alias = '', $type = 'MAX')
00188         {
00189                 if ( ! is_string($select) OR $select == '')
00190                 {
00191                         $this->display_error('db_invalid_query');
00192                 }
00193         
00194                 $type = strtoupper($type);
00195         
00196                 if ( ! in_array($type, array('MAX', 'MIN', 'AVG', 'SUM')))
00197                 {
00198                         show_error('Invalid function type: '.$type);
00199                 }
00200         
00201                 if ($alias == '')
00202                 {
00203                         $alias = $this->_create_alias_from_table(trim($select));
00204                 }
00205         
00206                 $sql = $type.'('.$this->_protect_identifiers(trim($select)).') AS '.$alias;
00207 
00208                 $this->ar_select[] = $sql;
00209                 
00210                 if ($this->ar_caching === TRUE)
00211                 {
00212                         $this->ar_cache_select[] = $sql;
00213                         $this->ar_cache_exists[] = 'select';
00214                 }
00215                 
00216                 return $this;
00217         }
00218 
00219         // --------------------------------------------------------------------
00220 
00221         /**
00222          * Determines the alias name based on the table
00223          *
00224          * @access      private
00225          * @param       string
00226          * @return      string
00227          */
00228         function _create_alias_from_table($item)
00229         {
00230                 if (strpos($item, '.') !== FALSE)
00231                 {
00232                         return end(explode('.', $item));
00233                 }
00234                 
00235                 return $item;
00236         }
00237 
00238         // --------------------------------------------------------------------
00239 
00240         /**
00241          * DISTINCT
00242          *
00243          * Sets a flag which tells the query string compiler to add DISTINCT
00244          *
00245          * @access      public
00246          * @param       bool
00247          * @return      object
00248          */
00249         function distinct($val = TRUE)
00250         {
00251                 $this->ar_distinct = (is_bool($val)) ? $val : TRUE;
00252                 return $this;
00253         }
00254         
00255         // --------------------------------------------------------------------
00256 
00257         /**
00258          * From
00259          *
00260          * Generates the FROM portion of the query
00261          *
00262          * @access      public
00263          * @param       mixed   can be a string or array
00264          * @return      object
00265          */
00266         function from($from)
00267         {
00268                 foreach ((array)$from as $val)
00269                 {
00270                         // Extract any aliases that might exist.  We use this information
00271                         // in the _protect_identifiers to know whether to add a table prefix 
00272                         $this->_track_aliases($val);
00273 
00274                         $this->ar_from[] = $this->_protect_identifiers($val, TRUE, NULL, FALSE);
00275                         
00276                         if ($this->ar_caching === TRUE)
00277                         {
00278                                 $this->ar_cache_from[] = $this->_protect_identifiers($val, TRUE, NULL, FALSE);
00279                                 $this->ar_cache_exists[] = 'from';
00280                         }
00281                 }
00282 
00283                 return $this;
00284         }
00285 
00286         // --------------------------------------------------------------------
00287 
00288         /**
00289          * Join
00290          *
00291          * Generates the JOIN portion of the query
00292          *
00293          * @access      public
00294          * @param       string
00295          * @param       string  the join condition
00296          * @param       string  the type of join
00297          * @return      object
00298          */
00299         function join($table, $cond, $type = '')
00300         {               
00301                 if ($type != '')
00302                 {
00303                         $type = strtoupper(trim($type));
00304 
00305                         if ( ! in_array($type, array('LEFT', 'RIGHT', 'OUTER', 'INNER', 'LEFT OUTER', 'RIGHT OUTER')))
00306                         {
00307                                 $type = '';
00308                         }
00309                         else
00310                         {
00311                                 $type .= ' ';
00312                         }
00313                 }
00314 
00315                 // Extract any aliases that might exist.  We use this information
00316                 // in the _protect_identifiers to know whether to add a table prefix 
00317                 $this->_track_aliases($table);
00318 
00319                 // Strip apart the condition and protect the identifiers
00320                 if (preg_match('/([\w\.]+)([\W\s]+)(.+)/', $cond, $match))
00321                 {
00322                         $match[1] = $this->_protect_identifiers($match[1]);
00323                         $match[3] = $this->_protect_identifiers($match[3]);
00324                 
00325                         $cond = $match[1].$match[2].$match[3];          
00326                 }
00327                 
00328                 // Assemble the JOIN statement
00329                 $join = $type.'JOIN '.$this->_protect_identifiers($table, TRUE, NULL, FALSE).' ON '.$cond;
00330 
00331                 $this->ar_join[] = $join;
00332                 if ($this->ar_caching === TRUE)
00333                 {
00334                         $this->ar_cache_join[] = $join;
00335                         $this->ar_cache_exists[] = 'join';
00336                 }
00337 
00338                 return $this;
00339         }
00340 
00341         // --------------------------------------------------------------------
00342 
00343         /**
00344          * Where
00345          *
00346          * Generates the WHERE portion of the query. Separates
00347          * multiple calls with AND
00348          *
00349          * @access      public
00350          * @param       mixed
00351          * @param       mixed
00352          * @return      object
00353          */
00354         function where($key, $value = NULL, $escape = TRUE)
00355         {
00356                 return $this->_where($key, $value, 'AND ', $escape);
00357         }
00358         
00359         // --------------------------------------------------------------------
00360 
00361         /**
00362          * OR Where
00363          *
00364          * Generates the WHERE portion of the query. Separates
00365          * multiple calls with OR
00366          *
00367          * @access      public
00368          * @param       mixed
00369          * @param       mixed
00370          * @return      object
00371          */
00372         function or_where($key, $value = NULL, $escape = TRUE)
00373         {
00374                 return $this->_where($key, $value, 'OR ', $escape);
00375         }
00376 
00377         // --------------------------------------------------------------------
00378 
00379         /**
00380          * orwhere() is an alias of or_where()
00381          * this function is here for backwards compatibility, as
00382          * orwhere() has been deprecated
00383          */
00384         function orwhere($key, $value = NULL, $escape = TRUE)
00385         {
00386                 return $this->or_where($key, $value, $escape);
00387         }
00388 
00389         // --------------------------------------------------------------------
00390 
00391         /**
00392          * Where
00393          *
00394          * Called by where() or orwhere()
00395          *
00396          * @access      private
00397          * @param       mixed
00398          * @param       mixed
00399          * @param       string
00400          * @return      object
00401          */
00402         function _where($key, $value = NULL, $type = 'AND ', $escape = NULL)
00403         {
00404                 if ( ! is_array($key))
00405                 {
00406                         $key = array($key => $value);
00407                 }
00408                 
00409                 // If the escape value was not set will will base it on the global setting
00410                 if ( ! is_bool($escape))
00411                 {
00412                         $escape = $this->_protect_identifiers;
00413                 }
00414 
00415                 foreach ($key as $k => $v)
00416                 {
00417                         $prefix = (count($this->ar_where) == 0 AND count($this->ar_cache_where) == 0) ? '' : $type;
00418 
00419                         if (is_null($v) && ! $this->_has_operator($k))
00420                         {
00421                                 // value appears not to have been set, assign the test to IS NULL
00422                                 $k .= ' IS NULL';
00423                         }
00424                         
00425                         if ( ! is_null($v))
00426                         {
00427                                 if ($escape === TRUE)
00428                                 {
00429                                         $k = $this->_protect_identifiers($k, FALSE, $escape);
00430                                         
00431                                         $v = ' '.$this->escape($v);
00432                                 }
00433 
00434                                 if ( ! $this->_has_operator($k))
00435                                 {
00436                                         $k .= ' =';
00437                                 }
00438                         }
00439                         else
00440                         {
00441                                 $k = $this->_protect_identifiers($k, FALSE, $escape);                   
00442                         }
00443 
00444                         $this->ar_where[] = $prefix.$k.$v;
00445                         
00446                         if ($this->ar_caching === TRUE)
00447                         {
00448                                 $this->ar_cache_where[] = $prefix.$k.$v;
00449                                 $this->ar_cache_exists[] = 'where';
00450                         }
00451                         
00452                 }
00453                 
00454                 return $this;
00455         }
00456 
00457         // --------------------------------------------------------------------
00458 
00459         /**
00460          * Where_in
00461          *
00462          * Generates a WHERE field IN ('item', 'item') SQL query joined with
00463          * AND if appropriate
00464          *
00465          * @access      public
00466          * @param       string  The field to search
00467          * @param       array   The values searched on
00468          * @return      object
00469          */
00470         function where_in($key = NULL, $values = NULL)
00471         {
00472                 return $this->_where_in($key, $values);
00473         }
00474         
00475         // --------------------------------------------------------------------
00476 
00477         /**
00478          * Where_in_or
00479          *
00480          * Generates a WHERE field IN ('item', 'item') SQL query joined with
00481          * OR if appropriate
00482          *
00483          * @access      public
00484          * @param       string  The field to search
00485          * @param       array   The values searched on
00486          * @return      object
00487          */
00488         function or_where_in($key = NULL, $values = NULL)
00489         {
00490                 return $this->_where_in($key, $values, FALSE, 'OR ');
00491         }
00492 
00493         // --------------------------------------------------------------------
00494 
00495         /**
00496          * Where_not_in
00497          *
00498          * Generates a WHERE field NOT IN ('item', 'item') SQL query joined
00499          * with AND if appropriate
00500          *
00501          * @access      public
00502          * @param       string  The field to search
00503          * @param       array   The values searched on
00504          * @return      object
00505          */
00506         function where_not_in($key = NULL, $values = NULL)
00507         {
00508                 return $this->_where_in($key, $values, TRUE);
00509         }
00510         
00511         // --------------------------------------------------------------------
00512 
00513         /**
00514          * Where_not_in_or
00515          *
00516          * Generates a WHERE field NOT IN ('item', 'item') SQL query joined
00517          * with OR if appropriate
00518          *
00519          * @access      public
00520          * @param       string  The field to search
00521          * @param       array   The values searched on
00522          * @return      object
00523          */
00524         function or_where_not_in($key = NULL, $values = NULL)
00525         {
00526                 return $this->_where_in($key, $values, TRUE, 'OR ');
00527         }
00528 
00529         // --------------------------------------------------------------------
00530 
00531         /**
00532          * Where_in
00533          *
00534          * Called by where_in, where_in_or, where_not_in, where_not_in_or
00535          *
00536          * @access      public
00537          * @param       string  The field to search
00538          * @param       array   The values searched on
00539          * @param       boolean If the statement would be IN or NOT IN
00540          * @param       string  
00541          * @return      object
00542          */
00543         function _where_in($key = NULL, $values = NULL, $not = FALSE, $type = 'AND ')
00544         {
00545                 if ($key === NULL OR $values === NULL)
00546                 {
00547                         return;
00548                 }
00549                 
00550                 if ( ! is_array($values))
00551                 {
00552                         $values = array($values);
00553                 }
00554                 
00555                 $not = ($not) ? ' NOT' : '';
00556 
00557                 foreach ($values as $value)
00558                 {
00559                         $this->ar_wherein[] = $this->escape($value);
00560                 }
00561 
00562                 $prefix = (count($this->ar_where) == 0) ? '' : $type;
00563  
00564                 $where_in = $prefix . $this->_protect_identifiers($key) . $not . " IN (" . implode(", ", $this->ar_wherein) . ") ";
00565 
00566                 $this->ar_where[] = $where_in;
00567                 if ($this->ar_caching === TRUE)
00568                 {
00569                         $this->ar_cache_where[] = $where_in;
00570                         $this->ar_cache_exists[] = 'where';
00571                 }
00572 
00573                 // reset the array for multiple calls
00574                 $this->ar_wherein = array();
00575                 return $this;
00576         }
00577                 
00578         // --------------------------------------------------------------------
00579 
00580         /**
00581          * Like
00582          *
00583          * Generates a %LIKE% portion of the query. Separates
00584          * multiple calls with AND
00585          *
00586          * @access      public
00587          * @param       mixed
00588          * @param       mixed
00589          * @return      object
00590          */
00591         function like($field, $match = '', $side = 'both')
00592         {
00593                 return $this->_like($field, $match, 'AND ', $side);
00594         }
00595 
00596         // --------------------------------------------------------------------
00597 
00598         /**
00599          * Not Like
00600          *
00601          * Generates a NOT LIKE portion of the query. Separates
00602          * multiple calls with AND
00603          *
00604          * @access      public
00605          * @param       mixed
00606          * @param       mixed
00607          * @return      object
00608          */
00609         function not_like($field, $match = '', $side = 'both')
00610         {
00611                 return $this->_like($field, $match, 'AND ', $side, 'NOT');
00612         }
00613                 
00614         // --------------------------------------------------------------------
00615 
00616         /**
00617          * OR Like
00618          *
00619          * Generates a %LIKE% portion of the query. Separates
00620          * multiple calls with OR
00621          *
00622          * @access      public
00623          * @param       mixed
00624          * @param       mixed
00625          * @return      object
00626          */
00627         function or_like($field, $match = '', $side = 'both')
00628         {
00629                 return $this->_like($field, $match, 'OR ', $side);
00630         }
00631 
00632         // --------------------------------------------------------------------
00633 
00634         /**
00635          * OR Not Like
00636          *
00637          * Generates a NOT LIKE portion of the query. Separates
00638          * multiple calls with OR
00639          *
00640          * @access      public
00641          * @param       mixed
00642          * @param       mixed
00643          * @return      object
00644          */
00645         function or_not_like($field, $match = '', $side = 'both')
00646         {
00647                 return $this->_like($field, $match, 'OR ', $side, 'NOT');
00648         }
00649         
00650         // --------------------------------------------------------------------
00651 
00652         /**
00653          * orlike() is an alias of or_like()
00654          * this function is here for backwards compatibility, as
00655          * orlike() has been deprecated
00656          */
00657         function orlike($field, $match = '', $side = 'both')
00658         {
00659                 return $this->or_like($field, $match, $side);
00660         }
00661         
00662         // --------------------------------------------------------------------
00663 
00664         /**
00665          * Like
00666          *
00667          * Called by like() or orlike()
00668          *
00669          * @access      private
00670          * @param       mixed
00671          * @param       mixed
00672          * @param       string
00673          * @return      object
00674          */
00675         function _like($field, $match = '', $type = 'AND ', $side = 'both', $not = '')
00676         {
00677                 if ( ! is_array($field))
00678                 {
00679                         $field = array($field => $match);
00680                 }
00681         
00682                 foreach ($field as $k => $v)
00683                 {
00684                         $k = $this->_protect_identifiers($k);
00685 
00686                         $prefix = (count($this->ar_like) == 0) ? '' : $type;
00687 
00688                         $v = $this->escape_str($v);
00689 
00690                         if ($side == 'before')
00691                         {
00692                                 $like_statement = $prefix." $k $not LIKE '%{$v}'";
00693                         }
00694                         elseif ($side == 'after')
00695                         {
00696                                 $like_statement = $prefix." $k $not LIKE '{$v}%'";
00697                         }
00698                         else
00699                         {
00700                                 $like_statement = $prefix." $k $not LIKE '%{$v}%'";
00701                         }
00702                         
00703                         $this->ar_like[] = $like_statement;
00704                         if ($this->ar_caching === TRUE)
00705                         {
00706                                 $this->ar_cache_like[] = $like_statement;
00707                                 $this->ar_cache_exists[] = 'like';
00708                         }
00709                         
00710                 }
00711                 return $this;
00712         }
00713         
00714         // --------------------------------------------------------------------
00715 
00716         /**
00717          * GROUP BY
00718          *
00719          * @access      public
00720          * @param       string
00721          * @return      object
00722          */
00723         function group_by($by)
00724         {
00725                 if (is_string($by))
00726                 {
00727                         $by = explode(',', $by);
00728                 }
00729         
00730                 foreach ($by as $val)
00731                 {
00732                         $val = trim($val);
00733                 
00734                         if ($val != '')
00735                         {
00736                                 $this->ar_groupby[] = $this->_protect_identifiers($val);
00737                                 
00738                                 if ($this->ar_caching === TRUE)
00739                                 {
00740                                         $this->ar_cache_groupby[] = $this->_protect_identifiers($val);
00741                                         $this->ar_cache_exists[] = 'groupby';
00742                                 }
00743                         }
00744                 }
00745                 return $this;
00746         }
00747 
00748         // --------------------------------------------------------------------
00749 
00750         /**
00751          * groupby() is an alias of group_by()
00752          * this function is here for backwards compatibility, as
00753          * groupby() has been deprecated
00754          */
00755         function groupby($by)
00756         {
00757                 return $this->group_by($by);
00758         }       
00759 
00760         // --------------------------------------------------------------------
00761 
00762         /**
00763          * Sets the HAVING value
00764          *
00765          * Separates multiple calls with AND
00766          *
00767          * @access      public
00768          * @param       string
00769          * @param       string
00770          * @return      object
00771          */
00772         function having($key, $value = '', $escape = TRUE)
00773         {
00774                 return $this->_having($key, $value, 'AND ', $escape);
00775         }
00776 
00777         // --------------------------------------------------------------------
00778 
00779         /**
00780          * orhaving() is an alias of or_having()
00781          * this function is here for backwards compatibility, as
00782          * orhaving() has been deprecated
00783          */
00784 
00785         function orhaving($key, $value = '', $escape = TRUE)
00786         {
00787                 return $this->or_having($key, $value, $escape);
00788         }       
00789         // --------------------------------------------------------------------
00790 
00791         /**
00792          * Sets the OR HAVING value
00793          *
00794          * Separates multiple calls with OR
00795          *
00796          * @access      public
00797          * @param       string
00798          * @param       string
00799          * @return      object
00800          */
00801         function or_having($key, $value = '', $escape = TRUE)
00802         {
00803                 return $this->_having($key, $value, 'OR ', $escape);
00804         }
00805         
00806         // --------------------------------------------------------------------
00807 
00808         /**
00809          * Sets the HAVING values
00810          *
00811          * Called by having() or or_having()
00812          *
00813          * @access      private
00814          * @param       string
00815          * @param       string
00816          * @return      object
00817          */
00818         function _having($key, $value = '', $type = 'AND ', $escape = TRUE)
00819         {
00820                 if ( ! is_array($key))
00821                 {
00822                         $key = array($key => $value);
00823                 }
00824         
00825                 foreach ($key as $k => $v)
00826                 {
00827                         $prefix = (count($this->ar_having) == 0) ? '' : $type;
00828 
00829                         if ($escape === TRUE)
00830                         {
00831                                 $k = $this->_protect_identifiers($k);
00832                         }
00833 
00834                         if ( ! $this->_has_operator($k))
00835                         {
00836                                 $k .= ' = ';
00837                         }
00838 
00839                         if ($v != '')
00840                         {
00841                                 $v = ' '.$this->escape_str($v);
00842                         }
00843                         
00844                         $this->ar_having[] = $prefix.$k.$v;
00845                         if ($this->ar_caching === TRUE)
00846                         {
00847                                 $this->ar_cache_having[] = $prefix.$k.$v;
00848                                 $this->ar_cache_exists[] = 'having';
00849                         }
00850                 }
00851                 
00852                 return $this;
00853         }
00854         
00855         // --------------------------------------------------------------------
00856 
00857         /**
00858          * Sets the ORDER BY value
00859          *
00860          * @access      public
00861          * @param       string
00862          * @param       string  direction: asc or desc
00863          * @return      object
00864          */
00865         function order_by($orderby, $direction = '')
00866         {
00867                 if (strtolower($direction) == 'random')
00868                 {
00869                         $orderby = ''; // Random results want or don't need a field name
00870                         $direction = $this->_random_keyword;
00871                 }
00872                 elseif (trim($direction) != '')
00873                 {
00874                         $direction = (in_array(strtoupper(trim($direction)), array('ASC', 'DESC'), TRUE)) ? ' '.$direction : ' ASC';
00875                 }
00876                 
00877                 $orderby_statement = $this->_protect_identifiers($orderby).$direction;
00878                 
00879                 $this->ar_orderby[] = $orderby_statement;
00880                 if ($this->ar_caching === TRUE)
00881                 {
00882                         $this->ar_cache_orderby[] = $orderby_statement;
00883                         $this->ar_cache_exists[] = 'orderby';
00884                 }
00885 
00886                 return $this;
00887         }
00888         
00889         // --------------------------------------------------------------------
00890 
00891         /**
00892          * orderby() is an alias of order_by()
00893          * this function is here for backwards compatibility, as
00894          * orderby() has been deprecated
00895          */
00896         function orderby($orderby, $direction = '')
00897         {
00898                 return $this->order_by($orderby, $direction);
00899         }
00900         
00901         // --------------------------------------------------------------------
00902 
00903         /**
00904          * Sets the LIMIT value
00905          *
00906          * @access      public
00907          * @param       integer the limit value
00908          * @param       integer the offset value
00909          * @return      object
00910          */
00911         function limit($value, $offset = '')
00912         {
00913                 $this->ar_limit = $value;
00914 
00915                 if ($offset != '')
00916                 {
00917                         $this->ar_offset = $offset;
00918                 }
00919                 
00920                 return $this;
00921         }
00922         
00923         // --------------------------------------------------------------------
00924 
00925         /**
00926          * Sets the OFFSET value
00927          *
00928          * @access      public
00929          * @param       integer the offset value
00930          * @return      object
00931          */
00932         function offset($offset)
00933         {
00934                 $this->ar_offset = $offset;
00935                 return $this;
00936         }
00937         
00938         // --------------------------------------------------------------------
00939 
00940         /**
00941          * The "set" function.  Allows key/value pairs to be set for inserting or updating
00942          *
00943          * @access      public
00944          * @param       mixed
00945          * @param       string
00946          * @param       boolean
00947          * @return      object
00948          */
00949         function set($key, $value = '', $escape = TRUE)
00950         {
00951                 $key = $this->_object_to_array($key);
00952         
00953                 if ( ! is_array($key))
00954                 {
00955                         $key = array($key => $value);
00956                 }       
00957 
00958                 foreach ($key as $k => $v)
00959                 {
00960                         if ($escape === FALSE)
00961                         {
00962                                 $this->ar_set[$this->_protect_identifiers($k)] = $v;
00963                         }
00964                         else
00965                         {
00966                                 $this->ar_set[$this->_protect_identifiers($k)] = $this->escape($v);
00967                         }
00968                 }
00969                 
00970                 return $this;
00971         }
00972         
00973         // --------------------------------------------------------------------
00974 
00975         /**
00976          * Get
00977          *
00978          * Compiles the select statement based on the other functions called
00979          * and runs the query
00980          *
00981          * @access      public
00982          * @param       string  the table
00983          * @param       string  the limit clause
00984          * @param       string  the offset clause
00985          * @return      object
00986          */
00987         function get($table = '', $limit = null, $offset = null)
00988         {
00989                 if ($table != '')
00990                 {
00991                         $this->_track_aliases($table);
00992                         $this->from($table);
00993                 }
00994                 
00995                 if ( ! is_null($limit))
00996                 {
00997                         $this->limit($limit, $offset);
00998                 }
00999                         
01000                 $sql = $this->_compile_select();
01001 
01002                 $result = $this->query($sql);
01003                 $this->_reset_select();
01004                 return $result;
01005         }
01006 
01007         /**
01008          * "Count All Results" query
01009          *
01010          * Generates a platform-specific query string that counts all records 
01011          * returned by an Active Record query.
01012          *
01013          * @access      public
01014          * @param       string
01015          * @return      string
01016          */
01017         function count_all_results($table = '')
01018         {
01019                 if ($table != '')
01020                 {
01021                         $this->_track_aliases($table);
01022                         $this->from($table);
01023                 }
01024                 
01025                 $sql = $this->_compile_select($this->_count_string . $this->_protect_identifiers('numrows'));
01026 
01027                 $query = $this->query($sql);
01028                 $this->_reset_select();
01029         
01030                 if ($query->num_rows() == 0)
01031                 {
01032                         return '0';
01033                 }
01034 
01035                 $row = $query->row();
01036                 return $row->numrows;
01037         }
01038 
01039         // --------------------------------------------------------------------
01040 
01041         /**
01042          * Get_Where
01043          *
01044          * Allows the where clause, limit and offset to be added directly
01045          *
01046          * @access      public
01047          * @param       string  the where clause
01048          * @param       string  the limit clause
01049          * @param       string  the offset clause
01050          * @return      object
01051          */
01052         function get_where($table = '', $where = null, $limit = null, $offset = null)
01053         {
01054                 if ($table != '')
01055                 {
01056                         $this->from($table);
01057                 }
01058 
01059                 if ( ! is_null($where))
01060                 {
01061                         $this->where($where);
01062                 }
01063                 
01064                 if ( ! is_null($limit))
01065                 {
01066                         $this->limit($limit, $offset);
01067                 }
01068                         
01069                 $sql = $this->_compile_select();
01070 
01071                 $result = $this->query($sql);
01072                 $this->_reset_select();
01073                 return $result;
01074         }
01075 
01076         // --------------------------------------------------------------------
01077 
01078         /**
01079          * getwhere() is an alias of get_where()
01080          * this function is here for backwards compatibility, as
01081          * getwhere() has been deprecated
01082          */
01083         function getwhere($table = '', $where = null, $limit = null, $offset = null)
01084         {
01085                 return $this->get_where($table, $where, $limit, $offset);
01086         }
01087         
01088         // --------------------------------------------------------------------
01089 
01090         /**
01091          * Insert
01092          *
01093          * Compiles an insert string and runs the query
01094          *
01095          * @access      public
01096          * @param       string  the table to retrieve the results from
01097          * @param       array   an associative array of insert values
01098          * @return      object
01099          */
01100         function insert($table = '', $set = NULL)
01101         {       
01102                 if ( ! is_null($set))
01103                 {
01104                         $this->set($set);
01105                 }
01106         
01107                 if (count($this->ar_set) == 0)
01108                 {
01109                         if ($this->db_debug)
01110                         {
01111                                 return $this->display_error('db_must_use_set');
01112                         }
01113                         return FALSE;
01114                 }
01115 
01116                 if ($table == '')
01117                 {
01118                         if ( ! isset($this->ar_from[0]))
01119                         {
01120                                 if ($this->db_debug)
01121                                 {
01122                                         return $this->display_error('db_must_set_table');
01123                                 }
01124                                 return FALSE;
01125                         }
01126                         
01127                         $table = $this->ar_from[0];
01128                 }
01129 
01130                 $sql = $this->_insert($this->_protect_identifiers($table, TRUE, NULL, FALSE), array_keys($this->ar_set), array_values($this->ar_set));
01131                 
01132                 $this->_reset_write();
01133                 return $this->query($sql);              
01134         }
01135         
01136         // --------------------------------------------------------------------
01137 
01138         /**
01139          * Update
01140          *
01141          * Compiles an update string and runs the query
01142          *
01143          * @access      public
01144          * @param       string  the table to retrieve the results from
01145          * @param       array   an associative array of update values
01146          * @param       mixed   the where clause
01147          * @return      object
01148          */
01149         function update($table = '', $set = NULL, $where = NULL, $limit = NULL)
01150         {
01151                 // Combine any cached components with the current statements
01152                 $this->_merge_cache();
01153 
01154                 if ( ! is_null($set))
01155                 {
01156                         $this->set($set);
01157                 }
01158         
01159                 if (count($this->ar_set) == 0)
01160                 {
01161                         if ($this->db_debug)
01162                         {
01163                                 return $this->display_error('db_must_use_set');
01164                         }
01165                         return FALSE;
01166                 }
01167 
01168                 if ($table == '')
01169                 {
01170                         if ( ! isset($this->ar_from[0]))
01171                         {
01172                                 if ($this->db_debug)
01173                                 {
01174                                         return $this->display_error('db_must_set_table');
01175                                 }
01176                                 return FALSE;
01177                         }
01178                         
01179                         $table = $this->ar_from[0];
01180                 }
01181                 
01182                 if ($where != NULL)
01183                 {
01184                         $this->where($where);
01185                 }
01186 
01187                 if ($limit != NULL)
01188                 {
01189                         $this->limit($limit);
01190                 }
01191                 
01192                 $sql = $this->_update($this->_protect_identifiers($table, TRUE, NULL, FALSE), $this->ar_set, $this->ar_where, $this->ar_orderby, $this->ar_limit);
01193                 
01194                 $this->_reset_write();
01195                 return $this->query($sql);
01196         }
01197 
01198         // --------------------------------------------------------------------
01199 
01200         /**
01201          * Empty Table
01202          *
01203          * Compiles a delete string and runs "DELETE FROM table"
01204          *
01205          * @access      public
01206          * @param       string  the table to empty
01207          * @return      object
01208          */
01209         function empty_table($table = '')
01210         {
01211                 if ($table == '')
01212                 {
01213                         if ( ! isset($this->ar_from[0]))
01214                         {
01215                                 if ($this->db_debug)
01216                                 {
01217                                         return $this->display_error('db_must_set_table');
01218                                 }
01219                                 return FALSE;
01220                         }
01221 
01222                         $table = $this->ar_from[0];
01223                 }
01224                 else
01225                 {
01226                         $table = $this->_protect_identifiers($table, TRUE, NULL, FALSE);
01227                 }
01228 
01229                 $sql = $this->_delete($table);
01230 
01231                 $this->_reset_write();
01232                 
01233                 return $this->query($sql);
01234         }
01235 
01236         // --------------------------------------------------------------------
01237 
01238         /**
01239          * Truncate
01240          *
01241          * Compiles a truncate string and runs the query
01242          * If the database does not support the truncate() command
01243          * This function maps to "DELETE FROM table"
01244          *
01245          * @access      public
01246          * @param       string  the table to truncate
01247          * @return      object
01248          */
01249         function truncate($table = '')
01250         {
01251                 if ($table == '')
01252                 {
01253                         if ( ! isset($this->ar_from[0]))
01254                         {
01255                                 if ($this->db_debug)
01256                                 {
01257                                         return $this->display_error('db_must_set_table');
01258                                 }
01259                                 return FALSE;
01260                         }
01261 
01262                         $table = $this->ar_from[0];
01263                 }
01264                 else
01265                 {
01266                         $table = $this->_protect_identifiers($table, TRUE, NULL, FALSE);
01267                 }
01268 
01269                 $sql = $this->_truncate($table);
01270 
01271                 $this->_reset_write();
01272                 
01273                 return $this->query($sql);
01274         }
01275         
01276         // --------------------------------------------------------------------
01277 
01278         /**
01279          * Delete
01280          *
01281          * Compiles a delete string and runs the query
01282          *
01283          * @access      public
01284          * @param       mixed   the table(s) to delete from. String or array
01285          * @param       mixed   the where clause
01286          * @param       mixed   the limit clause
01287          * @param       boolean
01288          * @return      object
01289          */
01290         function delete($table = '', $where = '', $limit = NULL, $reset_data = TRUE)
01291         {
01292                 // Combine any cached components with the current statements
01293                 $this->_merge_cache();
01294 
01295                 if ($table == '')
01296                 {
01297                         if ( ! isset($this->ar_from[0]))
01298                         {
01299                                 if ($this->db_debug)
01300                                 {
01301                                         return $this->display_error('db_must_set_table');
01302                                 }
01303                                 return FALSE;
01304                         }
01305 
01306                         $table = $this->ar_from[0];
01307                 }
01308                 elseif (is_array($table))
01309                 {
01310                         foreach($table as $single_table)
01311                         {
01312                                 $this->delete($single_table, $where, $limit, FALSE);
01313                         }
01314 
01315                         $this->_reset_write();
01316                         return;
01317                 }
01318                 else
01319                 {
01320                         $table = $this->_protect_identifiers($table, TRUE, NULL, FALSE);
01321                 }
01322 
01323                 if ($where != '')
01324                 {
01325                         $this->where($where);
01326                 }
01327 
01328                 if ($limit != NULL)
01329                 {
01330                         $this->limit($limit);
01331                 }
01332 
01333                 if (count($this->ar_where) == 0 && count($this->ar_like) == 0)
01334                 {
01335                         if ($this->db_debug)
01336                         {
01337                                 return $this->display_error('db_del_must_use_where');
01338                         }
01339 
01340                         return FALSE;
01341                 }               
01342 
01343                 $sql = $this->_delete($table, $this->ar_where, $this->ar_like, $this->ar_limit);
01344 
01345                 if ($reset_data)
01346                 {
01347                         $this->_reset_write();
01348                 }
01349                 
01350                 return $this->query($sql);
01351         }
01352 
01353         // --------------------------------------------------------------------
01354 
01355         /**
01356          * DB Prefix
01357          *
01358          * Prepends a database prefix if one exists in configuration
01359          *
01360          * @access      public
01361          * @param       string  the table
01362          * @return      string
01363          */
01364         function dbprefix($table = '')
01365         {
01366                 if ($table == '')
01367                 {
01368                         $this->display_error('db_table_name_required');
01369                 }
01370 
01371                 return $this->dbprefix.$table;
01372         }
01373 
01374         // --------------------------------------------------------------------
01375 
01376         /**
01377          * Track Aliases
01378          *
01379          * Used to track SQL statements written with aliased tables.
01380          *
01381          * @access      private
01382          * @param       string  The table to inspect
01383          * @return      string
01384          */     
01385         function _track_aliases($table)
01386         {
01387                 if (is_array($table))
01388                 {
01389                         foreach ($table as $t)
01390                         {
01391                                 $this->_track_aliases($t);
01392                         }
01393                         return;
01394                 }
01395                 
01396                 // Does the string contain a comma?  If so, we need to separate
01397                 // the string into discreet statements
01398                 if (strpos($table, ',') !== FALSE)
01399                 {
01400                         return $this->_track_aliases(explode(',', $table));
01401                 }
01402         
01403                 // if a table alias is used we can recognize it by a space
01404                 if (strpos($table, " ") !== FALSE)
01405                 {
01406                         // if the alias is written with the AS keyword, remove it
01407                         $table = preg_replace('/ AS /i', ' ', $table);
01408                         
01409                         // Grab the alias
01410                         $table = trim(strrchr($table, " "));
01411                         
01412                         // Store the alias, if it doesn't already exist
01413                         if ( ! in_array($table, $this->ar_aliased_tables))
01414                         {
01415                                 $this->ar_aliased_tables[] = $table;
01416                         }
01417                 }
01418         }
01419 
01420         // --------------------------------------------------------------------
01421 
01422         /**
01423          * Compile the SELECT statement
01424          *
01425          * Generates a query string based on which functions were used.
01426          * Should not be called directly.  The get() function calls it.
01427          *
01428          * @access      private
01429          * @return      string
01430          */
01431         function _compile_select($select_override = FALSE)
01432         {
01433                 // Combine any cached components with the current statements
01434                 $this->_merge_cache();
01435 
01436                 // ----------------------------------------------------------------
01437                 
01438                 // Write the "select" portion of the query
01439 
01440                 if ($select_override !== FALSE)
01441                 {
01442                         $sql = $select_override;
01443                 }
01444                 else
01445                 {
01446                         $sql = ( ! $this->ar_distinct) ? 'SELECT ' : 'SELECT DISTINCT ';
01447                 
01448                         if (count($this->ar_select) == 0)
01449                         {
01450                                 $sql .= '*';            
01451                         }
01452                         else
01453                         {                               
01454                                 // Cycle through the "select" portion of the query and prep each column name.
01455                                 // The reason we protect identifiers here rather then in the select() function
01456                                 // is because until the user calls the from() function we don't know if there are aliases
01457                                 foreach ($this->ar_select as $key => $val)
01458                                 {
01459                                         $this->ar_select[$key] = $this->_protect_identifiers($val);
01460                                 }
01461                                 
01462                                 $sql .= implode(', ', $this->ar_select);
01463                         }
01464                 }
01465 
01466                 // ----------------------------------------------------------------
01467                 
01468                 // Write the "FROM" portion of the query
01469 
01470                 if (count($this->ar_from) > 0)
01471                 {
01472                         $sql .= "\nFROM ";
01473 
01474                         $sql .= $this->_from_tables($this->ar_from);
01475                 }
01476 
01477                 // ----------------------------------------------------------------
01478                 
01479                 // Write the "JOIN" portion of the query
01480 
01481                 if (count($this->ar_join) > 0)
01482                 {
01483                         $sql .= "\n";
01484 
01485                         $sql .= implode("\n", $this->ar_join);
01486                 }
01487 
01488                 // ----------------------------------------------------------------
01489                 
01490                 // Write the "WHERE" portion of the query
01491 
01492                 if (count($this->ar_where) > 0 OR count($this->ar_like) > 0)
01493                 {
01494                         $sql .= "\n";
01495 
01496                         $sql .= "WHERE ";
01497                 }
01498 
01499                 $sql .= implode("\n", $this->ar_where);
01500 
01501                 // ----------------------------------------------------------------
01502                 
01503                 // Write the "LIKE" portion of the query
01504         
01505                 if (count($this->ar_like) > 0)
01506                 {
01507                         if (count($this->ar_where) > 0)
01508                         {
01509                                 $sql .= "\nAND ";
01510                         }
01511 
01512                         $sql .= implode("\n", $this->ar_like);
01513                 }
01514 
01515                 // ----------------------------------------------------------------
01516                 
01517                 // Write the "GROUP BY" portion of the query
01518         
01519                 if (count($this->ar_groupby) > 0)
01520                 {
01521                         $sql .= "\nGROUP BY ";
01522                         
01523                         $sql .= implode(', ', $this->ar_groupby);
01524                 }
01525 
01526                 // ----------------------------------------------------------------
01527                 
01528                 // Write the "HAVING" portion of the query
01529                 
01530                 if (count($this->ar_having) > 0)
01531                 {
01532                         $sql .= "\nHAVING ";
01533                         $sql .= implode("\n", $this->ar_having);
01534                 }
01535 
01536                 // ----------------------------------------------------------------
01537                 
01538                 // Write the "ORDER BY" portion of the query
01539 
01540                 if (count($this->ar_orderby) > 0)
01541                 {
01542                         $sql .= "\nORDER BY ";
01543                         $sql .= implode(', ', $this->ar_orderby);
01544                         
01545                         if ($this->ar_order !== FALSE)
01546                         {
01547                                 $sql .= ($this->ar_order == 'desc') ? ' DESC' : ' ASC';
01548                         }               
01549                 }
01550 
01551                 // ----------------------------------------------------------------
01552                 
01553                 // Write the "LIMIT" portion of the query
01554                 
01555                 if (is_numeric($this->ar_limit))
01556                 {
01557                         $sql .= "\n";
01558                         $sql = $this->_limit($sql, $this->ar_limit, $this->ar_offset);
01559                 }
01560 
01561                 return $sql;
01562         }
01563 
01564         // --------------------------------------------------------------------
01565 
01566         /**
01567          * Object to Array
01568          *
01569          * Takes an object as input and converts the class variables to array key/vals
01570          *
01571          * @access      public
01572          * @param       object
01573          * @return      array
01574          */
01575         function _object_to_array($object)
01576         {
01577                 if ( ! is_object($object))
01578                 {
01579                         return $object;
01580                 }
01581                 
01582                 $array = array();
01583                 foreach (get_object_vars($object) as $key => $val)
01584                 {
01585                         // There are some built in keys we need to ignore for this conversion
01586                         if ( ! is_object($val) && ! is_array($val) && $key != '_parent_name' && $key != '_ci_scaffolding' && $key != '_ci_scaff_table')
01587                         {
01588                                 $array[$key] = $val;
01589                         }
01590                 }
01591         
01592                 return $array;
01593         }
01594         
01595         // --------------------------------------------------------------------
01596 
01597         /**
01598          * Start Cache
01599          *
01600          * Starts AR caching
01601          *
01602          * @access      public
01603          * @return      void
01604          */             
01605         function start_cache()
01606         {
01607                 $this->ar_caching = TRUE;
01608         }
01609 
01610         // --------------------------------------------------------------------
01611 
01612         /**
01613          * Stop Cache
01614          *
01615          * Stops AR caching
01616          *
01617          * @access      public
01618          * @return      void
01619          */             
01620         function stop_cache()
01621         {
01622                 $this->ar_caching = FALSE;
01623         }
01624 
01625         // --------------------------------------------------------------------
01626 
01627         /**
01628          * Flush Cache
01629          *
01630          * Empties the AR cache
01631          *
01632          * @access      public
01633          * @return      void
01634          */     
01635         function flush_cache()
01636         {       
01637                 $this->_reset_run(
01638                                                         array(
01639                                                                         'ar_cache_select'       => array(), 
01640                                                                         'ar_cache_from'         => array(), 
01641                                                                         'ar_cache_join'         => array(),
01642                                                                         'ar_cache_where'        => array(), 
01643                                                                         'ar_cache_like'         => array(), 
01644                                                                         'ar_cache_groupby'      => array(), 
01645                                                                         'ar_cache_having'       => array(), 
01646                                                                         'ar_cache_orderby'      => array(), 
01647                                                                         'ar_cache_set'          => array(),
01648                                                                         'ar_cache_exists'       => array()
01649                                                                 )
01650                                                         );      
01651         }
01652 
01653         // --------------------------------------------------------------------
01654 
01655         /**
01656          * Merge Cache
01657          *
01658          * When called, this function merges any cached AR arrays with 
01659          * locally called ones.
01660          *
01661          * @access      private
01662          * @return      void
01663          */
01664         function _merge_cache()
01665         {
01666                 if (count($this->ar_cache_exists) == 0)
01667                 {
01668                         return;
01669                 }
01670 
01671                 foreach ($this->ar_cache_exists as $val)
01672                 {
01673                         $ar_variable    = 'ar_'.$val;
01674                         $ar_cache_var   = 'ar_cache_'.$val;
01675 
01676                         if (count($this->$ar_cache_var) == 0)
01677                         {
01678                                 continue;
01679                         }
01680 
01681                         $this->$ar_variable = array_unique(array_merge($this->$ar_cache_var, $this->$ar_variable));
01682                 }
01683 
01684                 // If we are "protecting identifiers" we need to examine the "from"
01685                 // portion of the query to determine if there are any aliases
01686                 if ($this->_protect_identifiers === TRUE AND count($this->ar_cache_from) > 0)
01687                 {
01688                         $this->_track_aliases($this->ar_from);
01689                 }
01690         }
01691 
01692         // --------------------------------------------------------------------
01693 
01694         /**
01695          * Resets the active record values.  Called by the get() function
01696          *
01697          * @access      private
01698          * @param       array   An array of fields to reset
01699          * @return      void
01700          */
01701         function _reset_run($ar_reset_items)
01702         {
01703                 foreach ($ar_reset_items as $item => $default_value)
01704                 {
01705                         if ( ! in_array($item, $this->ar_store_array))
01706                         {
01707                                 $this->$item = $default_value;
01708                         }
01709                 }
01710         }
01711 
01712         // --------------------------------------------------------------------
01713 
01714         /**
01715          * Resets the active record values.  Called by the get() function
01716          *
01717          * @access      private
01718          * @return      void
01719          */
01720         function _reset_select()
01721         {
01722                 $ar_reset_items = array(
01723                                                                 'ar_select'                     => array(), 
01724                                                                 'ar_from'                       => array(), 
01725                                                                 'ar_join'                       => array(), 
01726                                                                 'ar_where'                      => array(), 
01727                                                                 'ar_like'                       => array(), 
01728                                                                 'ar_groupby'            => array(), 
01729                                                                 'ar_having'                     => array(), 
01730                                                                 'ar_orderby'            => array(), 
01731                                                                 'ar_wherein'            => array(), 
01732                                                                 'ar_aliased_tables'     => array(),
01733                                                                 'ar_distinct'           => FALSE, 
01734                                                                 'ar_limit'                      => FALSE, 
01735                                                                 'ar_offset'                     => FALSE, 
01736                                                                 'ar_order'                      => FALSE,
01737                                                         );
01738                 
01739                 $this->_reset_run($ar_reset_items);
01740         }
01741         
01742         // --------------------------------------------------------------------
01743 
01744         /**
01745          * Resets the active record "write" values.
01746          *
01747          * Called by the insert() update() and delete() functions
01748          *
01749          * @access      private
01750          * @return      void
01751          */
01752         function _reset_write()
01753         {       
01754                 $ar_reset_items = array(
01755                                                                 'ar_set'                => array(), 
01756                                                                 'ar_from'               => array(), 
01757                                                                 'ar_where'              => array(), 
01758                                                                 'ar_like'               => array(),
01759                                                                 'ar_orderby'    => array(), 
01760                                                                 'ar_limit'              => FALSE, 
01761                                                                 'ar_order'              => FALSE
01762                                                                 );
01763 
01764                 $this->_reset_run($ar_reset_items);
01765         }
01766         
01767 }
01768 
01769 /* End of file DB_active_rec.php */
01770 /* Location: ./system/database/DB_active_rec.php */