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 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. 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 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? 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. 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 Link to comment https://forums.phpfreaks.com/topic/134914-solved-simple-update-query/#findComment-703870 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.