I try to make universal update / swap which would always switch active status. In SQL is simple:
UPDATE contacts SET active = ABS( active - 1 ) WHERE id = ....
Where active is small int / flag 0 or 1, so it always work.
When I try to implement it to model class extend Zend_Db_Table:
public function disableContact( $contact_id )
{
$where = $this->getAdapter( )->quoteInto( 'id = ?', $contact_id );
$data = Array( );
$data ['active'] = '(ABS( the.contacts.active - 1 ))';
return parent::update( $data, $where );
}
I got Error: SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for integer: "(ABS( the.contacts.active - 1 ))"<p><pre>#0 ......./ZendFramework-1.11.0/library/Zend/Db/Statement.php(300): Zend_Db_Statement_Pdo->_execute(Array)
How to pass ABS expression to update ?