public function generateAlias(Clause $clause)
    {
        if ($clause instanceof FieldName)
        {
            $table = $clause->getTable();
            if (empty($table))
            {
                // When no table is defined, it means only one table is being
                // used in the query. Aliases will not be required
                return "";
            }

            $prefix = $table->getPrefix();
            $alias = $prefix . '_' . $clause->getField();
        }
        elseif ($clause instanceof SQLFunction)
        {
            $func = $clause->getFunction();
            $alias = strtolower($func);
        }
        else
            throw new ImplementationException("No alias generation implemented for: " . get_class($clause));

        $cnt = 1;
        $base_alias = $alias;
        while (isset($this->field_aliases[$alias]))
            $alias = $base_alias . (++$cnt);

        $this->field_aliases[$alias] = true;
        return $alias;
    }
public function generateAlias(Clause $clause)
    {
        if ($clause instanceof FieldName)
        {
            $table = $clause->getTable();
            if (empty($table))
            {
                // When no table is defined, it means only one table is being
                // used in the query. Aliases will not be required
                return "";
            }

            $prefix = $table->getPrefix();
            $alias = $prefix . '_' . $clause->getField();
        }
        elseif ($clause instanceof SQLFunction)
        {
            $func = $clause->getFunction();
            $alias = strtolower($func);
        }
        else
            throw new ImplementationException("No alias generation implemented for: " . get_class($clause));

        $cnt = 1;
        $base_alias = $alias;
        while (isset($this->field_aliases[$alias]))
            $alias = $base_alias . (++$cnt);

        $this->field_aliases[$alias] = true;
        return $alias;
    }
public function generateAlias ( Clause $ clause ) { if ( $ clause instanceof FieldName ) { $ table = $ clause -> getTable ( ) ; if ( empty ( $ table ) ) { // When no table is defined, it means only one table is being // used in the query. Aliases will not be required return "" ; } $ prefix = $ table -> getPrefix ( ) ; $ alias = $ prefix . '_' . $ clause -> getField ( ) ; } elseif ( $ clause instanceof SQLFunction ) { $ func = $ clause -> getFunction ( ) ; $ alias = strtolower ( $ func ) ; } else throw new ImplementationException ( "No alias generation implemented for: " . get_class ( $ clause ) ) ; $ cnt = 1 ; $ base_alias = $ alias ; while ( isset ( $ this -> field_aliases [ $ alias ] ) ) $ alias = $ base_alias . ( ++ $ cnt ) ; $ this -> field_aliases [ $ alias ] = true ; return $ alias ; }
Generate an alias for a table
@param Clause $clause The field or sub query to refer to
@return string The alias for the table
Generate an alias for a table