Where in datatables with codeigniter

Asked

Viewed 83 times

2

I have a code that draws a table according to the data in the database. EX: If she has a registered customer she will make the table with only one row, if he has no registered customer, no table will appear. In this code too, I have a filter (tabletools) that when you type anything it checks if it exists in the table. In my model, I need to put a WHERE to show users only from the company that is logged in, but when I put this, the filter stops working. The wrong line 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 ');
  • What error is occurring?

  • @Dherik the filter when I put Where in the code it does not work, it filters but does not show the filtering result in the View

1 answer

1

check if the data of the Session is arriving correctly to the model, of an echo in the session inside the model if the data return certain believe that its problem is in concatenation, look for double quotes user in strings with variables together ex:

$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");

Browser other questions tagged

You are not signed in. Login or sign up in order to post.