开发者

how to set the table prefix in zend framework

开发者 https://www.devze.com 2023-01-26 17:22 出处:网络
I need to add a table prefix to zend framework configurations. But it seems really complicated开发者_如何学Python matter adding such a configuration (I have to add too many lines of code to do that).

I need to add a table prefix to zend framework configurations. But it seems really complicated开发者_如何学Python matter adding such a configuration (I have to add too many lines of code to do that). Is there a way to set the table prefix in a simple manner? (like other frameworks do). I'm using Zend Framework 1.11


if you use Zend_Db_Table_Abstract, you could extend this class like this:

class My_Db_Table_Abstract extends Zend_Db_Table_Abstract
{
     protected function _setupTableName()
     {
         parent::_setupTableName();
         $prefix = 'StackOverflow'; // maybe from config..
         $this->_name = $prefix . '_' . $this->_name;
     }
}

class User extends My_Db_Table_Abstract
{
        $this->_name = 'user';
}
0

精彩评论

暂无评论...
验证码 换一张
取 消