Pre and post database operations with Zend Framework using Zend_Db_Table_Row

Hi all.

Here I am again.

Today I have a quick tip for beginners using Zend Framework.

Do not insert pre and post code (for database) in your Controller. The

Zend_Db_Table_Row
Zend_Db_Table_Row is for that.

Lets create our

DatabaseTable
DatabaseTable class for Posts:

/**
* Located in .../models/DbTable/Posts.php
*/
class Posts extends Zend\_Db\_Table_Abstract
{
protected $_primary = 'id';
protected $_name = 'posts';
protected $_rowClass = 'Post'; // here we linked the Post class above
}
/** * Located in .../models/DbTable/Posts.php */ class Posts extends Zend\_Db\_Table_Abstract { protected $_primary = 'id'; protected $_name = 'posts'; protected $_rowClass = 'Post'; // here we linked the Post class above }
/**  
* Located in .../models/DbTable/Posts.php  
*/  
class Posts extends Zend\_Db\_Table_Abstract  
{
    protected $_primary = 'id';  
    protected $_name = 'posts';  
    protected $_rowClass = 'Post'; // here we linked the Post class above  
}

Continue reading Pre and post database operations with Zend Framework using Zend_Db_Table_Row