hello, i have this problem with looping through my query.

my yaml is like so

Category:
  actAs:
    NestedSet:
      hasManyRoots: true
      rootColumnName: root_id
  columns:
    name: { type: string(255), notnull: true, unique: true }

Product:
  columns:
    category_id: { type: integer, notnull: true }
    name: { type: string(255), notnull: true }
    description: { type: clob, notnull: true }
    price: { type: decimal, scale: 2 }
    quantity: { type: string(255), notnull: true }
    image: { type: string(255) }
    date: { type: date, notnull: true }
    last_update: { type: date, notnull: true }
  relations:
    Category:
      local: category_id
      foreign: id
      type: one
      foreignType: many
      onDelete: cascade




i have this function on the model that follows instructions from
doctrine manual on how to retrieve nested set tree with related data

 public function productCategories($catName) {

        $q = Doctrine_Query::create()
                ->select('c.name, p.name, p.price, p.image')
                ->from('Category c')
                ->leftJoin('c.Product p')
                ->where('c.name = ?', $catName);


        $treeObject = Doctrine_Core::getTable('Category')->getTree();
        $treeObject->setBaseQuery($q);
        $tree = $treeObject->fetchTree();

        return $tree;

    }




i retrieve it from the controller and pass an attribute to the method.

 $this->products = Doctrine_Core::getTable('Category')
                ->productCategories($request->getAttribute('node'));



however, when i try to loop the object products in the view, it gives
me the following error

Warning: Invalid argument supplied for foreach()

code for view

<?php foreach ($products as $product): ?>

<?php echo $product->getName() ?>

<?php endforeach;?>




any ideas please

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to