We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Model relationship to a FEDERATED mysql db table

Hi, In mysql server i have several databases like abc, xyz, pqr, etc.. and one database say lang_geo which contain language and geo table that are common to all other databases. so in 'abc' database i created the language table as follows:

CREATE TABLE `fd_language` (
  `id` int(11) NOT NULL,
  `name` varchar(250) NOT NULL,
  `short` varchar(250) NOT NULL
) ENGINE=FEDERATED DEFAULT CHARSET=utf8 CONNECTION='mysql://user:[email protected]/lang_geo/language';

Everythings works fine till this, i can able to fetch language table data.also can insert new language row.

But i have a Product model which is in relationship with Language model so when i did something like:

$product = Product::findFirstById($product_id);
$lang_name = $product->Language->name;

I got $lang_name as undefined

Above relationship works when language table is within same database.

Can any body tell how to establish relationship in FEDERATED engine situation

Thanks



43.9k

Hi,

I think that using relationships between tables that are not belonging to the same database is not possible at all.