为什么这段代码 $results = \Db::select('select * from engegraph_forms_membros where id = ?', [1]);不工作?
Why this code $results = \Db::select('select * from engegraph_forms_membros where id = ?', [1]); dont work?
我的组件上有这段代码。
$results = \Db::select('select * from engegraph_forms_membros where id = ?', [1]);
echo $results;
但是我有这个错误
"Array to string conversion"
有人可以帮助新手??
问题是您将数组打印为字符串。
returning result of \Db::select
is an array so to print array you can use print_r()
$results = \Db::select('select * from engegraph_forms_membros where id = ?', [1]);
echo '<pre/>'; print_r($result); exit();
您可以像这样打印结果,或者您可以使用内置调试器功能。
$results = \Db::select('select * from engegraph_forms_membros where id = ?', [1]);
dd($result);
// or dump($result);
if you use dump/dd
function you dont need to worry it can print anything. dd [die and dump]
stops php flow to next statements. dump
will continues flow so you can print another values/or/execute next statements if you need.
如有疑问请补充。
我的组件上有这段代码。
$results = \Db::select('select * from engegraph_forms_membros where id = ?', [1]);
echo $results;
但是我有这个错误 "Array to string conversion"
有人可以帮助新手??
问题是您将数组打印为字符串。
returning result of
\Db::select
is an array so to print array you can useprint_r()
$results = \Db::select('select * from engegraph_forms_membros where id = ?', [1]);
echo '<pre/>'; print_r($result); exit();
您可以像这样打印结果,或者您可以使用内置调试器功能。
$results = \Db::select('select * from engegraph_forms_membros where id = ?', [1]);
dd($result);
// or dump($result);
if you use
dump/dd
function you dont need to worry it can print anything.dd [die and dump]
stops php flow to next statements.dump
will continues flow so you can print another values/or/execute next statements if you need.
如有疑问请补充。