Source for file SearchEntryIterator.class.php

Documentation is available at SearchEntryIterator.class.php

  1. <?php
  2. /**
  3. * @since 3/1/06
  4. * @package harmoni.osid_v2.logging
  5. *
  6. * @copyright Copyright &copy; 2005, Middlebury College
  7. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  8. *
  9. * @version $Id: SearchEntryIterator.class.php,v 1.4 2007/09/04 20:25:43 adamfranco Exp $
  10. */
  11.  
  12. require_once(dirname(__FILE__)."/HarmoniEntryIterator.class.php");
  13. require_once(dirname(__FILE__)."/HarmoniEntry.class.php");
  14.  
  15. /**
  16. * EntryIterator provides access to these objects sequentially, one at a time.
  17. * The purpose of all Iterators is to to offer a way for OSID methods to
  18. * return multiple values of a common type and not use an array. Returning an
  19. * array may not be appropriate if the number of values returned is large or
  20. * is fetched remotely. Iterators do not allow access to values by index,
  21. * rather you must access values in sequence. Similarly, there is no way to go
  22. * backwards through the sequence unless you place the values in a data
  23. * structure, such as an array, that allows for access by index.
  24. *
  25. * @since 3/1/06
  26. * @package harmoni.osid_v2.logging
  27. *
  28. * @copyright Copyright &copy; 2005, Middlebury College
  29. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  30. *
  31. * @version $Id: SearchEntryIterator.class.php,v 1.4 2007/09/04 20:25:43 adamfranco Exp $
  32. */
  33. class SearchEntryIterator
  34. extends HarmoniEntryIterator
  35. {
  36. /**
  37. * Constructor
  38. *
  39. * @param string $logName
  40. * @param array $searchCriteria
  41. * @param object Type $formatType
  42. * @param object Type $priorityType
  43. * @return object
  44. * @access public
  45. * @since 3/1/06
  46. */
  47. function SearchEntryIterator ( $logName, $searchCriteria, $formatType, $priorityType, $dbIndex ) {
  48. $this->_startDate =$searchCriteria['start'];
  49. $this->_endDate =$searchCriteria['end'];
  50. if (isset($searchCriteria['agent_id']))
  51. $this->_agentId = $searchCriteria['agent_id'];
  52. else
  53. $this->_agentId = false;
  54. if (isset($searchCriteria['node_id']))
  55. $this->_nodeId = $searchCriteria['node_id'];
  56. else
  57. $this->_nodeId = false;
  58. if (isset($searchCriteria['category']))
  59. $this->_category = $searchCriteria['category'];
  60. else
  61. $this->_category = false;
  62. $this->HarmoniEntryIterator($logName, $formatType, $priorityType, $dbIndex);
  63. }
  64. /**
  65. * Add where clauses to the query
  66. *
  67. * @param object SelectQuery $query
  68. * @return void
  69. * @access public
  70. * @since 3/9/06
  71. */
  72. function addWhereClauses ( $query ) {
  73. $dbc = Services::getService("DatabaseManager");
  74. if ($this->_agentId) {
  75. $query->addTable("log_agent", INNER_JOIN, "log_entry.id = search_agent.fk_entry", "search_agent");
  76. $query->addWhere("search_agent.fk_agent = '".addslashes($this->_agentId->getIdString())."'");
  77. }
  78. if ($this->_nodeId) {
  79. $query->addTable("log_node", INNER_JOIN, "log_entry.id = search_node.fk_entry", "search_node");
  80. $query->addWhere("search_node.fk_node = '".addslashes($this->_nodeId->getIdString())."'");
  81. }
  82. if ($this->_category) {
  83. $query->addWhere("log_entry.category = '".addslashes($this->_category)."'");
  84. }
  85. $query->addWhere("log_entry.timestamp > ".$dbc->toDBDate($this->_startDate, $this->_dbIndex));
  86. $query->addWhere("log_entry.timestamp < ".$dbc->toDBDate($this->_endDate, $this->_dbIndex));
  87. parent::addWhereClauses($query);
  88. }
  89. }
  90.  
  91. ?>

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