0

How do I get the 'params' from a query object in CakePHP 3?

$response = $this->getTable()->find();
// there are beforeFinds...etc that make this more complex

When I debug the $response, I get this (:

// ...
'(help)' => 'This is a Query object, to get the results execute or iterate it.',
'sql' => 'SELECT .... WHERE ... article_id = :c2',
'params' => [
    ':c0' => [
        [maximum depth reached]
    ],
    ':c1' => [
        [maximum depth reached]
    ],
    ':c2' => [
        [maximum depth reached]
    ]
],
// ...

I'd like to know what the value of :c2 is, but I can't seem to get the params to debug.

I've tried these:

\Cake\Error\Debugger::log($response->params);
\Cake\Error\Debugger::log($response->params());
\Cake\Error\Debugger::log($response['params']);
\Cake\Error\Debugger::log($response->getParams());
\Cake\Error\Debugger::log($response->getQueryParams());

But none work.

Dave
  • 28,833
  • 23
  • 113
  • 183

3 Answers3

0

By increasing the depth of the debug, I was able to see dditional information, including the values of the :c2

\Cake\Error\Debugger::log($response, 'debug', 4); // default depth is 3
Dave
  • 28,833
  • 23
  • 113
  • 183
0

You should be able to get them via $response->valueBinder()->bindings().

Greg Schmidt
  • 5,010
  • 2
  • 14
  • 35
0

You can use __debugInfo() method:

$result = $this->Pages->find()->where(['is_public' => 1]);

dd($result->__debugInfo()['params']);
Dariusz Majchrzak
  • 1,227
  • 2
  • 12
  • 22