// ORDER BY usage is often problematic here (most notably // on Microsoft SQL Server) and ultimately unnecessary // for selecting COUNT(*) ... if ( ! empty($this->qb_orderby)) { $orderby = $this->qb_orderby; $this->qb_orderby = NULL; }
if ($reset === TRUE) { $this->_reset_select(); } // If we've previously reset the qb_orderby values, get them back elseif ( ! isset($this->qb_orderby)) { $this->qb_orderby = $orderby; }
protectedfunction_track_aliases($table) { if (is_array($table)) { foreach ($table as $t) { $this->_track_aliases($t); } return; }
// Does the string contain a comma? If so, we need to separate // the string into discreet statements if (strpos($table, ',') !== FALSE) { return$this->_track_aliases(explode(',', $table)); }
// if a table alias is used we can recognize it by a space if (strpos($table, ' ') !== FALSE) { // if the alias is written with the AS keyword, remove it $table = preg_replace('/\s+AS\s+/i', ' ', $table);
// Grab the alias $table = trim(strrchr($table, ' '));
// Store the alias, if it doesn't already exist if ( ! in_array($table, $this->qb_aliased_tables, TRUE)) { $this->qb_aliased_tables[] = $table; if ($this->qb_caching === TRUE && ! in_array($table, $this->qb_cache_aliased_tables, TRUE)) { $this->qb_cache_aliased_tables[] = $table; $this->qb_cache_exists[] = 'aliased_tables'; } } } }