Source for file PS_DB.inc

Documentation is available at PS_DB.inc

  1. <?php
  2. /**
  3. * PrepStep Module Database API.
  4. * This file is part of CompInaBox.
  5. * @copyright Copyright 2001-2005. Eric D. Nielsen, All rights reserverd.
  6. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  7. * @author Eric D. Nielsen <nielsene@alum.mit.edu>
  8. *
  9. * @package Database
  10. */
  11.  
  12. /**
  13. * PrepStep Module Database API.
  14. * This class presents a OOP interface to the common
  15. * queries needed by PrepStep functionality.
  16. * @todo Further tease out SQL to the {@link PhraseBook}.
  17. * @package Database
  18. */
  19. class PS_DB extends CIB_DB
  20. {
  21. /**
  22. * PrepStep DB Constructor.
  23. * Simply call the parent constructor.
  24. * @todo Add a check after connecting to make sure its a central DB and
  25. * not a per-comp DB
  26. * @access public
  27. *
  28. * @param string $dbname what database do you want to connect to
  29. * @param string $user as what user
  30. * @param string $password which what password
  31. */
  32. function PS_DB($dbname, $user, $pass)
  33. {
  34. DB::DB($dbname, $user, $pass);
  35. }
  36. /**
  37. * Return the list of canonical levels
  38. * Returns a list of levels normally used by competitions of a given
  39. * type.
  40. * @param array $compTypes a list of selected "types" for this competition
  41. * normally a only one type is selected, at present only the last item
  42. * in the list is used. Sample types are "US Collegiate", "USA Dance, Inc",
  43. * "NDCA", etc
  44. * @returns array structured array listing the levels in track/index order
  45. * @todo handle multi-type competitions better
  46. * @access public
  47. */
  48. function getCanLevels($compTypes)
  49. {
  50. $useType=$compTypes[count($compTypes)-1];
  51. $query =<<<END_QUERY
  52. SELECT levelname, track, displayorder, eventfullprefix, eventshortprefix
  53. FROM cannonical_levels WHERE comptype='$useType' ORDER BY track, displayorder;
  54. END_QUERY; $result = $this->query($query);
  55. $num = $result->numrows();
  56. for ($i=0;$i<$num;$i++)
  57. {
  58. list($level,$track,$order,$full,$short) = $result->getRowAt($i);
  59. $levels[$track][$order]=array("Name"=>$level,
  60. "Short"=>$short,
  61. "Full"=>$full);
  62. }
  63. return $levels;
  64. }
  65.  
  66.  
  67. /**
  68. * Return the list of canonical styles
  69. * Returns a list of levels normally used by competitions of a given
  70. * type.
  71. * @param array $compTypes a list of selected "types" for this competition
  72. * normally a only one type is selected, at present only the last item
  73. * in the list is used. Sample types are "US Collegiate", "USA Dance, Inc",
  74. * "NDCA", etc
  75. * @returns array structured array listing the styles in order
  76. * @todo handle multi-type competitions better
  77. * @access public
  78. */
  79. function getCanStyles($compTypes)
  80. {
  81. $useType=$compTypes[count($compTypes)-1];
  82. $query =<<<END_QUERY
  83. SELECT stylename, displayorder, eventfullprefix,
  84. eventshortprefix, styleabbreviation
  85. FROM cannonical_styles WHERE comptype='$useType' ORDER BY displayorder;
  86. END_QUERY; $result = $this->query($query);
  87. $num = $result->numrows();
  88. for ($i=0;$i<$num;$i++)
  89. {
  90. list($style,$order,$full,$short,$abbrev) = $result->getRowAt($i);
  91. $styles[$order]=array("Name"=>$style,
  92. "Short"=>$short,
  93. "Full"=>$full,
  94. "Abbrev"=>$abbrev);
  95. }
  96. return $styles;
  97. }
  98.  
  99.  
  100. }
  101. ?>

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