I need data from two MySQL tables - I wrote a Propel query to retrieve data from my 'search' table. Now, I am trying to retrieve data from my 'item_view' table using
->getItemView()->getPosition() within the view. The search_id (search table primary key) is a foreign key in the item_view table but the item_view_id (item view primary key) is not a foreign key in the search table. Any suggestions for how to retrieve this data? Code below.
<?php foreach ($queries as $query) : ?> <tr> <td><?php echo $query->getTs(); ?></td> <td><?php echo $query->getUser() ? $query->getUser()->getEmail() : ""; ?></td> <td><?php echo $query->getTerm(); ?></td> <td><?php echo $query->getResultCount(); ?></td> <td><?php echo **$query->getItemViews()->getItem()->getPartName()**; ?></td> <td><?php echo **$query->getItemViews()->getPosition()**; ?></td> </tr> <?php endforeach; ?>
Controller: (note: I have no problem retrieving user table data because its foreign key is in the search table.
$c = new Criteria(); $c->addDescendingOrderByColumn(SearchPeer::TS); $this->queries = SearchPeer::doSelect($c);
Is this a case where you cannot retrieve data from a table unless its primary key is the foreign key of the table for which the propel query is formed?
Any solutions are appreciated!