Hi,
I have used Zend Framework for some small projects and plan to use it for a larger one. But what I wonder is what kind of methods you use for Zend_Db, what kind of pattern? Etc..
I have used a mapper and extended Zend_Db_Table_Abstract for each table, example:
PHP Code:<?php
class user {
public $id;
public $name;
protected $_mapper = null;
private function setMapper() {
$this->_mapper = new userMapper();
}
private function getMapper() {
if ($this->_mapper === null) {
$this->setMapper ();
}
return $this->_mapper;
}
public function insert() {
return $this->_mapper->insert($this);
}
public function update(){
return $this->_mapper->update($this);
}
}
?>PHP Code:<?php
class userMapper {
protected $_table = null;
private function setTable() {
$this->_table = new UserDbTable();
}
private function getTable() {
if($this->_table === null) {
$this->setTable();
}
return $this->_table;
}
public function insert(user $user) {
return $this->getTable()->insert( array(data ) );
}
Public function update(user $user) {
return $this->getTable()->update(array("data"), 'id=' . $user->id);
}
}
?>PHP Code:<?php
class userDbTable extends Zend_Db_Table_Abstract {
protected $_name = 'users';
}
?>
Is it the right way, or can it be done otherwise?
Thanks




Bookmarks