Hi,
I'm trying to do a simple model query but it doesn't seem to work as defined in the official documentation.
Here's my code below:
PHP Code:
<?php
namespace App\Models;
use CodeIgniter\Model;
class UtilisateurModel extends Model {
protected $db;
protected $table = 'utilisateur';
protected $primaryKey = 'id_utilisateur';
protected $useAutoIncrement = true;
protected $returnType = 'array';
protected $allowedFields = [
'nom',
'email',
];
public function __construct() {
$this->db = db_connect();
}
public function get_from_email ($email) {
return $this->where('email', $email)->first();
}
}
When I call (new UtilisateurModel)->get_from_email($email);
I got the error:
Argument 1 passed to CodeIgniter\Database\BaseResult::getFirstRow() must be of the type string, null given
How can I solve that?
Regards