| author | Bashkim Isai |
|---|---|
| package | OXRM |
In file D:\oblib-core\php\oblib\dataOXRM\dataEntityQueryCull.class.php between lines 50 and 140.
<?php
/**
* Represents a 'manually written' SQL DELETE statement
* for an entity
*
* @author Bashkim Isai
* @package OXRM
* @see Object [data]
*/
class dataEntityQueryCull
{
/**
* 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;
/**
* Creates a new Manual Entity DELETE Query
*
* @return Void
*/
final function __construct (dataEntities &$denEntities)
{
$this->_denEntities =& $denEntities;
$this->_eqbWhere = new dataQueryBranch;
}
/**
* Accessor method which returns the current WHERE dataQueryBranch in use
*
* @return Class [dataQueryBranch]
*/
public function &Where ()
{
return $this->_eqbWhere;
}
/**
* Renders and Executes the SQL DELETE Statement and returns the number of
* affected rows
*
* @return Integer
*/
public function ___Render ()
{
// Build the Query
$strParam = '';
$arrParam = Array ();
// Clauses
$strWhere = $this->_eqbWhere->___Render ($strParam, $arrParam, NULL);
$strStatement = 'DELETE FROM `' . $this->_denEntities->___Table (). '` ';
$strStatement .= 'WHERE ' . $strWhere . ' ';
$smtStatement = $GLOBALS ['MySQL']->Prepare ($strStatement);
if (!$smtStatement)
{
throw new ExceptionMysql ($GLOBALS ['MySQL'], $strStatement);
}
if (count ($arrParam) <> 0)
{
array_unshift ($arrParam, $strParam);
call_user_func_array (
Array ($smtStatement, 'bind_param'),
$arrParam
);
}
$bolResponse = $smtStatement->execute ();
$smtStatement->free_result ();
// If there was a failure, throw an exception
if (!$bolResponse)
{
throw new ExceptionMysql ($GLOBALS ['MySQL'], $strStatement);
}
return $GLOBALS ['MySQL']->affected_rows;
}
}
?>