0

I have this code on my component.

$results = \Db::select('select * from engegraph_forms_membros where id = ?', [1]);
echo $results; 

but i have this error "Array to string conversion"

Someone can help a newbie ??

Hardik Satasiya
  • 9,547
  • 3
  • 22
  • 40
Erik
  • 3
  • 4
  • Possible duplicate of [Reference - What does this error mean in PHP?](https://stackoverflow.com/questions/12769982/reference-what-does-this-error-mean-in-php) – Pandawan Oct 14 '19 at 20:35

1 Answers1

2

The problem is you are printing array as as string.

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();

you can print result like this or you can use build in debugger function.

$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.

if any doubts please add comments.

Hardik Satasiya
  • 9,547
  • 3
  • 22
  • 40