I got model in Zend Framework what extends Zend_Db_Table where $this->_name = 'tableA'.
It is very nice how long I doing insert(), update(), or delete(). How I can realize updating main table based on value from another table.. ?
In raw SQL query it could looks like this:
UPDATE tableA SET fieldA = tableB.newValue
FROM tableB
WHERE tableA.someValue = tableB.someIndex // it will be complicate manipulation
AND tableA.index = .....
how I can build params for update() method:
parent::update( $data, $where );
There are no possible combinations of how to build params for the
parent::update()method to get that final update query. The reason is because the Db Tableupdatemethod just passes along your$dataand$wherevariables to the Db Adapter’supdatemethod. The adapter’supdatemethod leaves no room for attaching additional information. You can’t hack params at allIf you can’t use table relationships with cascade update. Your best bet will be to extend the Db Adapter and create a new method to handle these types of updates. This should work.
Note: I didn’t test this out, but I am pretty confident it will work as expected. If you have any problems, just let me know. Because I copied the adapter’s update method, I went ahead and added notes of the reasons why you can’t hack those params.
EDIT
I almost forgot to mention. Every adapter is unique so you will have to check with your adapters update method. I just copied from
Zend_Db_Abstract.