Jump to content

Recommended Posts

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++

 

Link to comment
https://forums.phpfreaks.com/topic/134977-solved-simple-update-query/
Share on other sites

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'?

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.