search

Home  >  Q&A  >  body text

Lithium: We can see the query executed as shown in CakePHP

Do you know of any way to display queries executed in Lithium like in CakePHP? It might be easier for me to find the implementation. The executed query is displayed at the bottom of the page.

![Screenshot]http://imgur.com/ffNfQ

After receiving the answer, I added the code to my controller:

Volumes::applyFilter('find', function($self, $params, $chain) {
      echo '<pre>===== self ======<br>';
      var_dump($self);
      echo '===== params ======<br>';
      var_dump($params);
      echo '===== chain ======<br>';
      var_dump($chain);
      echo '</pre>';
      $next = $chain->next($self, $params, $chain);

      return $next;

});

It gives me the output of all var_dump regarding self and params but I need to execute the SQL query.

Please see the screenshot http://imgur.com/ffNfQ

P粉757640504P粉757640504246 days ago461

reply all(2)I'll reply

  • P粉052724364

    P粉0527243642024-03-27 11:04:16

    As @Nils suggested, you can leverage Lithium filters and write a simple query logger.
    Imade one here. It logs the read query to a file in the product environment.
    You should be able to customize and add filters to the create, update, and delete actions to suit your needs.

    If you are looking for an out-of-the-box solution, such as Cake's debug toolbar, check out the li3_perf project: https://github.com/tmaiaroto/li3_perf

    reply
    0
  • P粉322918729

    P粉3229187292024-03-27 10:40:33

    Following all the suggestions from Nils and Mehdi, I created a new plugin that only displays query results and not vardump or print_r() of queries executed in Lithium using MongoDB.

    Now it's really easier for me to find what it's doing.

    You can view the project on Github:

    https://github.com/nilamdoc/li3_show

    reply
    0
  • Cancelreply