出于纯粹的好奇心,有人能快速告诉我是否有可能吗?我没有那样实现它,但回头看,我想知道是否可以做到。这是场景:
两个定义成本之间的产品,服务和关系表的表
Product ID | Name 1 | Product A 2 | Product B Service ID | Name 1 | Service A 2 | Service B 3 | Service C Price ID | Cost | Product ID | Service ID 1 | 1 | 1 | 1 2 | 2 | 1 | 3 3 | 3 | 2 | 2 4 | 4 | 2 | 3
因此,如果有表数据对象,则会有:
//$query = obtain a list of all products with services and prices;
//$query = obtain a product and all it's associated services and prices;
$statement = $pdo->prepare($query);
$statement -> execute();
$results = $statement ->fetchAll(PDO::FETCH_CLASS,"Product");