completeamateur Posted November 30, 2008 Share Posted November 30, 2008 Hi guys, I'm trying to create a simple query to update some records. $this->update(array('lft'=>'lft + 2'), 'lft > ' . $lft); This works fine, except it does not write the correct value in the lft column, it just writes '0', where as it should be 'lft + 2' i.e. the original value + 2. I'm not quite sure what I'm doing wrong. TIA Quote Link to comment https://forums.phpfreaks.com/topic/134914-solved-simple-update-query/ Share on other sites More sharing options...
trq Posted November 30, 2008 Share Posted November 30, 2008 That code allone doesn't make much sense without context. You should at least inform us what framework / library your using. Quote Link to comment https://forums.phpfreaks.com/topic/134914-solved-simple-update-query/#findComment-702595 Share on other sites More sharing options...
completeamateur Posted November 30, 2008 Author Share Posted November 30, 2008 Apologies, I'm using Zend Framework 1.5 Quote Link to comment https://forums.phpfreaks.com/topic/134914-solved-simple-update-query/#findComment-702597 Share on other sites More sharing options...
Daniel0 Posted December 2, 2008 Share Posted December 2, 2008 Try $this->update(array('lft'=> new Zend_Db_Expr('lft + 2')), 'lft > ' . $lft); Which class does $this refer to here? Quote Link to comment https://forums.phpfreaks.com/topic/134914-solved-simple-update-query/#findComment-703847 Share on other sites More sharing options...
completeamateur Posted December 2, 2008 Author Share Posted December 2, 2008 Daniel, that's worked a treat. It was trying to enter it as a string rather than an expression. Thank you so much. Quote Link to comment https://forums.phpfreaks.com/topic/134914-solved-simple-update-query/#findComment-703863 Share on other sites More sharing options...
Daniel0 Posted December 2, 2008 Share Posted December 2, 2008 No problem. Remember to click the "Topic Solved" button when you're done. I did it for you this time though Quote Link to comment https://forums.phpfreaks.com/topic/134914-solved-simple-update-query/#findComment-703870 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.