嗨伙计们
我的对象有以下架构:
Product:
columns:
name: { type: string(255) }
Basket:
columns:
current_status: { type: integer }
relations:
Products: { class: Product, refClass: BasketProducts, onDelete: CASCADE }
BasketProducts:
columns:
product_id: { type: integer, primary: true }
basket_id: { type: integer, primary: true }
quantity: { type: integer(4) }
relations:
Product: { local: product_id, onDelete: CASCADE }
Basket: { local: basket_id, onDelete: CASCADE }
现在在前端,我尝试向用户展示购物篮,通过
foreach($basket->getProducts() as $product) {
echo $product->getId();
echo $product->getName();
}
现在的问题是,我如何从 BasketProducts 访问数量字段?