开发者

Zend DB: Proxying between Table and Row classes?

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 tabl开发者_C百科e?

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...


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜