Here is an example of how I would code that:

  $data = array('order' => new Zend_Db_Expr('order + 2'));
  $where = array(
    $this->getAdapter()->quoteInto('userteam_id = ?', $userteamID),
    $this->getAdapter()->quoteInto('user_id = ?', $userID)
  );
  $result = $this->update($data, $where);

Explanation of the differences:

1. Use an object of type Zend_Db_Expr if you don't want the expression
quoted as a string.

2. The $where parameter can be an array.  The update() method knows how
to implode()s the elements together with the 'AND' operator between
them.  It isn't mandatory to do this instead of the string
concatentation you were using, but I find it more readable.

3. Use $this->getAdapter() instead of parent::getAdapter().  I assume
this code is in a non-static method in your table class that extends
Zend_Db_Table_Abstract.  Unless you have overridden the implementation
of getAdapter(), the subclass can reference that method as if it is part
of the class (because it has been inherited).

Regards,
Bill Karwin

> -----Original Message-----
> From: Ian Warner [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, August 30, 2007 1:36 AM
> To: Zend Framework
> Subject: [fw-general] Row incrementing DB Table
> 
> Hi
> 
> How do I do something like this:
> 
> $data  = array('order' => 'order + 2');
> 
> in
> 
>              $data  = array('order' => 'order + 2');
>              $where = 
> parent::getAdapter()->quoteInto('userteam_id = ?',
> $userteamID)
>                . ' AND ' . 
> parent::getAdapter()->quoteInto('user_id = ?', $userID);
> 
>              $result = parent::update($data, $where);
> 
> getting back an int(0) when i try
> 
> ian
> 

Reply via email to