Source for file Competitor.inc

Documentation is available at Competitor.inc

  1. <?php
  2. /**
  3. * Competitor Class.
  4. *
  5. * A competitor is a subtype of {@link Person} that
  6. * knows about finding the partners of a given person.
  7. *
  8. * This file is part of CompInaBox.
  9. * @copyright Copyright 2001-2005. Eric D. Nielsen, All rights reserverd.
  10. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  11. * @author Eric D. Nielsen <nielsene@alum.mit.edu>
  12. *
  13. * @package ObjectRelationalMappingLayer
  14. */
  15.  
  16. /**
  17. * Competitor
  18. *
  19. * Competitors are a subtype of {@link Person} that
  20. * knows how to find the partners of the person.
  21. * @package ObjectRelationalMappingLayer
  22. * @access public
  23. */
  24. class Competitor extends Person
  25. {
  26. function Competitor($db=0, $id=0)
  27. {
  28. Person::Person($db,$id);
  29. }
  30. /**
  31. * Returns the peopleid's of this Competitor's partners
  32. *
  33. * Allows querying by role "lead" or "follow" or both
  34. * via the "*"/default. Returns the list of peopleid's from
  35. * the database.
  36. * @param string $role which role partner's to find, defaults to
  37. * all roles. Enter "lead" to get partner's leading this
  38. * Competitor. Enter "follow" to get partner's following this
  39. * Competitor
  40. * @return array list of peopleid meeting the requested criteria
  41. */
  42. function getPartners($role="")
  43. {
  44. $db = $this->db;
  45. $temp = array();
  46. $queryID= $this->getID();
  47.  
  48. $isFollow = (($role == "follow") ? TRUE : FALSE);
  49. if (!$isFollow)
  50. {
  51. $query = "SELECT leader FROM COUPLES where follower=$queryID;";
  52. $result = $db->query($query);
  53. $numLeads = $result->numRows();
  54. for ($i=0;$i<$numLeads;$i++)
  55. {
  56. $lead = $result->getRowAt($i);
  57. array_push($temp,$lead[0]);
  58. }
  59. }
  60. $isLead = (($role == "lead") ? TRUE : FALSE);
  61. if (!$isLead)
  62. {
  63. $query = "SELECT follower FROM COUPLES where leader=$queryID;";
  64. $result = $this->db->query($query);
  65. $numFollowss = $result->numRows();
  66. for ($i=0;$i<$numFollowss;$i++)
  67. {
  68. $follow = $result->getRowAt($i);
  69. array_push($temp,$follow[0]);
  70. }
  71. }
  72. return $temp;
  73. }
  74. }
  75. ?>

Documentation generated on Tue, 25 Apr 2006 13:00:25 -0400 by phpDocumentor 1.3.0RC3