Active Record, update using both with and like criteria, like criteria drops |
[eluser]Xollef[/eluser]
I must be blind :coolcheese: or something but I can't get this little query to work. For some reason the like criteria is dropped from the query. Code: $this->db->set('parentage', $parentage."-".$newSortOrder); Quote:UPDATE `pages` SET `parentage` = '0-00001-00001-00001' WHERE `language_code` = 'en' Can someone see what is wrong with this active record query and give a reason why the like criteria is dropped. PS: I use the newest Codeigniter.
[eluser]Chris Newton[/eluser]
I can't tell you from experience, but maybe replace the WHERE statement with another LIKE statement. $this->db->like('language_code', $language); If your language code is always just 2 letters, then the wildcards around 'en' wouldn't matter anyway.
[eluser]Seppo[/eluser]
Active record does not check for "like" arguments, it only checks for "where" clauses. I'm not sure if it's a bug or intentional... probably they didn't think that anybody will use it, but it would be ok to add...
[eluser]Chris Newton[/eluser]
http://ellislab.com/codeigniter/user-gui...ecord.html According to the documentation it does. The following from Active Records documentation. Also, if you check the code in Db_active_rec class around line 369, the function for LIKE exists. So if it doesn't work, that's a pretty major, major bug. Code: $this->db->like();
[eluser]Xollef[/eluser]
Thanks for your replies, if you havent spotted any obvious typing error then it seems it is a bug/feature. Quote: As you can see I only use LIKE on the parentage column and there I have to use a LIKE in this query. The language code is a normal where criteria. Has anyone got a similar query to work with Active record or can someone confirm that this is a bug(feature)? After checking through my code I notice that I have perfectly working Active Record select queries that use LIKE criteria. So it seems this problem, for me at least, only occurres on update Active Record queries. Quote:I have actually solved this using this run query method so I have no panic
[eluser]Noah David[/eluser]
Put the LIKE statement after the WHERE statement.
[eluser]Xollef[/eluser]
Actually I have tried having the like statement after the WHERE but it does not help.
[eluser]Noah David[/eluser]
And if you comment out the WHERE statement, it produces the LIKE statement correctly?
[eluser]Xollef[/eluser]
Just tested, and the answer is nope. It does not produce a LIKE statement at all when the WHERE statement is commented out. It just produces this Code: UPDATE `pages` SET `parentage` = ‘0-00001-00001-00001’
|
Welcome Guest, Not a member yet? Register Sign In |