Source for file OracleInsertQueryResult.class.php

Documentation is available at OracleInsertQueryResult.class.php

  1. <?php
  2. /**
  3. * @package harmoni.dbc.oracle
  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: OracleInsertQueryResult.class.php,v 1.8 2007/09/05 21:39:00 adamfranco Exp $
  9. */
  10. require_once(HARMONI."DBHandler/InsertQueryResult.interface.php");
  11.  
  12. /**
  13. * The InsertQueryResult interface provides the functionality common to all INSERT query results.
  14. * For example, you can get the primary key for the last insertion, get number of inserted rows, etc.
  15. *
  16. * @package harmoni.dbc.oracle
  17. *
  18. * @copyright Copyright &copy; 2005, Middlebury College
  19. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  20. *
  21. * @version $Id: OracleInsertQueryResult.class.php,v 1.8 2007/09/05 21:39:00 adamfranco Exp $
  22. */
  23.  
  24. class OracleInsertQueryResult
  25. implements InsertQueryResultInterface
  26. {
  27.  
  28.  
  29. /**
  30. * The resource id for this query.
  31. * @var integer __resourceId
  32. * @access private
  33. */
  34. var $_resourceId;
  35.  
  36. /**
  37. * Gets the last auto increment value that was generated by the INSERT query.
  38. * Gets the last auto increment value that was generated by the INSERT query.
  39. * @access private
  40. * @var integer $_lastAutoIncrementValue The last auto increment value that was generated by the INSERT query.
  41. */
  42. var $_lastAutoIncrementValue;
  43.  
  44. /**
  45. * Stores the number of rows processed by the query.
  46. * Stores the number of rows processed by the query.
  47. * @var integer $_numberOfRows The number of rows processed by the query.
  48. * @access private
  49. */
  50. var $_numberOfRows;
  51.  
  52.  
  53. /**
  54. * Creates a new OracleINSERTQueryResult object.
  55. * @access public
  56. * @param integer $resourceId The resource id for this query.
  57. * @param integer $lastId The last id that was inserted
  58. * @return object A new OracleINSERTQueryResult object.
  59. */
  60. function OracleInsertQueryResult($resourceId, $lastId) {
  61. // ** parameter validation
  62. $resourceRule = ResourceValidatorRule::getRule();
  63. $integerRule = OptionalRule::getRule(IntegerValidatorRule::getRule());
  64. ArgumentValidator::validate($resourceId, $resourceRule, true);
  65. ArgumentValidator::validate($lastId, $integerRule, true);
  66. // ** end of parameter validation
  67.  
  68. $this->_resourceId = $resourceId;
  69. $this->_numberOfRows = ocirowcount($this->_resourceId);
  70. $this->_lastAutoIncrementValue = $lastId;
  71. }
  72.  
  73. /**
  74. * Gets the last auto increment value that was generated by the INSERT query.
  75. * This is not a 100% reliable method. If somebody inserted something after
  76. * the insert query but before the InsertQueryResult object was created, then
  77. * this method could return an invalid value.
  78. * @access public
  79. * @return integer The last auto increment value that was generated by the INSERT query.
  80. */
  81. function getLastAutoIncrementValue() {
  82. if (is_null($this->_lastAutoIncrementValue)) {
  83. $str = "Cannot get last autoincrement value, because the autoincrement ";
  84. $str .= "column has not been set with setAutoIncrementColumn().";
  85. throw new DatabaseException($str);
  86. }
  87. return $this->_lastAutoIncrementValue;
  88. }
  89.  
  90. /**
  91. * Returns the number of rows that the query processed.
  92. * Returns the number of rows that the query processed. For a SELECT query,
  93. * this would be the total number of rows selected. For a DELETE, UPDATE, or
  94. * INSERT query, this would be the number of rows that were affected.
  95. * @return integer Number of rows that were processed by the query.
  96. * @access public
  97. */
  98. function getNumberOfRows() {
  99. return $this->_numberOfRows;
  100. }
  101.  
  102.  
  103. }
  104.  
  105. ?>

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