# SelectField.class.php

Go to the documentation of this file.

    00001 <?php
    00002 /***************************************************************************
    00003  *   Copyright (C) 2005-2008 by Anton E. Lebedevich                        *
    00004  *                                                                         *
    00005  *   This program is free software; you can redistribute it and/or modify  *
    00006  *   it under the terms of the GNU Lesser General Public License as        *
    00007  *   published by the Free Software Foundation; either version 3 of the    *
    00008  *   License, or (at your option) any later version.                       *
    00009  *                                                                         *
    00010  ***************************************************************************/
    00011
    00018     final class SelectField extends FieldTable implements Aliased
    00019     {
    00020         private $alias = null;
    00021
    00025         public static function create(DialectString $field, $alias)
    00026         {
    00027             return new self($field, $alias);
    00028         }
    00029
    00030         public function __construct(DialectString $field, $alias)
    00031         {
    00032             parent::__construct($field);
    00033             $this->alias = $alias;
    00034         }
    00035
    00036         public function getAlias()
    00037         {
    00038             return $this->alias;
    00039         }
    00040
    00041         public function getName()
    00042         {
    00043             if ($this->field instanceof DBField)
    00044                 return $this->field->getField();
    00045
    00046             return $this->alias;
    00047         }
    00048
    00049         public function toDialectString(Dialect $dialect)
    00050         {
    00051             return
    00052                 parent::toDialectString($dialect)
    00053                 .(
    00054                     $this->alias
    00055                         ? ' AS '.$dialect->quoteField($this->alias)
    00056                         : null
    00057                 );
    00058         }
    00059     }
    00060 ?>