예제 #1
0
 /**
  * This method checks if the setJoin() method is working correctly
  *
  * check if stuff like MAX(id), LOWER(question), etc. will be converted to
  *     MAX(TABLE_QUESTION.id), LOWER(TABLE_QUESTION.question)
  * this is done for preventing ambiguous column names, that's why it only applies
  * in joined queries ...
  */
 function test_setJoin()
 {
     $theQuestion = 'Why does this not work?';
     $theAnswer = 'I dont know!';
     $question = new MDB_QT(TABLE_QUESTION);
     $newQuest = array(TABLE_QUESTION => $theQuestion);
     $qid = $question->add($newQuest);
     $this->assertTrue($qid != false);
     $answer = new MDB_QT(TABLE_ANSWER);
     $newAnswer = array(TABLE_QUESTION . '_id' => $qid, TABLE_ANSWER => $theAnswer);
     $aid = $answer->add($newAnswer);
     $this->assertTrue($aid != false);
     $joinOn = TABLE_QUESTION . '.id=' . TABLE_ANSWER . '.question_id';
     $question->setJoin(TABLE_ANSWER, $joinOn);
     if (DB_TYPE == 'ibase') {
         $expected = array('t_answer_id' => $aid, 't_answer_answer' => $theAnswer, 't_answer_question_id' => $qid, 'id' => $qid, 'question' => $theQuestion);
     } else {
         $expected = array('_answer_id' => $aid, '_answer_answer' => $theAnswer, '_answer_question_id' => $qid, 'id' => $qid, 'question' => $theQuestion);
     }
     $this->assertEqual($expected, $question->get($qid));
 }