Hello,
I have a ProductCategory class with a method:
public function getActiveProductsQuery()
{
$q = Doctrine_Query::create()
->from('Product p, ProductCategory pc, ProductToProductCategory ptc')
->where('pc.slug = ?', $this->getId())
->andWhere('pc.id = ptc.product_category_id')
->andWhere('p.id = ptc.product_id');
return Doctrine_Core::getTable('Product')->addActiveProductsQuery($q);
}
ProductTable.class has function:
public function addActiveProductsQuery(Doctrine_Query $q = null)
{
if (is_null($q))
{
$q = Doctrine_Query::create()
->from('Product p');
}
return $q;
}
product_categoryActions has the SHOW of:
public function executeShow(sfWebRequest $request)
{
$this->foo = $request->getParameterHolder();
$this->product_category = $this->getRoute()->getObject();
$this->pager = new sfDoctrinePager(
'Product',
sfConfig::get('app_max_products_on_category')
);
$this->pager->setQuery($this->product_category->getActiveProductsQuery());
$this->pager->setPage($request->getParameter('page', 1));
$this->pager->init();
}
and showSuccess has:
<?php echo count($pager) ?></strong> products in this category
which shows a count of '0'
Routing:
product_category:
url: product_category/:slug
class: sfDoctrineRoute
param: { module: product_category, action: show }
options: { model: ProductCategory, type: object }
Table structure is:
product: id, name, description, etc...
product_category: is, name, graphic, etc...
product_to_product_category: product_id, product_category_id
My issue is that I am not getting back any results and the count is '0'
If I change $this->getId() to $this->getSlug() in: getActiveProductsQuery(), I
get an error:
'"ProductCategory" with an alias of "pc" in your query does not reference the
parent component it is related to.'
I have tried the sql out in phpMyAdmin and it works as expected, but not in
symfony.
Any suggestions as to what I am doing wrong would be great.
Thanks.
--
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