• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to use Controller and Model in Codeigniter 4

#2
Models are just classes so loading a model is simply:

Code:
$userModel = new UserModel();

Typically models have a 1 model-to 1 table relationship. If you need to use a different table within one of the functions you can use the Model's builder() method:

Code:
public function data_function_one()
{
    $builder = $this->builder('table1')->whateverYouNeedNext();
}
Support Development  • Practical CodeIgniter 3  • Vulcan - CLI Tools for CI4
Reply


Messages In This Thread
RE: How to use Controller and Model in Codeigniter 4 - by kilishan - 06-03-2019, 06:32 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.