Source for file PostgreSQLGenericQueryResult.class.php

Documentation is available at PostgreSQLGenericQueryResult.class.php

  1. <?php
  2. /**
  3. * @package harmoni.dbc.postgre
  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: PostgreSQLGenericQueryResult.class.php,v 1.1 2007/09/14 13:57:08 adamfranco Exp $
  9. */
  10. require_once(HARMONI."DBHandler/GenericQueryResult.interface.php");
  11.  
  12. /**
  13. * The GenericQueryResult interface provides methods for accessing the results of
  14. * a generic query. These results can be returned as if they were one of the other
  15. * query types, or the resource links can be returned and accessed directly.
  16. *
  17. *
  18. * @package harmoni.dbc.postgre
  19. *
  20. * @copyright Copyright &copy; 2005, Middlebury College
  21. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  22. *
  23. * @version $Id: PostgreSQLGenericQueryResult.class.php,v 1.1 2007/09/14 13:57:08 adamfranco Exp $
  24. */
  25. class PostgreSQLGenericQueryResult
  26. implements GenericQueryResultInterface
  27. {
  28. /**
  29. * The resource id for this SELECT query.
  30. * The resource id for this SELECT query.
  31. * @var integer $_resourceId The resource id for this SELECT query.
  32. * @access private
  33. */
  34. var $_resourceId;
  35.  
  36.  
  37. /**
  38. * The link identifier for the database connection.
  39. * The link identifier for the database connection.
  40. * @param integer $_linkId The link identifier for the database connection.
  41. * @access private
  42. */
  43. var $_linkId;
  44. /**
  45. * Constructor
  46. *
  47. * @param integer $resourceId The resource id for this SELECT query.
  48. * @param integer $linkId The link identifier for the database connection.
  49. * @access public
  50. * @since 7/2/04
  51. */
  52. function PostgreSQLGenericQueryResult ($resourceId, $linkId) {
  53. // ** parameter validation
  54. $resourceRule = ResourceValidatorRule::getRule();
  55. if (!is_bool($resourceId)) {
  56. ArgumentValidator::validate($resourceId, $resourceRule, true);
  57. }
  58. ArgumentValidator::validate($linkId, $resourceRule, true);
  59. // ** end of parameter validation
  60.  
  61. $this->_resourceId = $resourceId;
  62. $this->_linkId = $linkId;
  63. }
  64. /**
  65. * Returns the number of rows that the query processed.
  66. * Returns the number of rows that the query processed. For a SELECT query,
  67. * this would be the total number of rows selected. For a DELETE, UPDATE, or
  68. * INSERT query, this would be the number of rows that were affected.
  69. * @return integer Number of rows that were processed by the query.
  70. */
  71. function getNumberOfRows() {
  72. return pg_num_rows($this->_resourceId);
  73. }
  74.  
  75. /**
  76. * Returns the resource id for this SELECT query.
  77. * Returns the resource id for this SELECT query. The resource id is returned
  78. * by the PostgreSQL_query() function.
  79. * @access public
  80. * @return integer The resource id for this SELECT query.
  81. ***/
  82. function getResourceId() {
  83. return $this->_resourceId;
  84. }
  85. /**
  86. * Returns the result of the query as a SelectQueryResult.
  87. *
  88. * @return object SelectQueryResult
  89. * @access public
  90. * @since 7/1/04
  91. */
  92. function returnAsSelectQueryResult () {
  93. $obj = new PostgreSQLSelectQueryResult($this->_resourceId, $this->_linkId);
  94. return $obj;
  95. }
  96. /**
  97. * Returns the result of the query as an InsertQueryResult.
  98. *
  99. * @return object InsertQueryResult
  100. * @access public
  101. * @since 7/1/04
  102. */
  103. function returnAsInsertQueryResult () {
  104. $obj = new PostgreSQLInsertQueryResult($this->_linkId);
  105. return $obj;
  106. }
  107. /**
  108. * Returns the result of the query as a UpdateQueryResult.
  109. *
  110. * @return object UpdateQueryResult
  111. * @access public
  112. * @since 7/1/04
  113. */
  114. function returnAsUpdateQueryResult () {
  115. $obj = new PostgreSQLUpdateQueryResult($this->_linkId);
  116. return $obj;
  117. }
  118. /**
  119. * Returns the result of the query as a DeleteQueryResult.
  120. *
  121. * @return object DeleteQueryResult
  122. * @access public
  123. * @since 7/1/04
  124. */
  125. function returnAsDeleteQueryResult () {
  126. $obj = new PostgreSQLDeleteQueryResult($this->_linkId);
  127. return $obj;
  128. }
  129. }
  130.  
  131. ?>

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