[英]Phalcon join multiple database in query
Usually in SQL or Codeigniter's Active record we can join 2 different database tables in single query like: 通常,在SQL或Codeigniter的Active记录中,我们可以在单个查询中联接2个不同的数据库表,例如:
join database_1.table_1 on ..
join database_2.table_2 on ..
How do we achieve this is "Phalcon"? 我们如何实现这就是“ Phalcon”?
I tried to do it, but got an error: 我尝试这样做,但出现错误:
SQLSTATE[42S02]: Base table or view not found:
1146 Table 'database_2.table_2' doesn't exist
You can make use of Phalcon's query builder 您可以使用Phalcon的查询构建器
Specifically: 特别:
<?php
$builder->join('Robots');
$builder->join('Robots', 'r.id = RobotsParts.robots_id');
$builder->join('Robots', 'r.id = RobotsParts.robots_id', 'r');
$builder->join('Robots', 'r.id = RobotsParts.robots_id', 'r', 'LEFT');
OR Left joins: 或左联接:
<?php
$builder->leftJoin('Robots', 'r.id = RobotsParts.robots_id', 'r');
etc. 等等
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.