CodeIgniter Forums
Active Record operator question - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Active Record operator question (/showthread.php?tid=52621)



Active Record operator question - El Forum - 06-19-2012

[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-guide/database/active_record.html#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?


Active Record operator question - El Forum - 06-19-2012

[eluser]marcogmonteiro[/eluser]
What version of ci are you using? is it the last one and if so, was it downloaded when they released it? I think there was some problems with the active records operators, that made them re-release CI.


Active Record operator question - El Forum - 06-19-2012

[eluser]Sean Delaney[/eluser]
I'm running 2.1.1, downloaded when first released.

I was not aware of another release. Download page still shows 2.1.1 ?


Active Record operator question - El Forum - 06-19-2012

[eluser]Sean Delaney[/eluser]
So is the currently 2.1.1 download of CI got fixes?


Active Record operator question - El Forum - 06-19-2012

[eluser]Sean Delaney[/eluser]
Fixed it with this for now:

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



Active Record operator question - El Forum - 06-19-2012

[eluser]Sean Delaney[/eluser]
Fixed it with this for now:

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



Active Record operator question - El Forum - 06-19-2012

[eluser]marcogmonteiro[/eluser]
yes, they re-released it on the next day but didn't change the version. It was a crappy move I tell you that, because if the version had indeed changed we would know how to help you better.

Try downloading it again and see how that goes.

cheers,
Marco


Active Record operator question - El Forum - 06-19-2012

[eluser]InsiteFX[/eluser]
CodeIgniter on GitHub