got a select that does 10 query in doctrine (Symfony)

后端 未结 2 1903
遥遥无期
遥遥无期 2021-01-29 09:10

I got a big query that execute 11 query, I didnt know where the problem is, but found the problem was in a select a did for geo loc, anyone has an idea how to correct that?

相关标签:
2条回答
  • 2021-01-29 09:41

    I would change all where by whereIn like:

    if($userid){
        $q->andWhereIn('a.userid', $userid);
    }
    
    if($catID){
        $q->andWhereIn('ca.categorie_id', $catID);
    }
    

    I think this happens because when you're using the results in the view the paginator cant fetch all records in a row, so for each item has to do the query to get all fields.

    0 讨论(0)
  • 2021-01-29 09:59

    I am really not sure why but here what was the problem:

    I used select('a.latitude')

    when I should have used...

    select('a.*')

    0 讨论(0)
提交回复
热议问题