<?php
/*
=============================================================================================================================================
| This file is part of a project released under the terms of the Xyndravandria PHP License (XyndravandriaPHPLicense.txt). |
| |
| You should be given a copy of the Xyndravandria PHP License (XyndravandriaPHPLicense.txt) within the same directory as the README.md; |
| if not, you can get a copy at http://Xyndravandria.ohost.de/XyndravandriaPHPLicense.txt . |
| |
| The copyright (c) of this project is owned by Mauro Di Girolamo <maurodigirolamo@.web.de>. |
============================================================================================================================================|
Xyndravandria Dyverath
----------------------
Alpha 0.0.0
Xyndravandria is the name of a collection of projects designed and developed by Mauro Di Girolamo (maurodigirolamo@web.de); he is therefore the copyright (c) owner of Xyndravandria itself and all of its projects.
Xyndravandria Dyverath is released under the terms of the Xyndravandria PHP License (XyndravandriaPHPLicense.txt). You should be given a copy of the Xyndravandria PHP License (XyndravandriaPHPLicense.txt) within the same directory as the README.md; if not, you can get a copy at http://Xyndravandria.ohost.de/XyndravandriaPHPLicense.txt . There might be a release under a freer license for a later, more stable version.
The documentation is either included in ./admin_media/Documentation/ or can be read at http://Xyndravandria.ohost.de/Dyverath/Documentation/.
All projects:
Xyndravandria Averazain
http://github.com/MauroDiGirolamo/Xyndravandria_Averazain
PHP
Averazain is an Ajax framework supporting also JavaScript disabled clients perfectly - including search engines like Google.
Xyndravandria Dyverath
http://github.com/MauroDiGirolamo/Xyndravandria_Dyverath
PHP
Dyverath is a database access wrapper.
Xyndravandria Erozaver
http://github.com/MauroDiGirolamo/Xyndravandria_Erozaver
PHP
Erozaver is a class extending the type hinting given by the PHP engine (additional support for basic type hinting and size constraints).
Xyndravandria Mondraviel
http://github.com/MauroDiGirolamo/Xyndravandria_Mondraviel
PHP
Mondraviel is a class used to separate HTML from PHP code by firstly register models - files containing place holders embedded in HTML code - and then later fill them dynamically with content by passing values for the place holders.
*/
namespace Xyndravandria\Dyverath\Query\Component\Statement;
use Xyndravandria\Dyverath\Table;
use Xyndravandria\Dyverath\Query\Component\Component;
use Xyndravandria\Dyverath\Query\Component\Type\Column;
use Xyndravandria\Dyverath\Query\Component\Type\Operator;
use Xyndravandria\Dyverath\Query\Component\Type\Value;
use Xyndravandria\Erozaver\XyndravandriaDyverathException;
/// @brief A class representing a general statement within a
/// Query.
/// @details A class representing a general statement within a
/// Query. @n
/// It consists of a left part (StatementType), an operator (@ref Xyndravandria::Dyverath::Query::Component::Type::Operator "Operator") and a right part (StatementType). @n
/// Examples:
/// @verbatim new Statement( new Column( 'id' ), new Operator( '>' ), new Value( 10 ) )
///new Statement( new Column( 'Name' ), new Operator( '=' ), new Value( 'Peter' ) ) @endverbatim
/// @abstract
class Statement extends Component {
/// The left part.
/// <dl class = "type"><dt><b>%Type:</b></dt>
/// <dd>StatementType</dd></dl>
/// @private
private $Left;
/// Returns Statement::$Left.
/// @public
/// @returns StatementType
public function Left( ) {
return $this->Left;
}
/// The Operator.
/// <dl class = "type"><dt><b>%Type:</b></dt>
/// <dd>Operator</dd></dl>
/// @private
private $Operator;
/// The right part.
/// <dl class = "type"><dt><b>%Type:</b></dt>
/// <dd>StatementType</dd></dl>
/// @private
private $Right;
/// Returns Statement::$Right.
/// @public
/// @returns StatementType
public function Right( ) {
return $this->Right;
}
/// Creates a new Statement.
/// @public
/// @param StatementType $Left: The left part.
/// @param Operator $Operator: The Operator.
/// @param StatementType $Right: The right part.
public function __construct( StatementType $Left, Operator $Operator, StatementType $Right ) {
// TODO Make this easier. It should be possible to pass strings in $Left, $Operator, $Right.
// TODO: Check whether $Left or $Right has alias?
//if( $Left instanceof Column && $Left->HasAnchor( ) )
// throw new XyndravandriaDyverathException( 'No column in $Left can have an alias!' );
//else
$this->Left = $Left;
$this->Operator = $Operator;
//if( $Right instanceof Column && $Right->HasAnchor( ) )
// throw new XyndravandriaDyverathException( 'No column in $Right can have an alias!' );
//else
$this->Right = $Right;
return;
}
/// Optimises a Statement.
/// @public
/// @param Table $Table: The Table used to optimise.
public function Optimise( Table $Table ) {
$this->Left instanceof Column && $this->Left->Optimise( $Table );
$this->Right instanceof Column && $this->Right->Optimise( $Table );
return;
}
/// Returns the Statement as a string.
/// @public
/// @returns string
/// @note Required by the Component class.
public function __ToString( ) {
return $this->Left . ' ' . $this->Operator . ' ' . $this->Right;
}
}
?>
|