| author | Bashkim Isai |
|---|---|
| package | OXRM |
In file D:\oblib-core\php\oblib\dataOXRM\dataEntityQuery.class.php between lines 51 and 295.
<?php
/**
* Represents a "manually written" SQL SELECT statement
* for an entity
*
* @author Bashkim Isai
* @package OXRM
* @see Object [data]
* @see Object [dataSampleQuery]
*/
class dataEntityQuery implements dataSampleQuery
{
/**
* The corresponding dataEntities object which is being Queries from the Database
*
* @type Object [typeOf dataEntities]
*/
private $_denEntities;
/**
* The WHERE clause builder
*
* @type Object [dataQueryBranch]
*/
private $_eqbWhere;
/**
* The length of the Sample being returned. If NULL, no LIMIT will be applied
*
* @type Integer
*/
private $_intSampleLength;
/**
* The page number that is currently being previewed.
* Does nothing unless the Sample Length is defined
*
* @type Integer
*/
private $_intSamplePage;
/**
* The current table alias that is in use for this query
*
* @type String
*/
private $_strTableAlias;
/**
* The next table alias that will be used for the next Query
*
* @type String
*/
private static $_strNextAlias = 'a';
/**
* Creates a new Manual Entity SELECT Query
*
* @return Void
*/
final function __construct (dataEntities &$denEntities)
{
$this->_denEntities =& $denEntities;
$this->_eqbWhere = new dataQueryBranch;
$this->_strTableAlias = self::$_strNextAlias++;
}
/**
* Accessor method which returns the current WHERE dataQueryBranch in use
*
* @return Class [dataQueryBranch]
*/
public function &Where ()
{
return $this->_eqbWhere;
}
/**
* Define the LIMIT Clause of the generated Statement (Sample Length, Page Number)
*
* @return Void
*/
public function Sample ($intSampleLength=NULL, $intSamplePage=NULL)
{
$this->_intSampleLength = $intSampleLength;
$this->_intSamplePage = $intSamplePage;
}
/**
* Runs the SELECT statement and returns a Sample
*
* @return dataSample
* @see Class [dataSample]
*/
public function ___Render ()
{
return new dataSample ($this);
}
/**
* The Following Lines relate specifically to generating SELECT queries
*/
/**
* The tagName of the Sample Element
*
* @return String
* @see Class [dataSample]
*/
public function QuerySelect_Name ()
{
return $this->_denEntities->___ClassMany ();
}
/**
* The Function that will be called to handle results
*
* @return Callback
* @see Class [dataSample]
*/
public function QuerySelect_Result ()
{
return Array ($this, 'QuerySelect_ResultHandler');
}
/**
* The Function which Handles Results for this Element
* Generates an object and returns it to add to the Sample
*
* @return Object [typeOf dataEntities::_strClassOne]
* @see Class [dataSample]
* @see Class [dataEntities]
*/
public function QuerySelect_ResultHandler ($arrData)
{
$strClass = $this->_denEntities->___ClassOne ();
return new $strClass ($this->_denEntities, $arrData);
}
/**
* Generates the fields to return for the SELECT statement
*
* @return String
* @see Class [dataSample]
* @see Class [dataEntities]
*/
public function QuerySelect_Field ()
{
return $this->_denEntities->___PropertySelect ($this->_strTableAlias);
}
/**
* Gets the name and alias to use for the FROM clause
*
* @return String
* @see Class [dataSample]
* @see Class [dataEntities]
*/
public function QuerySelect_Table ()
{
return '`' . $this->_denEntities->___Table () . '` `' . $this->_strTableAlias . '`';
}
/**
* Returns the WHERE clause as an Object to be traversed manually
*
* @return String
* @see Class [dataSample]
* @see Class [dataEntities]
*/
public function QuerySelect_Where ()
{
return $this->_eqbWhere;
}
/**
* Generates the GROUP BY Clause. As there is no GROUP BY allowed for dataEntityQuery objects,
* a blank value is returned
*
* @return String
* @see Class [dataSample]
* @see Class [dataEntities]
*/
public function QuerySelect_GroupBy ()
{
return '';
}
/**
* Generates the ORDER BY Clause. As there is no ORDER BY allowed for dataEntityQuery objects,
* a blank value is returned
*
* @return String
* @see Class [dataSample]
* @see Class [dataEntities]
*/
public function QuerySelect_OrderBy ()
{
return '';
}
/**
* Accessor method for the Sample Length
*
* @return String
* @see Property [dataEntityQuery _intSamplePage]
* @see Class [dataSample]
* @see Class [dataEntities]
*/
public function QuerySelect_SampleLength ()
{
return $this->_intSampleLength;
}
/**
* Accessor method for the Sample Page
*
* @return String
* @see Property [dataEntityQuery _intSamplePage]
* @see Class [dataSample]
* @see Class [dataEntities]
*/
public function QuerySelect_SamplePage ()
{
return $this->_intSamplePage;
}
}
?>