1

Is there any proxying in place between Zend DB Table and Zend DB Row? For example, if I override the DB_Table delete() method to merely flag deleted records, will I need to do the same thing in DB_Table_Row? Or does row proxy to table?

If proxying is in place, in which direction does it occur? (Row proxies to table?) And for which methods? (Row delete() and save() -to- table delete(), update() and insert()?)

I realise I could test this myself but chance are you will be a lot faster (if you don't already know the answer...)

Thanks!

EDIT

The reason for the question is that I am developing some models which will include ACL. Since I have ACL in controllers too, I am planning only to override selected methods in the DB classes. For example, I want to ensure that a Member can delete their own record only. (I think I need to use ACL asserts to do this).

So I was asking the question above in order to determine whether I had to override pairs of methods (i.e. one in the Table class, one in the Row class), or whether I could just override one. Judging by the responses, however, I'm now wondering whether I'm asking the wrong question.

How do experienced developers deal with this kind of situation? Perhaps you choose to work with just one delete method (e.g. from the Row class). (Ditto for the update method too). If so, do you override the Table class delete to prevent inadvertant usage?

I am curious... Thanks...

2 Answers 2

1

From what I understand, the delete method in Zend_DB_Row employs delete method from Zend_DB_Table. Thus, if you overwrite delete from Zend_DB_Table it should be seen by delete in Zend_DB_Row.

Hope this helps. Anyway, if this would be not the case, please let me know.

Sign up to request clarification or add additional context in comments.

1 Comment

Assuming that it's using the instance of the Zend_Db_Table, and it's not a static call. Note: this is speculation.
1

Line 627 of Zend_Db_Table_Row_Abstract

    /**
     * Execute the DELETE (this may throw an exception)
     */
    $result = $this->_getTable()->delete($where);

gets the table and executes the delete method.

Line 1182 of Zend_Db_Table_Abstract

    return $this->_db->delete($tableSpec, $where);

This will call the Zend_Db_Adapter_Abstract::delete().

IMO, it may be best to over write the delete method in your adapter class. This is will ensure that no matter where the delete request comes from, your custom delete logic will be executed.

1 Comment

Same goes for updates and inserts. It really depends on whether you plan to have multiples models that can updates the same information. Either in the model or in the Adapter. The disadvantage to doing in the adepter is that if you custom logic for different tables your adapter my become hard to maintain. The disadvantage to doing it in the model class is that you have to do the CUD operations thru that model or the table_row created by that model. That may not be a disadvantage at all tho.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.