Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/275.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Symfony1 基于关系的外场分配_Symfony1_Symfony 1.4 - Fatal编程技术网

Symfony1 基于关系的外场分配

Symfony1 基于关系的外场分配,symfony1,symfony-1.4,Symfony1,Symfony 1.4,我有以下模式: catalogue: actAs: [Timestampable, Sortable] columns: id: type: integer(2) primary: true autoincrement: true catalogue_name: type: varchar(255) relations: catalogue: class: Product ref

我有以下模式:

 catalogue:
  actAs: [Timestampable, Sortable]
  columns:
    id:
      type: integer(2)
      primary: true
      autoincrement: true
    catalogue_name:
      type: varchar(255)
  relations:
    catalogue:
        class: Product
        refClass: ProductPrices
        local: catalogue_id
        foreign: product_id
ProductPrices:
  actAs: [Timestampable]
  columns:
    product_id: { type: integer(4)}
    catalogue_id: { type: integer(2) }
    price: { type:real }
  relations:
    Product:    { local: product_id, foreign: id }
    catalogue:  { local: catalogue_id, foreign: id }
  indexes:
    unique_price:  { fields: [catalogue_id, product_id], type: unique }
Product:
  actAs:             [Timestampable]
  columns:
    id:
      type: integer(4)
      primary: true
      autoincrement: true
    product_code:
      type: varchar(10)
    product_desc:
      type: varchar(255)
    created_at:
      type: timestamp
  relations:
    catalogue:
        class: catalogue
        refClass: ProductPrices
        local: product_id
        foreign: catalogue_id
现在这是
产品
目录

我想做的是,在HTML表格中显示每个目录及其产品

我已经创建了一个概要和一个条令查询:

public static function getPricingTable()
{
    $q = Doctrine_Query::create()
      ->from('ProductPrices p');

   return $q->execute();
}
现在,我唯一的问题是显示目录和产品,即

目录1

* Product 1     
* Product 2        
* Product 3
目录2

* Product 1

感谢所有帮助

如果您想获得目录的所有产品,只需使用目录实例的getProduct()方法即可

例如,如果要获取所有产品的所有目录:

$catalogues = Doctrine::getTable('catalogue')->findAll();

foreach($catalogues as $catalogue){
   //$catalogue is an instance
   echo $catalogue->getCatalogueName()

   //you've got all products from a catalogue instance    
   foreach($catalogue->getProduct() as $product){
       echo $product->getProductDesc();
   }
}