[英]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'. 但是其他数据库(例如“ db2”)中的表searchs_mp3s。 How I can do relationship with through for my situation? 如何根据自己的情况与他人建立关系? Thank you 谢谢
In pure SQL this should be database.table.field
. 在纯SQL中,应为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: 我不知道,kohana可以理解database.table
表示法...您可以在Model(ORM)类中尝试:
class Model_Search extends ORM
{
protected $_table_name = 'db1.search';
protected $_has_many = array(
'mp3s' => array(
'model' => 'Mp3',
'through' => 'db2.searches_mp3s',
),
);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.