CI_DB_query_builder::_track_aliases PHP Method

_track_aliases() protected method

Used to track SQL statements written with aliased tables.
protected _track_aliases ( $table ) : string
return string
    protected function _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)) {
                $this->qb_aliased_tables[] = $table;
            }
        }
    }