Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fat free framework find and cast

I am familiarising myself with the Fat Free Framework. I am trying to query a database and return the result in json format.

$user=new DB\SQL\Mapper($db,'wilt');
 $filter = array();
    $option = array(
            'order' => 'created DESC',
            'limit' => 7
    );
    $list=$user->find($filter,$option);
    echo json_encode($list);

When I use $list=$user->find($filter,$option);, it returns 3 empty records. When I use $list=$user->cast(), it returns the one record with the fields, but the values are null.

How can I combine find and cast?

like image 862
teee2 Avatar asked Mar 21 '23 17:03

teee2


1 Answers

try this one:

$list = array_map(array($user,'cast'),$user->find($filter,$option));
echo json_encode($list);
like image 164
ikkez Avatar answered Apr 01 '23 00:04

ikkez