Zend Framework fetchAll
Asked Answered
R

2

5

Can i override fetchall method in a model? I need to check sth everytime fetchAll is called. The model extends Zend_db_table_abstract

Reformism answered 9/10, 2008 at 10:1 Comment(0)
S
9

To override this method you would need to subclass the Zend_Db_Table_Abstract. Like so:

<?php
abstract class My_Db_Table_Abstract extends Zend_Db_Table_Abstract
{
    ...

    public function fetchAll($where, $order)
    {
        ...
    }

    ...
}

Then make sure your models extend My_Db_Table_Abstract instead. This way, you will always inherit your overridden fetchAll method.

Sex answered 13/10, 2008 at 16:2 Comment(1)
Since you're naming it Abstract, you probably want it to be an abstract class.Plowboy
S
0

Yes. Just define a new fetchAll() method in your model with the same construction as the Zend_db_table_abstract method (ie same input / output) then at the end of your method call the parent method:

parent::fetchAll($params)

Andrew

Sporozoite answered 23/10, 2008 at 13:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.