php - CodeIgniter: Instances of CI_Model -


i wondering if ci_model more database layer, or can use use model.

to me looks ugly things like:

for($i = 0; $i < 3; $i++){     $this->load->model('user_model', $i);     $this->user_model->name  = $this->generate_name();     $this->user_model->age   = $this->generate_age(); }  //... , somewhere else use  for($i = 0; $i < 3; $i++){     $this->$i->save(); //<-- ugly, using $i } 

is there way store models, or better way create non ci model. end like:

$user = new user($this->generate_name(), $this->generate_age()); $this->user_model->saveuser($user); 

let me know..

don't caught how things named in codeigniter; things named in ways can confusing people.

it sounds me want implement business logic in model, , in codeigniter it's cleaner in library. can use the ci_model classes data access layer only.

in case, be: /libraries/user.php <-- user "model" /models/usermodel.php <-- db operations user table primary table

note: may find moving application logic out of controllers , libraries makes testing, organizing, , reusing code easier.


Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -