Страница 1 из 1

Связывание объектов из разных баз данных

Добавлено: 2017.08.01, 14:57
slmd_
Столкнулся с проблемой, при запросе cross-database связи с помощью метода joinWith() получаю ошибку
Base table or view not found: 1146 Table 'connect1.table3' doesn't exist
Базы ( обе mysql )на разных машинах. В модели таблицы table3 указано соединение connect2. В документации же сказано :
Active Record allows you to declare relations between Active Record classes that are powered by different databases. The databases can be of different types (e.g. MySQL and PostgreSQL, or MS SQL and MongoDB), and they can run on different servers. You can use the same syntax to perform relational queries.
, С пометкой
Note: Usage of joinWith() is limited to databases that allow cross-database JOIN queries. For this reason, you cannot use this method in the above example because MongoDB does not support JOIN.
Итоговый объект запроса прилагаю:

Код: Выделить всё

{
  "sql": null,
  "on": null,
  "joinWith": [
    [
      [
        "relarion1"
      ],
      false,
      "LEFT JOIN"
    ],
    [
      [
        "relation2"
      ],
      false,
      "LEFT JOIN"
    ],
    [
      [
        "relation3"
      ],
      false,
      "LEFT JOIN"
    ],
    [
      [
        "relation4.subrelation"
      ],
      false,
      "LEFT JOIN"
    ],
    [
      [
        "relation6.subrelation"
      ],
      false,
      "LEFT JOIN"
    ],
    [
      [
        "relation7"
      ],
      false,
      "LEFT JOIN"
    ]
  ],
  "select": [],
  "selectOption": null,
  "distinct": "",
  "from": {
    "clients_ph": "clients_ph"
  },
  "groupBy": null,
  "join": null,
  "having": null,
  "union": null,
  "params": [],
  "where": [
    "between",
    "relation3.field",
    "10",
    "1000"
  ],
  "limit": null,
  "offset": null,
  "orderBy": null,
  "indexBy": null,
  "emulateExecution": false,
  "modelClass": "app\\models\\ClientsPh",
  "with": null,
  "asArray": null,
  "multiple": null,
  "primaryModel": null,
  "link": null,
  "via": null,
  "inverseOf": null
}

Помогите разобраться, что я делаю не так. Заранее спасибо.

Re: Связывание объектов из разных баз данных

Добавлено: 2017.08.01, 17:31
Nex-Otaku
Используешь MongoDB, хотя в доках сказано, что он не умеет джойны между БД?