Search and casting

I am introducing 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 entries. When I use $ list = $ user-> cast (), it returns a single record with fields, but the values ​​are zero.

How can I combine search and casting?

+4
source share
1 answer

try the following:

$list = array_map(array($user,'cast'),$user->find($filter,$option));
echo json_encode($list);
+7
source

Source: https://habr.com/ru/post/1524920/


All Articles