relation() public static method

Checking that relation between tables exists
public static relation ( string $local, string $foreign ) : boolean
$local string local table
$foreign string related table
return boolean relation exists
Exemplo n.º 1
0
 /**
  * Use relation to table
  * @param string $table Table name
  * @return \Lazer\Classes\Core_Relation
  */
 public function with($table)
 {
     Validate::relation($this->tables['local'], $table);
     $this->setTable('foreign', $table);
     $this->setRelationType(Config::table($this->tables['local'])->relations($this->tables['foreign'])->type);
     $this->setKey('local', Config::table($this->tables['local'])->relations($this->tables['foreign'])->keys->local);
     $this->setKey('foreign', Config::table($this->tables['local'])->relations($this->tables['foreign'])->keys->foreign);
     return $this;
 }
Exemplo n.º 2
0
 /**
  * @covers Lazer\Classes\Helpers\Validate::relation
  * @expectedException Lazer\Classes\LazerException
  */
 public function testRelationNotExists()
 {
     $this->object->relation('users', 'tags');
 }