Where in datatables with codeigniter

2

I have a code that draws a table according to the data in the database. EX: if she has a registered client she will make the table with only one row, if it has no one registered, no table will appear. In that code too, I have a filter (tabletools) that when you type anything it checks whether it exists in the table. In my model, I need to put a WHERE to show users only the company that is logged in, but when I put this in, the filter stops working. The line that is giving error is this:

$this->datatables->where('em.e_id = ' . $this->session->userdata('e_id') . ' AND usr.u_ni = 3 OR em.e_fil = ' . $this->session->userdata('e_id') . ' AND usr.u_ni = 3 ');
    
asked by anonymous 18.08.2015 / 14:36

1 answer

1

If the session data is arriving correctly to the model, from an echo in the session within the model if the data returns, I believe that your problem is in the concatenation, look for double quotation marks in strings with variables together: p>

$this->datatables->where("em.e_id = {$this->session->userdata('e_id')} AND usr.u_ni = 3 OR em.e_fil = {$this->session->userdata('e_id')} AND usr.u_ni = 3");

    
21.08.2015 / 00:54