Using Entity with model, return empty Object - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: Using Entity with model, return empty Object (/showthread.php?tid=76080) |
Using Entity with model, return empty Object - harpreetsb - 04-13-2020 Hello there, Hope you are safe and healthy. PROBLEM: PHP Code: $user = $userModel->where('user_email', $email)->first(); Controller Code: PHP Code: public function doLogin() Model Code: PHP Code: <?php namespace App\Models; User Entity Code: PHP Code: <?php namespace App\Entities; If I Update the return type of model to OBJECT everything works fine but if i keep the return type as entity, it returns empty object. What is it that I am doing wrong? RE: Using Entity with model, return empty Object - cyberstunts - 04-13-2020 If no records are found, you will get null. Replace where statement with ID to test, e.g. PHP Code: $user = $userModel->where('user_id', 1)->first(); Otherwise nothing obvious which I can help with. |