php - Using fat-free-framework fetch from table -
how fetch data table using fat free
my code:
$user=new db\sql\mapper($db,'test1'); $user->load()
but want display data without query. want print data using foreach statement
solution mapper
the first solution exports mapper
data array before iterating records.
$data = []; $user = new db\sql\mapper($db, 'test1'); ($user->load(); !$user->dry(); $user->next()) { $data[] = $user->cast(); }
now it's possible use foreach($data $user)
iterate users.
solution sql
it's possible fetch records without mapper
object.
foreach ($sql->exec('select * test1') $user) { echo $user['name']; }
more information
have @ documentation more information , tips:
Comments
Post a Comment