symfony1 - Automatically getting a query instead of a result set in Symfony -
In my schema, users are related to their queries.
I want to show all the questions I asked about by a user.
I also want this page to be endorsed using the sfDoctrinePager
, for which the Doctrine_Query
parameter is required.
I know that to get all the questions from my_user, $ my_user-> Getquestions ()
can call, but is there any way to get queries to get all of these questions? $ my_user-> GetQuestionsQuery ()
for example.
Or do I have to implement myself?
It seems that you have to create an Doctrine_Query
object manually:
$ query = new Doctrine:: GetTable ('question') - & gt; CreateQuery ('q') - & gt; Where ('q.uid =?', $ My_user- & gt; getId ());
And then pass it on the pager:
$ this-> Pager = new sfDoctrinePager ('question', $ max_per_page); $ This- & gt; Pager-> SetQuery ($ query); $ This- & gt; Pager-> SetPage ($ cur_page); $ This- & gt; Pager-> Init ();
Comments
Post a Comment