How do I view the parameters in a query?

后端 未结 5 1377
遇见更好的自我
遇见更好的自我 2021-02-08 04:09

In order to debug my code I would like to see the explicit sql query that is executed.

I create the query with createQueryBuilder, and the most explicit thi

5条回答
  •  再見小時候
    2021-02-08 04:34

    You can access the parameters used by the placeholders using $query->getParameters(), so you could debug your query using:

    $query = $qb->getQuery();
    print_r(array(
        'sql'        => $query->getSQL(),
        'parameters' => $query->getParameters(),
    ));
    

提交回复
热议问题