Welcome Guest, Not a member yet? Register   Sign In
better approach to work with models
#1

(This post was last modified: 07-01-2021, 11:23 AM by tino.)

this may seems a stupid question, and probably it is.
let's say i have to print all the users who are verificated, would be better doing something like this:
PHP Code:
class UserController extends BaseController {

    public function showEveryUser() {
        $userModel = new UserModel();

        $users $userModel->where("is_verificated"1)->findAll();

        ...
    }


or creating a specific method in the UserModel like this:
PHP Code:
class UserModel extends Model {

    public function getEveryUser() {
        return $this->where("is_verificated"1)->findAll();
    }


and then calling UserModel->getEveryUser() in UserController->showEveryUser()?
Reply


Messages In This Thread
better approach to work with models - by tino - 07-01-2021, 11:16 AM
RE: better approach to work with models - by tino - 07-02-2021, 02:54 AM



Theme © iAndrew 2016 - Forum software by © MyBB