I'm using CodeIgniter 4 and having an issue with my model. I'm using first() and findAll() to retrieve data as objects or arrays, but for some functions, I get this error:
Unknown column 'adresses_facturation.suppression' in 'where clause'
In my database, I have a column named suppression of type DATETIME.
public function getAdresse(int $idAdresse): ?object
{
return $this->where(['idFacturation' => $idAdresse, 'suppression' => null])->first();
}
my model :
class AdressesFacturationModel extends Model
{
protected $DBGroup = 'default';
protected $table = 'adresses_facturation'; //Nom de la table
protected $primaryKey = 'idFacturation'; //Clé primaire de la table
protected $useAutoIncrement = true;
protected $returnType = 'object'; // ou array ou object
protected $useSoftDeletes = true;
protected $allowedFields = [
'idFacturation',
'civilite',
'nom',
'prenom',
'entreprise',
'adresse',
'complement',
'postal',
'ville',
'telephone',
'email',
'idPays',
'defaut',
'utilisateurs_idUtilisateur'
];
protected $useTimestamps = true;
protected $createdField = 'creation';
protected $updatedField = 'modification';
protected $deletedField = 'suppression';
protected $validationRules = [];
protected $validationMessages = [];
protected $skipValidation = false;
protected $dateFormat = 'datetime';
For now I have done as code :
public function getAdresse(int $idAdresse): ?object
{
return $this->where(['idFacturation' => $idAdresse, 'suppression' => null])->get()->getRow();
}
but I would like to understand why I have the error with the first