Welcome Guest, Not a member yet? Register   Sign In
Models in CI4
#3

You can do it exactly as you've done it in the past. Add a new method to the model and call it. The new models basically take a lot of the functionality that many of the publicly available MY_Model classes had and build them into the core.

The reason that query is giving you errors is because you're treating the table() call like a select call, which it isn't. The table method just specifies which table to use. This is necessary in 4 to keep queries from "bleeding" into other queries as would often happen in CI3 if you weren't very careful.

PHP Code:
$this->db->table('users')... 

However, you also have some helper functions in your model you can use now for that same query.

PHP Code:
public function checkLoginCredentials($username$password) {
    
$user $this->where('username'$username)->first();

    if (
$user === null) {
       return 
false;
    }

    ... 
check password stuff here...

Reply


Messages In This Thread
Models in CI4 - by dudeawesome - 04-09-2020, 02:32 AM
RE: Models in CI4 - by includebeer - 04-10-2020, 04:51 AM
RE: Models in CI4 - by kilishan - 04-10-2020, 07:11 AM



Theme © iAndrew 2016 - Forum software by © MyBB