I need to use php session_user data in postgresql view. How is it possible?
I have created postgre view with session_user variable in db.
CREATE OR REPLACE VIEW test_view AS
SELECT T.name, TT.age
FROM test1 T INNER JOIN test2 TT ON T.client_id=TT.client_id
WHERE T.user::text=session_user::text;
And I have my PHP code with CodeIgnited framework. I have created session in PHP:
$data = array(
'client_id' => $row->client_id,
'user' => $row->user,
'validated' => true
);
$this->session->set_userdata($data);
And now I try to select that view:
$result = $this->db->get('test_view');
But it is not working. The query returns 0 row.
What I'm doing wrong? (I know that I can make function or just select query, but I have to do this with this way - with view).