Jump to content

[SOLVED] Simple UPDATE query


completeamateur

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.