I try to get the row where email is as in the session variable using the following code in my controller.
$usermodel = new AppModelsUserModel();
$user=$usermodel->where('email', $session->get('email'))->find();
I do not get the proper result. Instead of getting the row containing the email in session variable, I get an empty array as result. However when i try to get all the content using findAll without filtering using email, I get the result showing all content. How can I get a filtered result with the row containing the specified email in session variable.
I checked if the session variable contains value and it was found to have the correct value.
My model
<?php namespace AppModels;
use CodeIgniterDatabaseConnectionInterface;
use CodeIgniterModel;
class UserModel extends Model
{
protected $table = 'tbl_user';
protected $allowedFields = ['name','email','password','image','role_id','isActive','date_created'];
}
Please help
I tried to get the row containing the email
But I get an empty array
2
Answers
Can you try like this by giving the where condition in find, i have not checked the code
You can also use the "first()" method if the email is unique.