Kohana 3 ORM改变数据库

时间:2016-07-21 08:32:47

标签: php mysql kohana kohana-orm

我希望我的SMS模型使用其他数据库组,所以我做了:

class Model_M4B_SMS extends ORM implements Model_Validate {

protected $_has_many = array('m4b_sms_expeditions' => array());
protected $_belongs_to = array('advert'=>array(),'m4b_sms_sender' => array());
protected $_db_group = 'sms';

public function __construct()
{
    $this->_db_group = 'sms';

    parent::__construct();
}
[...]

但它不起作用,即使我将mysql登录数据设置为一些随机的东西(所以它应该给我一个删除),仍然没有。

这里有什么问题?

1 个答案:

答案 0 :(得分:0)

我的猜测是你的模型根本没有被执行。因为你是对的,当你指定一个不存在的$_db_group时,你应该得到这个错误:

ErrorException [ Notice ]: Undefined index: sms

MODPATH/database/classes/Kohana/Database.php [ 65 ]

        if ( ! isset(Database::$instances[$name]))
        {
            if ($config === NULL)
            {
                // Load the configuration for this database
                $config = Kohana::$config->load('database')->$name;
            }

            if ( ! isset($config['type']))
            {
                throw new Kohana_Exception('Database type not defined in :name configuration',

仔细检查您的模型是否完全执行,并检查您的数据库sms配置文件是否确实具有不同的数据库值。

相关问题