Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
一个客户有很多订单。(一对多关系)我想做的是:
$order = Order::find_by_id(3); echo $order->customer;
我如何设置模型才能做到这一点?
建立一对多关系的正确方法是(例如客户 1 <-----> * 订单)
class Customer extends ActiveRecord\Model { static $has_many = array( array('orders') ); } class Order extends ActiveRecord\Model { static $belongs_to = array( array('customer') ); }
这在 php 活动记录文档中并不清楚。