【问题标题】:Kohana 3 ORM changing dbKohana 3 ORM 更改数据库
【发布时间】:2016-07-21 08:32:46
【问题描述】:

我希望我的 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 登录数据设置为一些随机的东西(所以它应该给我一个 excpetion),仍然没有。

这里有什么问题?

【问题讨论】:

    标签: php mysql kohana kohana-orm


    【解决方案1】:

    我的猜测是您的模型根本没有执行。因为你是对的,所以当你指定一个不存在的$_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 配置文件是否确实具有不同的数据库值。

    【讨论】:

      猜你喜欢
      • 2011-05-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-02-25
      • 1970-01-01
      相关资源
      最近更新 更多