How to load whole table into a model?

193 Views Asked by At

I have a database table and I want to load it to model? Not by specified condition but whole table. How to do it?

3

There are 3 best solutions below

0
On BEST ANSWER

models in ATK4 are used to represent data and to abstract the underlying technicalities but not directly hold them.

it is used by MVCGrid, MVCForm and CRUD to know how data is to be presented / laid out to the user's interface.

though models may not hold data, they are used to retrieve it through dsql.

example:

 $m = $this->add('Model_UserAccess');
 $u = $m->dsql()
          ->field('usernm')
          ->field('acclvl')
          //->do_getOne(); // return only 1 record
          ->do_getAll(); // return all records

the use of DSQL or Dynamic SQL is important to retrieve data from tables and save it back.

0
On

I have a very simple script that creates the necessary .php files to copy to /lib/Model.

I did it because was migrating an Access application with tables of 20-30 attributes and was very tedious to create it by hand.

The script it's very very basic, but it's very useful for me.

Here is the link

https://github.com/ajmmartinez/atk4_create_mod

0
On

Try

$data = $mymodel->getRows();

This will get all the data from the model and store into the array. Your question is difficult to understand, so I'm not sure how to reply.