Annotation of db/prgsrc/drupal/modules/chgk_db/classes/DbDatabase.class.php, revision 1.2

1.1       roma7       1: <?php
                      2: 
                      3: class DbDatabase  {
                      4:   const QUESTION_TABLE='Questions';
                      5:   const TOURNAMENT_TABLE='Tournaments';
                      6: 
                      7:   public function getTournament($id) {
1.2     ! roma7       8:       if (is_numeric($id)) {
        !             9:           return $this->getTournamentByDatabaseId($id);
        !            10:       } else {
        !            11:           return $this->getTournamentByTextId($id);
        !            12:       }
        !            13:   }
        !            14: 
        !            15:   public function getTournamentByDatabaseId($id){
        !            16:     $sql = sprintf ("SELECT * FROM %s t
        !            17:       WHERE t.Id = '%d'", self::TOURNAMENT_TABLE, $id);
        !            18:     $res = db_query($sql);
        !            19:     return db_fetch_object($res);
        !            20:   }
        !            21:   public function getTournamentByTextId($id){
1.1       roma7      22:     if (!preg_match('/\./', $id)) {
                     23:       $id .= '.txt';
                     24:     }
                     25: 
1.2     ! roma7      26:     $sql = sprintf ("SELECT * FROM %s t
1.1       roma7      27:       WHERE t.FileName = '%s'", self::TOURNAMENT_TABLE, $id);
1.2     ! roma7      28:     $res = db_query($sql);
1.1       roma7      29:     return db_fetch_object($res);
                     30:   }
                     31:   public function getQuestionsRes($id) {
                     32:     $sql = sprintf("SELECT * FROM {%s} WHERE ParentId=%d", self::QUESTION_TABLE, $id);
                     33:     return db_query($sql);
                     34:   }
1.2     ! roma7      35: 
        !            36:   public function getToursRes($id) {
        !            37:     $sql = sprintf("SELECT * FROM {%s} WHERE ParentId=%d", self::TOURNAMENT_TABLE, $id);
        !            38:     return db_query($sql);
        !            39:   }
1.1       roma7      40:   
                     41:   public function fetch_row($res) {
                     42:     return db_fetch_object($res);
                     43:   }
                     44: }
                     45: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>