Welcome Guest, Not a member yet? Register   Sign In
Active Record operator question
#1

[eluser]Sean Delaney[/eluser]
I get the following error when trying to run this query:

Code:
$this->CI->db->from('business');
$this->CI->db->where('business_start_date >',date('Y-m-d'));
$this->CI->db->where('business_end_date <',date('Y-m-d'));
$this->CI->db->where('business_status_id',3);

business_start_date and business_end_date are both date field types in the table.

ERROR:

Code:
A Database Error Occurred

Error Number: 1064

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 '`>` '2012-06-19' AND `business_end_date` `<` '2012-06-19' AND `business_status_i' at line 3

SELECT * FROM (`ci_business`) WHERE `business_start_date` `>` '2012-06-19' AND `business_end_date` `<` '2012-06-19' AND `business_status_id` = 3

Filename: /home/xxxx/public_html/xxxx/libraries/xxxx.php

Line Number: 280


According the documentation here: http://ellislab.com/codeigniter/user-gui...tml#select I can pass operators in the where() like this:

Code:
$this->db->where('name !=', $name);
$this->db->where('id <', $id);

// Produces: WHERE name != 'Joe' AND id < 45

Any ideas? I assume I'm doing something wrong?


Messages In This Thread
Active Record operator question - by El Forum - 06-19-2012, 01:52 AM
Active Record operator question - by El Forum - 06-19-2012, 01:57 AM
Active Record operator question - by El Forum - 06-19-2012, 02:01 AM
Active Record operator question - by El Forum - 06-19-2012, 02:12 AM
Active Record operator question - by El Forum - 06-19-2012, 02:27 AM
Active Record operator question - by El Forum - 06-19-2012, 02:28 AM
Active Record operator question - by El Forum - 06-19-2012, 02:33 AM
Active Record operator question - by El Forum - 06-19-2012, 02:38 AM



Theme © iAndrew 2016 - Forum software by © MyBB