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

后端 未结 2 1936
遥遥无期
遥遥无期 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.

提交回复
热议问题