find() in model function returns 2d array |
Hi,
I'm just wondering if there is a way to make the find() function return a one dimensional array. I have a login function in my model and I want to run password_verify on it through Code: password_verify($password, $users['pwd']); this is the code I'm familiar with in CI3 but every time I run this code. it gives an error of undefined index. so I tried to debug it with var_dump and print_r. this returns me the array result array(1) { [0]=> array(12) { ["id"]=> string(1) "1" .... } } This is my model code that makes use of the return result of the find function. Code: public function checkLogin($userid, $password){ Thank you very much in advance! Good Day, Stay Safe, and Happy Coding.
Hi, are emp_id your primary key in said table? In that case you should use:
Code: $this->find($userid); As you don't specify an ID in there, you will get an array. Or do it your way with first() instead. Code: $users = $this->where('emp_id', $userid)->first(); https://codeigniter.com/user_guide/models/model.html
I have not declared 'emp_id' as my primary key. also, in my DB 'emp_id' is not my primary key but a unique foreign key. I'll try both of your suggestions and get back on this. Thank you!
|
Welcome Guest, Not a member yet? Register Sign In |