Source for file DeleteQuery.class.php

Documentation is available at DeleteQuery.class.php

  1. <?php
  2. /**
  3. * @package harmoni.dbc
  4. *
  5. * @copyright Copyright &copy; 2005, Middlebury College
  6. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  7. *
  8. * @version $Id: DeleteQuery.class.php,v 1.8 2007/09/05 21:38:59 adamfranco Exp $
  9. */
  10. require_once(HARMONI."DBHandler/DeleteQuery.interface.php");
  11. require_once("Query.abstract.php");
  12.  
  13. /**
  14. * A DeleteQuery class provides the tools to build a DELETE query.
  15. *
  16. *
  17. * @package harmoni.dbc
  18. *
  19. * @copyright Copyright &copy; 2005, Middlebury College
  20. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  21. *
  22. * @version $Id: DeleteQuery.class.php,v 1.8 2007/09/05 21:38:59 adamfranco Exp $
  23. */
  24.  
  25. class DeleteQuery
  26. extends QueryAbstract
  27. implements DeleteQueryInterface
  28. {
  29.  
  30.  
  31. /**
  32. * @var string $_table The name of the table to update.
  33. * @access private
  34. */
  35. var $_table;
  36.  
  37. /**
  38. * This will store the condition in the WHERE clause. Each element of this
  39. * array stores 2 things: the condition itself, and the logical operator
  40. * to use to join with the previous condition.
  41. * @var array $_condition The condition in the WHERE clause.
  42. * @access private
  43. */
  44. var $_condition;
  45.  
  46. /**
  47. * This is the constructor for a DELETE query.
  48. * This is the constructor for a DELETE query.
  49. * @access public
  50. */
  51. function DeleteQuery() {
  52. $this->reset();
  53. }
  54.  
  55.  
  56. /**
  57. * Sets the table to delete from.
  58. * @param string $table The table to delete from.
  59. * @access public
  60. */
  61. function setTable($table) {
  62. // ** parameter validation
  63. $stringRule = StringValidatorRule::getRule();
  64. ArgumentValidator::validate($table, $stringRule, true);
  65. // ** end of parameter validation
  66.  
  67. $this->_table = $table;
  68. }
  69.  
  70.  
  71. /**
  72. * *Deprecated* Specifies the condition in the WHERE clause.
  73. *
  74. * The query will execute only on rows that fulfil the condition. If this method
  75. * is never called, then the WHERE clause will not be included.
  76. * @param string The WHERE clause condition.
  77. * @access public
  78. * @deprecated July 09, 2003 - Use addWhere() instead.
  79. */
  80. function setWhere($condition) {
  81. // ** parameter validation
  82. $stringRule = StringValidatorRule::getRule();
  83. ArgumentValidator::validate($condition, $stringRule, true);
  84. // ** end of parameter validation
  85.  
  86. $arr = array();
  87. $arr[] = $condition;
  88. $arr[] = null;
  89. $this->_condition[] = $arr;
  90. }
  91.  
  92.  
  93. /**
  94. * Adds a new condition in the WHERE clause.
  95. *
  96. * The query will execute only on rows that fulfil the condition. If this method
  97. * is never called, then the WHERE clause will not be included.
  98. * @param string condition The WHERE clause condition to add.
  99. * @param integer logicalOperation The logical operation to use to connect
  100. * this WHERE condition with the previous WHERE conditions. Allowed values:
  101. * <code>_AND</code> and <code>_OR</code>.
  102. * @access public
  103. * @return void
  104. */
  105. function addWhere($condition, $logicalOperation = _AND) {
  106. // ** parameter validation
  107. $stringRule = StringValidatorRule::getRule();
  108. $integerRule = IntegerValidatorRule::getRule();
  109. $optionalRule = OptionalRule::getRule($integerRule);
  110. ArgumentValidator::validate($condition, $stringRule, true);
  111. ArgumentValidator::validate($logicalOperation, $optionalRule, true);
  112. // ** end of parameter validation
  113.  
  114. $arr = array();
  115. $arr[] = $condition;
  116. $arr[] = $logicalOperation;
  117. $this->_condition[] = $arr;
  118. }
  119.  
  120.  
  121. /**
  122. * Resets the query.
  123. * @access public
  124. */
  125. function reset() {
  126. parent::reset();
  127.  
  128. // a DELETE query
  129. $this->_type = DELETE;
  130. // default query configuration:
  131. // no table to delete from
  132. $this->_table = "";
  133.  
  134. // no WHERE condition, by default
  135. $this->_condition = array();
  136. }
  137.  
  138. }
  139. ?>

Documentation generated on Wed, 19 Sep 2007 10:22:42 -0400 by phpDocumentor 1.3.0RC3