Note that there are some explanatory texts on larger screens.

plurals
  1. POLaravel 4 - paginate ignore distinct in Fluent
    primarykey
    data
    text
    <p>I make fluent request with distinct and paginate. My problem is that the paginate request is execute before disinct request</p> <p>My Fluent request :</p> <pre><code>$candidates = DB::table('candidates') -&gt;select('candidates.*') -&gt;distinct() -&gt;join('candidate_region', 'candidates.id', '=', 'candidate_region.candidate_id') -&gt;join('candidate_job', 'candidates.id', '=', 'candidate_job.candidate_id') -&gt;whereIn('candidate_region.region_id', $inputs['region']) -&gt;whereIn('candidate_job.job_id', $inputs['job']) -&gt;where('imavailable', '1') -&gt;where('dateDisponible', '&lt;=', $inputs['availableDate']) -&gt;paginate(15); </code></pre> <p>I test my request with DB::getQueryLog()</p> <pre><code>$query = DB::getQueryLog($candidates); </code></pre> <p>$query show that paginate request (with count) for make number page :</p> <pre><code>5 =&gt; array (size=3) 'query' =&gt; string 'select count(*) as aggregate from `candidates` inner join `candidate_region` on `candidates`.`id` = `candidate_region`.`candidate_id` inner join `candidate_job` on `candidates`.`id` = `candidate_job`.`candidate_id` where `candidate_region`.`region_id` in (?, ?, ?, ?, ?) and `candidate_job`.`job_id` in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) and `imavailable` = ? and `dateDisponible` &lt;= ?' (length=396) </code></pre> <p>And my request with distinct is execute after paginate :</p> <pre><code>6 =&gt; array (size=3) 'query' =&gt; string 'select distinct `candidates`.* from `candidates` inner join `candidate_region` on `candidates`.`id` = `candidate_region`.`candidate_id` inner join `candidate_job` on `candidates`.`id` = `candidate_job`.`candidate_id` where `candidate_region`.`region_id` in (?, ?, ?, ?, ?) and `candidate_job`.`job_id` in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) and `imavailable` = ? and `dateDisponible` &lt;= ? limit 15 offset 15' (length=417) </code></pre> <p>How to do for execute request distinct before the paginate ?</p> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload