我正在学习symfony框架。现在我以这种方式从mysql表orders
获取所有数据:
$c = new Criteria(); $this->items = OrdersPeer::doSelect($c);
我还有其他表orders_complete
。如何从表orders
和orders_complete
获取数据?
我想做这个查询:
SELECT * FROM orders, orders_complete WHERE orders.id = orders_complete.id
答案 0 :(得分:0)
如果我没记错的话,你应该能够做到这样的事情:
$c = new Criteria();
$orders = OrdersPeer::doSelect($c);
foreach($orders as $order) {
$complete = $order->getOrderCompletes();
// do something with $order and $complete ...
}
这规定您已在模式文件中定义了两个表关系... 请检查有关此问题的推进文档:http://propelorm.org/documentation/04-relationships.html#using-relationships-in-a-query