completeamateur Posted December 1, 2008 Share Posted December 1, 2008 Hi guys, I'm trying to increment the current value of a column by using an update query. UPDATE category SET lft = lft + 2 WHERE lft > $lft; Unfortunately, because I'm using Zend Framework, it interprets 'lft + 2' incorrectly (don't ask me why!). Is there another way to increment the existing value, e.g. lft++ Quote Link to comment https://forums.phpfreaks.com/topic/134977-solved-simple-update-query/ Share on other sites More sharing options...
Mchl Posted December 1, 2008 Share Posted December 1, 2008 What is the actual PHP code you use? Maybe you should try UPDATE category SET `lft` = `lft` + 2 WHERE `lft` > $lft; [/code] Quote Link to comment https://forums.phpfreaks.com/topic/134977-solved-simple-update-query/#findComment-702946 Share on other sites More sharing options...
completeamateur Posted December 1, 2008 Author Share Posted December 1, 2008 I'm working with ZF so the code I use to generate the query is a little abstract... $this->update(array('lft'=>'lft + 2'), 'lft > ' . $lft); I've tried all variations of apostrophes and quotes but to no avail. Interestingly enough, I've found that... $this->update(array('lft'=>'2'), 'lft > ' . $lft); ...works fine, but... $this->update(array('lft'=>'lft'), 'lft > ' . $lft); ...doesn't. I presume this is because it is trying to enter the string 'lft'? Quote Link to comment https://forums.phpfreaks.com/topic/134977-solved-simple-update-query/#findComment-703277 Share on other sites More sharing options...
Mchl Posted December 1, 2008 Share Posted December 1, 2008 Try echo $this->update->__toString(); this should echo the actual query string, so that you can check the syntax. Quote Link to comment https://forums.phpfreaks.com/topic/134977-solved-simple-update-query/#findComment-703305 Share on other sites More sharing options...
completeamateur Posted December 2, 2008 Author Share Posted December 2, 2008 I'm afraid this just returns... Notice: Undefined property: Catalogue::$update in /Library/WebServer/Documents/bbusl/application/models/Catalogue.php on line 80 Fatal error: Call to a member function __toString() on a non-object in /Library/WebServer/Documents/bbusl/application/models/Catalogue.php on line 80 Quote Link to comment https://forums.phpfreaks.com/topic/134977-solved-simple-update-query/#findComment-703804 Share on other sites More sharing options...
completeamateur Posted December 2, 2008 Author Share Posted December 2, 2008 Yippee!... this has been solved in a different thread! http://www.phpfreaks.com/forums/index.php/topic,227860.0.html Quote Link to comment https://forums.phpfreaks.com/topic/134977-solved-simple-update-query/#findComment-703888 Share on other sites More sharing options...
Mchl Posted December 2, 2008 Share Posted December 2, 2008 Cool. I must take a note of this. I'm just struggling with ZF myself. Quote Link to comment https://forums.phpfreaks.com/topic/134977-solved-simple-update-query/#findComment-704165 Share on other sites More sharing options...
fenway Posted December 2, 2008 Share Posted December 2, 2008 Yippee!... this has been solved in a different thread! http://www.phpfreaks.com/forums/index.php/topic,227860.0.html Then you've double-posted... careful now. Quote Link to comment https://forums.phpfreaks.com/topic/134977-solved-simple-update-query/#findComment-704278 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.