Source for file AndSearch.class.php

Documentation is available at AndSearch.class.php

  1. <?php
  2.  
  3. require_once HARMONI."dataManager/search/MultipleCriteriaSearch.abstract.php";
  4.  
  5. /**
  6. * Takes multiple other criteria and AND's them together in the SQL query.
  7. *
  8. * @package harmoni.datamanager.search
  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: AndSearch.class.php,v 1.6 2007/09/04 20:25:32 adamfranco Exp $
  14. */
  15. class AndSearch extends MultipleCriteriaSearch {
  16. function returnSearchString() {
  17. $parts = array();
  18. // we will return the first criteria now, and then work through the rest in turn later with post-processing.
  19. // this is to avoid a problem with multiple AND-searches where the criteria may all be true for a given record, but not true for one single row returned describing a part of the record.
  20. /*foreach (array_keys($this->_criteria) as $key) {
  21. if ($string = $this->_criteria[$key]->returnSearchString()) $parts[] = $string;
  22. }*/
  23. if (!count($this->_criteria)) return null;
  24. $keys = array_keys($this->_criteria);
  25. return $this->_criteria[$keys[0]]->returnSearchString();
  26. // return "(" . implode(" AND ",$parts) . ")";
  27. }
  28. function postProcess($ids) {
  29. // let's go through index 1-n of the criteria and keep narrowing down our lsit of ids.
  30. $rm = Services::getService("RecordManager");
  31.  
  32. $keys = array_keys($this->_criteria);
  33. for($i=1; $i < count($keys); $i++) {
  34. $ids = $rm->getRecordIDsBySearch($this->_criteria[$keys[$i]], $ids);
  35. }
  36. return $ids;
  37. }
  38. }
  39.  
  40. ?>

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