Closed
Description
Describe the bug
When I insert the data to database using a model, If any MySQL errors exits, Its not being reported.
$userModel = new \App\Models\UserModel();
$newUser = [
'name' => $this->request->getVar('name'),
'username' => $this->request->getVar('username'),
'email' => $this->request->getVar('email'),
'password' => $this->request->getVar('password'),
];
$user_id = $userModel->insert($newUser);
// here the name column does not exists in the database
$user_id returns '0'
//But when I try
$userModel->errors(); //Returns nothing
The only way I can see there is an error is var_dump($userModel) // and go through the whole array to see the error
and here is my model
namespace App\Models;
use CodeIgniter\Model;
class UserModel extends Model
{
protected $table = 'users';
protected $primaryKey = 'id';
protected $returnType = 'array';
protected $useSoftDeletes = true;
protected $allowedFields = ['name', 'email', 'username','password'];
protected $useTimestamps = true;
protected $createdField = 'created_at';
protected $updatedField = 'updated_at';
protected $deletedField = 'deleted_at';
protected $validationRules = [];
protected $validationMessages = [];
protected $skipValidation = false;
}
CodeIgniter 4 version
CodeIgniter 4.0.3
Affected module(s)
Models
Context
- OS: macOS Mojave
- Web server Apache
- PHP version : 7.4
Activity