getTable() public method

Returns the table object, or null if this is disconnected row
public getTable ( ) : Table
return Table
コード例 #1
0
ファイル: Relations.php プロジェクト: bluzphp/framework
 /**
  * findRelation
  *
  * @param  Row $row
  * @param  string $relation
  * @return array
  * @throws Exception\RelationNotFoundException
  */
 public static function findRelation($row, $relation)
 {
     $model = $row->getTable()->getModel();
     /** @var \Bluz\Db\Table $relationTable */
     $relationTable = Relations::getModelClass($relation);
     $relationTable::getInstance();
     if (!($relations = Relations::getRelations($model, $relation))) {
         throw new RelationNotFoundException("Relations between model `{$model}` and `{$relation}` is not defined");
     }
     // check many-to-many relations
     if (sizeof($relations) == 1) {
         $relations = Relations::getRelations($model, current($relations));
     }
     $field = $relations[$model];
     $key = $row->{$field};
     return Relations::findRelations($model, $relation, [$key]);
 }
コード例 #2
0
ファイル: Row.php プロジェクト: 9618211/framework
 /**
  * Set relation
  * @param Row $row
  * @return Row
  */
 public function setRelation(Row $row)
 {
     $modelName = $row->getTable()->getModel();
     $this->relations[$modelName] = [$row];
     return $this;
 }
コード例 #3
0
ファイル: RowTest.php プロジェクト: dezvell/mm.local
 /**
  * @covers Bluz\Db\Row::getTable
  * @expectedException Bluz\Db\Exception\TableNotFoundException
  */
 public function testGetTableException()
 {
     $this->row = new Bluz\Tests\Db\Fixtures\ConcreteRowWithInvalidTable();
     $this->row->getTable();
 }