简体   繁体   中英

How use table in other database for “through” kohana ORM?

Sorry for my english, I'm from Ukraine. I have next model

 class Model_Search extends ORM
    {
        protected $_has_many = array(
           'mp3s'       => array(
                        'model' => 'Mp3',
                        'through' => 'searches_mp3s',

                        ),
            );

but table searches_mp3s in other database, for example 'db2'. How I can do relationship with through for my situation? Thank you

In pure SQL this should be database.table.field . And you must have user-connection who allow read from both databases.

I don't know, that kohana understand database.table notation... You can try in your Model (ORM) class:

class Model_Search extends ORM
{
    protected  $_table_name = 'db1.search';
    protected $_has_many = array(
       'mp3s'       => array(
                    'model' => 'Mp3',
                    'through' => 'db2.searches_mp3s',

                    ),
        );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM