-- debussy007 <[EMAIL PROTECTED]> wrote
(on Sunday, 05 October 2008, 01:29 PM -0700):
> In the directory "models", I usually have classes which are linked to tables
> and in which, sometimes, I create custom functions; here is an example:
> <?php
>
> class Trajets extends Zend_Db_Table_Abstract {
> protected $_name = 'trajets';
>
> function getNbAnnoncesConducteur($memberId) {
> return $this->getAdapter()->query(
> "select count(*) from trajets T " .
> "where T.member_id = '" . $memberId . "'"
> )->fetchColumn();
> }
> }
>
> ?>
>
> But I would like for some reasons to create a class which is not linked to a
> DB (for some POO reasons ...). However, I won't be able to use something
> like: return $this->getAdapter()->query( to return results since it is not
> linked to a DB.
>
> What is the best way to achieve this ?
I often use the Table Module pattern or Domain Model pattern -- and in
these cases, you attach data providers to your model, and pull from
there. So, with that in mind, you could create methods in your model for
pulling the default db table adapter or the table object itself, for
that matter.
(For an example, look at the Quick Start guide, which demonstrates a
table module pattern.)
--
Matthew Weier O'Phinney
Software Architect | [EMAIL PROTECTED]
Zend Framework | http://framework.zend.com/