E
E
Evgeny_Shestakov2015-08-10 10:49:11
Yii
Evgeny_Shestakov, 2015-08-10 10:49:11

Using each other's models between 2 sites in Yii 1.xx?

There are 2 sites on Yii 1 (each as a separate application), the task is to make widgets of one on the other, as well as use some models of one site on the other (counter). The question arose of how exactly it is better to use models (including relations) of one on the other. I didn’t find a ready-made recipe, I think to use namespaces and make 2 db components on each site (conditionally db1 for working with my own models, db2 for third-party ones), share your experience on how best to implement this?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Evgeny Elchev, 2015-08-10
@rsi

An unnecessary complication is trying to reach one model from another site. Since the model is not just a file in a vacuum, it is a part of the site that depends on its settings and so on.
Want to be simple and uncomplicated? Copy the model of one site to another, set up a connection in it to the database of another site and take data from the database. If you want to do api correctly, it's not as scary as it sounds. And what you propose is more complicated and dumber than any of the options I have proposed.

R
Rikcon, 2015-08-10
@Rikcon

If I understand you correctly, then write an API for db1 (REST) ​​and on the second just knock on db1 as you like, the models will accordingly remain in db1 and you don’t need to be smart with namespaces.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question