This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use the new forum.
Home » plugins » General plug-ins » where clause is not working as expected
where clause is not working as expected [message #102554] Thu, 15 July 2010 20:26 Go to next message
cgithinji  is currently offline cgithinji
Messages: 4
Registered: June 2010
Junior Member
Hi guys,

i am working with Doctrine and in a module examapprove action i have

public function executeIndex(sfWebRequest $request)
{
$this->examapproves = Doctrine::getTable('examapprove')->getExamsApproved();


$this->pager = new sfDoctrinePager('examapprove',sfConfig::get('app_max_exams_o n_examapprove_index'));
$this->pager->getQuery()->from('examapprove e');
$this->pager->setPage($this->getRequestParameter('page',1));
$this->pager->init();

}


the getExamsApproved() method is defined in ExamApproveTable.class.php


public function getExamsApproved() {

$q = $this->createQuery('c')
->where('c.is_approved = ?', 1);
return $q->execute();

}



The problem is that the whole table's data us displayed instead of only those whose is_approved field is true. where could i have gone wrong?

please help me guys
Re: where clause is not working as expected [message #102594 is a reply to message #102554 ] Fri, 16 July 2010 14:26 Go to previous messageGo to next message
trontank  is currently offline trontank
Messages: 179
Registered: July 2008
Location: Germany
Senior Member
sorry, double post.

[Updated on: Fri, 16 July 2010 14:30]

Re: where clause is not working as expected [message #102595 is a reply to message #102554 ] Fri, 16 July 2010 14:30 Go to previous message
trontank  is currently offline trontank
Messages: 179
Registered: July 2008
Location: Germany
Senior Member
I think this should work:

# ExamApproveTable.class.php
public function getExamsApprovedQuery() 
{
  return $this->createQuery('c')->where('c.is_approved = ?', 1);
}


# in your action:
public function executeIndex(sfWebRequest $request)
{
  $pager = new sfDoctrinePager('ExamApprove', sfConfig::get('app_max_exams_o n_examapprove_index'));
  $pager->setQuery(Doctrine::getTable('ExamApprove')->getExamsApprovedQuery());
  $pager->setPage($this->getRequestParameter('page',1));
  $pager->init();
}

[Updated on: Fri, 16 July 2010 14:31]

Previous Topic:[SOLVED] prestaForumConnectorPlugin synch error
Next Topic:Task doctrine:generate is not defined
Goto Forum:
  

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software