all data sore in \DB\SQL\Mapper ?

45 views
Skip to first unread message

s.hosein Hoseini

unread,
May 2, 2017, 11:37:21 PM5/2/17
to Fat-Free Framework

wthis code :

  $mapper = new \DB\SQL\Mapper($this->db,"article");
                $re =$mapper->find();

        print_r($re);

the  result include  any array and variable used in all source
i saved the result of print_r in text file and the size was 1.2 mb

if i extends \DB\SQL\Mapper in some model class and use those models the result will be larger !

$article = new Article();
                $re =$article->find();

        print_r($re);

is it logic ?

bcosca

unread,
May 3, 2017, 4:17:41 AM5/3/17
to Fat-Free Framework
Yes, that is by design - but no sensible dev should use find() without an argument unless the data volume is manageable. If you want to retrieve only a number of records at a time, use paginate().

s.hosein Hoseini

unread,
May 5, 2017, 1:37:38 PM5/5/17
to Fat-Free Framework
by using paginate we can limit record but my problem is not this
please see part of  result  form this   code:   $mapper = new \DB\SQL\Mapper($db,'site_reg_step' );        print_r($mapper->paginate());

result in browser :

Array ( [subset] => Array ( [0] => DB\SQL\Mapper Object ( [db:protected] => DB\SQL Object ( [uuid:protected] => 3nd4fppjge68o [pdo:protected] => PDO Object ( ) [dsn:protected] => mysql:host=127.0.0.1;port=3306;dbname=f3 [engine:protected] => mysql [dbname:protected] => f3 [trans:protected] => [rows:protected] => 10 [log:protected] => (0.1ms) SELECT f5 FROM site_reg_step GROUP BY f5 ORDER BY f6  SELECT f1,f2,f33,f4,f7 FROM site_reg_step WHERE


as you see result show all query used before in app with all results of those query's

ved

unread,
May 5, 2017, 2:09:57 PM5/5/17
to Fat-Free Framework
Again, that's not a bug, it's a feature.

The database class saves query information so one can debug the queries using the log() method.

You'll never use the results directly as from a print_r, so just get the data you need using $mapper->myfield and forget about what's on print_r or var_dump outputs. You can also call $mapper->cast() to get the results as an array if you want.
Reply all
Reply to author
Forward
0 new messages