Source for file StorableBlob.class.php

Documentation is available at StorableBlob.class.php

  1. <?php
  2.  
  3. require_once(HARMONI."dataManager/storablePrimitives/StorableString.abstract.php");
  4.  
  5. /**
  6. * This is the {@link StorablePrimitive} equivalent of {@link Blob} for the dm_blob table.
  7. *
  8. * @package harmoni.datamanager.storableprimitives
  9. *
  10. * @copyright Copyright &copy; 2005, Middlebury College
  11. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  12. *
  13. * @version $Id: StorableBlob.class.php,v 1.10 2007/09/04 20:25:33 adamfranco Exp $
  14. */
  15. class StorableBlob
  16. extends StorableStringAbstract
  17. /* implements StorablePrimitive */
  18. {
  19.  
  20. /*******************************************************
  21. * Class Methods
  22. *********************************************************/
  23.  
  24. /**
  25. * Takes a single database row, which would contain the columns added by alterQuery()
  26. * and extracts the values to setup the object with the appropriate data.
  27. * @param array $dbRow
  28. * @access public
  29. * @return object StorableBlob
  30. * @static
  31. */
  32. function createAndPopulate( $dbRow ) {
  33. $blob = new StorableBlob;
  34. $blob->_setValue($dbRow["blob_data"]);
  35. return $blob;
  36. }
  37. /*******************************************************
  38. * Instance Methods
  39. *********************************************************/
  40.  
  41. /**
  42. * Inserts a new row into the Database with the data contained in the object.
  43. * @param integer $dbID The {@link DBHandler} database ID to query.
  44. * @access public
  45. * @return integer Returns the new ID of the data stored.
  46. */
  47. function insert($dbID) {
  48. $this->_table = "dm_blob";
  49. return parent::insert($dbID);
  50. }
  51. /**
  52. * Set the value
  53. *
  54. * @param $value
  55. * @return void
  56. * @access private
  57. * @since 7/13/05
  58. */
  59. function _setValue ($value) {
  60. $this->_string = (string) $value;
  61. }
  62.  
  63. function StorableBlob() {
  64. $this->_table = "dm_blob";
  65. }
  66. /**
  67. * Takes an existing {@link SelectQuery} and adds a table join and some columns so that
  68. * when it is executed the actual data can be retrieved from the row. The join condition must
  69. * be "fk_data = data_id_field", since the field "fk_data" is already part of the DataManager's
  70. * table structure.
  71. * @access public
  72. * @return void
  73. */
  74. function alterQuery( $query ) {
  75. $query->addTable("dm_blob",LEFT_JOIN,"dm_blob.id = fk_data");
  76. $query->addColumn("data","blob_data","dm_blob");
  77. }
  78. function value() {
  79. return $this->_string;
  80. }
  81.  
  82. /*******************************************************
  83. * Conversion Methods
  84. *********************************************************/
  85.  
  86. /**
  87. * Convert this object to a StorableBlob
  88. *
  89. * @return object
  90. * @access public
  91. * @since 6/9/06
  92. */
  93. function asABlob () {
  94. return $this;
  95. }
  96. /**
  97. * Convert this object to a StorableString
  98. *
  99. * @return object
  100. * @access public
  101. * @since 6/9/06
  102. */
  103. function asAString () {
  104. return String::fromString($this->asString());
  105. }
  106. /**
  107. * Convert this object to a StorableShortString
  108. *
  109. * @return object
  110. * @access public
  111. * @since 6/9/06
  112. */
  113. function asAShortString () {
  114. return String::fromString($this->asString());
  115. }
  116. }

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