<? PHP
/
* * * Data Access objects (Data Access Object) sample @ create_date

* * : 2010-01-04 */


class BaseDAO
{
var $_db=null;
var $_table=null;

function BaseDAO ($config)
{
$this - >_db=new MysqlDB ();//can't operate here
}

/
* * * for handling

* * @ param array $/filter/filter
* @ param string $field//retrieve field
* @ param int $page//the current page
* @ param int $limit//pages/

* function the fetch ($filter=array (), $field="*", $page=1, $limit=null)
{
$this - >_db - >Select ($filed) - >The from ($this - >_table) - >The where ($filter) - >Limit ($page, $limit);
return $this - >_db - >The execute ();
}

the function update () {}
the function delete () {}
the function insert () {}
}

class MemberDAO extends BaseDAO
{
var $_table="member".
}

$oMember=new MemberDAO ();
$oMember - >The fetch ();

/
* * * are commonly used to:
* MVC model layer in the base class/

*? >

you might be interested in the article:

  • PHP Adapter design pattern (Adapter pattern)
  • PHP design model Builder (builders mode)
  • PHP design pattern Decorator (decorative pattern)
  • PHP design pattern Delegation (delegate pattern)
  • PHP design pattern Factory (Factory pattern)
  • PHP Interpreter of design patterns (the Interpreter mode)
  • PHP design pattern Strategy (Strategy)
  • PHP design mode Observer (Observer pattern)
  • PHP design pattern Facade appearance (mode)


This concludes the body part