Welcome Guest, Not a member yet? Register   Sign In
Use Model in view CI4
#3

Best practice is to use the model within your controller to get the data you need, and pass it to the view. It is usually recommended to keep as little function calling out of the views. They should be just for display purposes with as little logic as possible.

PHP Code:
$users = new UserModel();

echo 
view('users/index', [
    
'users' => $user->findAll(),
]); 
Reply


Messages In This Thread
Use Model in view CI4 - by gra - 04-08-2020, 09:14 AM
RE: Use Model in view CI4 - by jreklund - 04-08-2020, 09:26 AM
RE: Use Model in view CI4 - by kilishan - 04-08-2020, 11:08 AM



Theme © iAndrew 2016 - Forum software by © MyBB