# SQLBaseJoin.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
    00015     abstract class SQLBaseJoin implements SQLTableName, Aliased
    00016     {
    00017         protected $subject  = null;
    00018         protected $alias    = null;
    00019         protected $logic    = null;
    00020
    00021         public function __construct($subject, LogicalObject $logic, $alias)
    00022         {
    00023             $this->subject  = $subject;
    00024             $this->alias    = $alias;
    00025             $this->logic    = $logic;
    00026         }
    00027
    00028         public function getAlias()
    00029         {
    00030             return $this->alias;
    00031         }
    00032
    00033         public function getTable()
    00034         {
    00035             return $this->alias ? $this->alias : $this->subject;
    00036         }
    00037
    00038         protected function baseToString(Dialect $dialect, $logic = null)
    00039         {
    00040             return
    00041                 $logic.'JOIN '
    00042                     .($this->subject instanceof DialectString
    00043                         ?
    00044                             $this->subject instanceof Query
    00045                                 ? '('.$this->subject->toDialectString($dialect).')'
    00046                                 : $this->subject->toDialectString($dialect)
    00047                         : $dialect->quoteTable($this->subject)
    00048                     )
    00049                 .($this->alias ? ' AS '.$dialect->quoteTable($this->alias) : null)
    00050                 .' ON '.$this->logic->toDialectString($dialect);
    00051         }
    00052     }
    00053 ?>