Welcome Guest, Not a member yet? Register   Sign In
active record - simple mysql statement but not working

[eluser]CI MikeD[/eluser]
Is it something I am missing here? Here is the part of the sql statement built with active record that is getting errors:

Quote:$this->db->where('DATE_ADD(CURRENT_DATE,INTERVAL 1 DAY)', 'ending');

CI returnes this error: An Error Was Encountered, Error Number: 1064

with this created part of mysql:

So it fails to create equal sign (=). If I force the creation of = sign like this:
Quote:$this->db->where('DATE_ADD(CURRENT_DATE,INTERVAL 1 DAY)=', 'ending');

the error is the same event though query looks ok now. The most "funny" thing about all this is while CI reports error when i copy paste entire generated mysql to phpmyadmin it works.

above is only part of mysql query. any ideas?thanks.

isn't the where statement
$this->db->where(‘ending’,’DATE_ADD(CURRENT_DATE,INTERVAL 1 DAY)’);
I guess the ending is a field name, or not?

[eluser]CI MikeD[/eluser]
xwero,thank you very much! yes, ending is filed name.I see no error now.I think that was it Smile

[eluser]CI MikeD[/eluser]
eh,the joy was shortlived. Above statement produces
but it should be
, without simple quotes. I checked some thread and some people have simmilar problems. So there is no way (i do not want to write helpers or modify CI code) active record can produce this without active record adding single quotes? It would be "shame" to not use active record for such a small issue,i really like it Smile

Or did i miss something?

There is an upcomming change in the SVN where the set method has a third argument that can be set to false to not automatically escape the values. I think it's useful for the where method too, like your example proves.

But for now i think you have to settle for the basic query method.

[eluser]CI MikeD[/eluser]
thanks again xwero!

Theme © iAndrew 2016 - Forum software by © MyBB