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?
#2

[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.
#3

[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 ?
#4

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

[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);
#6

[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);
#7

[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
#8

[eluser]InsiteFX[/eluser]
CodeIgniter on GitHub




Theme © iAndrew 2016 - Forum software by © MyBB