wp_post在blog_cn数据库中,而stat_weibo在task数据库中。现在两个数据表需要进行连表查询,该如何实现?
阿神2017-04-17 15:43:34
Also note that these two databases are in one mariadb instance. Cross-mariadb, cross-server join is not possible
高洛峰2017-04-17 15:43:34
Override the ActiveRecord::getDb() method and return to connect to the database according to the configured db component by default.
伊谢尔伦2017-04-17 15:43:34
You can do this if the two databases are in the same Mysql server
Override the tableName() method of the Weibo model class:
public static function tableName()
{
preg_match("/dbname=([^;]+)/i", self::getDb()->dsn, $matches);
return $matches[1].'.weibo';
}
If the two databases are not in the same Mysql server, there is no solution for the time being