如何从CakePHP 3的查询对象获取参数 [英] How to get params from query object in CakePHP 3
本文介绍了如何从CakePHP 3的查询对象获取参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何从CakePHP 3中的查询对象获取参数?
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
当我调试时 $ response
,我得到这个(:
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]
]
],
// ...
我想知道:c2
的值是,但是我似乎无法获取 params
进行调试。
I'd like to know what the value of :c2
is, but I can't seem to get the params
to debug.
我已经尝试过这些:
\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());
但是没有用。
推荐答案
您可以使用 __ debugInfo()
方法:
$result = $this->Pages->find()->where(['is_public' => 1]);
dd($result->__debugInfo()['params']);
这篇关于如何从CakePHP 3的查询对象获取参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文