[eluser]octavianmh[/eluser]
All-
Working on an enhancement to a site and running into a strange query issue.
Here's my controller:
Code:
if($this->session->userdata('logged_in')) {
$data = array('couponData' => $this->user->getUserCouponInfoByOrganization($this->user->getUserId($this->session->userdata('user_email')),$this->input->post('organization_id')));
$this->load->view('header');
$this->load->view('view_coupons', $data);
$this->load->view('footer');
} else {
Here's the "getUserCouponInfoByOrganization" method:
Code:
function getUserCouponInfoByOrganization($user_id, $organization_id)
{
$this->db->from('coupon, users, organizations');
$where = "coupon.coupon_user_id = $user_id AND users.user_id = $user_id AND coupon.coupon_organization_id = $organization_id AND organizations.organization_id = $organization_id";
$this->db->where($where);
$query = $this->db->get();
$rows = $query->result_array();
return $rows;
}
When i change the where() statement to add FALSE as a second parameter, I get this error:
Quote:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '0' at line 3
SELECT * FROM (`coupon`, `users`, `organizations`) WHERE `coupon`.`coupon_user_id` = 3 AND users.user_id = 3 AND coupon.coupon_organization_id = 1 AND organizations.organization_id = 1 0
See that trailing zero? without it, the query works fine, I can't figure out where that's coming from!!
Any ideas?