Kohana 3 ORM changing db

174 views Asked by At

I want my SMS model to use other database group, so I did:

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();
}
[...]

But it's not working, even if I set mysql login data to some random stuff (so it should give me an excpetion), still nothing.

What's the problem here?

1

There are 1 answers

0
Daan On

My guess is that your model isn't executed at all. Because you are right, when you specify a $_db_group that does not exist, you should get this error:

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',

Double check if you model is executed at all, and check if your databasse sms config file does actually have different database values.