Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-02-2008, 02:20 PM
Junior Member
 
Join Date: Jan 2008
Posts: 5
Default How I can increment field using zend_db??

Hi guys,

I have an application in zend framework structure, and I'm using zend_db, when I try to update table and increment field in this table, exception appear, I passes values as follow:

$data = array('lastresettime' => time(),
'verifiedflag' => '0',
'resetcount' => 'resetcount + 1');

when I try to execute it shows error.

when I try to use array as follows, it works propaply :

$data = array('lastresettime' => time(),
'verifiedflag' => '0');


Are there any one have an idea how to increment field in update zend_db statement??

thx

Last edited by ahmedrezk : 07-03-2008 at 08:05 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 07-02-2008, 03:23 PM
Member
 
Join Date: Mar 2007
Posts: 40
Default

Hi.

I think that this error is not coused by Zend_Db, but by Zend_Config.
You should read Exception descriptions, IT HELPS!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 07-03-2008, 08:08 AM
Junior Member
 
Join Date: Jan 2008
Posts: 5
Question

What ensure that this is an zend_db error, that when I tries to pass array of values as following it works:

Case 1: Not work and exception appear

$data = array('lastresettime' => time(),
'verifiedflag' => '0',
'resetcount' => 'resetcount + 1');

Case 2: It works and no problem
$data = array('lastresettime' => time(),
'verifiedflag' => '0');

Got it??
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 07-03-2008, 10:50 AM
Member
 
Join Date: Mar 2007
Posts: 40
Default

You have modified your first post, but you had an zend_Config exception there.

Here you have problem with storing string ('resetcount + 1') to integer column. You should use

PHP Code:
$data = array('lastresettime' => time(),
'verifiedflag' => '0',
'resetcount' => new Zend_Db_Expr('resetcount + 1')); 
It will probably work OK.


btw. wrap your code in , it is much more readable
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 07-03-2008, 12:55 PM
Junior Member
 
Join Date: Jan 2008
Posts: 5
Default

thx man it has been solved and work OK,
thx again
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 07-03-2008, 02:49 PM
Member
 
Join Date: Mar 2007
Posts: 40
Default

great


Martin.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 09:18 PM.