예제 #1
0
 public function testRelationJoin()
 {
     $this->initConnection();
     $select = Authors::select();
     $select->relationJoin('warehouse', array(), array('warehouse.amount', 'bookName' => 'books.name'));
     $result = $select->fetchAll();
     $result = $this->inline($result);
     $expected = "array(0=>array('author_id'=>'1','first_name'=>'Matthew','last_name'=>'Normani','birth_date'=>'1982-06-06','amount'=>'2','bookName'=>'LearningPHP,MySQL&JavaScript:WithjQuery,CSS&HTML5',),1=>array('author_id'=>'1','first_name'=>'Matthew','last_name'=>'Normani','birth_date'=>'1982-06-06','amount'=>'10','bookName'=>'We\\'reAllDamaged',),2=>array('author_id'=>'1','first_name'=>'Matthew','last_name'=>'Normani','birth_date'=>'1982-06-06','amount'=>'11','bookName'=>'JavaScriptandJQuery:InteractiveFront-EndWebDevelopment',),3=>array('author_id'=>'2','first_name'=>'Roji','last_name'=>'Normani','birth_date'=>'1977-03-15','amount'=>'10','bookName'=>'We\\'reAllDamaged',),4=>array('author_id'=>'3','first_name'=>'Anna','last_name'=>'Kowalska','birth_date'=>'1999-05-15','amount'=>'11','bookName'=>'JavaScriptandJQuery:InteractiveFront-EndWebDevelopment',),)";
     $this->assertEquals($expected, $result);
     // not clear relation
     $select = AuthorsAddresses::select();
     $select->relationJoin('$authors_addresses_type:dictionary_values', array('dictionary_values' => 'dtype'), array('type' => 'dtype.value'));
     $select->relationJoin('$authors_addresses_country:dictionary_values', array('dictionary_values' => 'dcountry'), array('country' => 'dcountry.value'));
     $select->relationJoin('$authors_addresses_street_prefix:dictionary_values', array('dictionary_values' => 'dprefix'), array('street_prefix' => 'dprefix.value'));
     $result = $select->fetchAll();
     $result = $this->inline($result);
     $expected = "array(0=>array('author_id'=>'1','type'=>'correspondence','street_prefix'=>'Road','street'=>'1ChapelHill','country'=>'Poland',),1=>array('author_id'=>'2','type'=>'correspondence','street_prefix'=>'Road','street'=>'56/45ApelMill','country'=>'Poland',),2=>array('author_id'=>'3','type'=>'business','street_prefix'=>'Road','street'=>'45/23Apply','country'=>'USA',),)";
     $this->assertEquals($expected, $result);
 }
예제 #2
0
 public function testPkDefinition()
 {
     $result = AuthorsAddresses::pkDefinition();
     $result = $this->inline($result);
     $expected = "array(0=>'author_id',1=>'type',)";
     $this->assertEquals($expected, $result);
     $result = BooksOpinions::pkDefinition();
     $result = $this->inline($result);
     $expected = "array(0=>'opinion_id',)";
     $this->assertEquals($expected, $result);
 }