Monday, 15 April 2013

symfony - Doctrine 2 createQueryBuilder with same result -


I have 2 different query builders returning the same results The first QueryBuilder returns the right result Second Quierbilder First Returns the result.

Question: How to apply second query builder to get data from the database, not from memory?

Usage:

/ ** @ Var sectionEnty $ section * / foreign currency ($ subject- & gt; receive communication (as $ section) {/ * * @ War Q & A $ Question * / Forex Currency ($ section-> Go Questions) As the $ question) {// ...}}

In this way I asked QueryBuilders I call:

$ subject- / $ subject = $ this- & gt; Retrieve default profile queries (); / ** @ Var topic ends $ old_subject * / $ old_subject = $ this- & gt; Recover Profile QuestFor User ($ user);

Functions:

  / ** * The database retrieves the default profile queries * * @Ruran Faucet | Subject continuity * @ throw \ theory / ORM \ Non translationist exception * / Retrieve private function Default profile question () {$ queryBuilder = $ this- & gt; CreateQueryBuilder ('s'); $ Query = $ querybuilder - & gt; Select ('s, SC, Q') - & gt; Left zone ('S. Sections', 'SC') - & gt; Left join ('scootization', 'Q', 'with', 'Q.user is NULL') - & gt; Where ('s.type =: TYPE') - & gt; SetParameter ('TYPE', 'Profile') - & gt; GetQuery (); Return $ query- & gt; GetOneOrNullResult (); } / ** * Recovers user's profile queries from the database * * @ Ultimate User Entity $ user * * @ Return faucet. Subject * * Throw \ Principle / ORM \ nonUniqueResultException * / Retrieve Personal FunctionProfile QuestionerUser ($ user) {$ queryBuilder = $ this- & gt; CreateQueryBuilder ('s'); $ Query = $ querybuilder - & gt; Select ('s, SC, Q') - & gt; Left zone ('S. Sections', 'SC') - & gt; Left join ('scootization', 'Q', 'with', 'Q.user =: USER') - & gt; Where ('s.type =: TYPE') - & gt; SetParameter ('USER', $ user) - & gt; Set Parameter ('TYPE', 'Profile') - & gt; GetQuery (); Return $ query- & gt; GetOneOrNullResult (); }  

The problem may be that you are sending mysql, this case Isql will not create a new execution plan and you will get the results of the memory, the one thing I suggested to try you is to select the -> and select (' S, SC, Q ') in - & gt; Select (S. *, SC. ​​*, Q. * ')


No comments:

Post a Comment