I get table -
$data = Doctrine::getTable('product_catalog')->findAll();
开发者_开发问答
this table (product_catalog) i link table. has 2 columns with foreign keys.
how i can check if $data
has a relation?
Try $data->hasRelation('RelationName')
which will check for the existence of the related object on your foreign key. Replace RelationName
with the real name of your relation.
I succeeded in getting relation from table:
$data = ORM::getTable($modelName)->findAll(); - get the table.
$relations = $data->getTable()->getRelations(); - >get to relation
foreach($relations as $key=>$row)
{
echo "<pre>"; var_dump($key); echo "</pre>";
}
die();
This will print the table relation on the screen.
This solution works with Doctrine 2:
$query = $this->entityManager->createQuery(YOUR_DQL_QUERY);
$query->setHint(Query::HINT_INCLUDE_META_COLUMNS, true);
$query->getArrayResult();
精彩评论