Question

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?

Was it helpful?

Solution

try this one:

$list = array_map(array($user,'cast'),$user->find($filter,$option));
echo json_encode($list);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top