通常在SQL或Codeigniter的Active记录中,我们可以加入2个不同的数据库表 单个查询如:
join database_1.table_1 on ..
join database_2.table_2 on ..
我们如何实现这一目标是" Phalcon"?
我试图这样做,但收到了错误:
SQLSTATE[42S02]: Base table or view not found:
1146 Table 'database_2.table_2' doesn't exist
答案 0 :(得分:0)
具体做法是:
<?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');
或左连接:
<?php
$builder->leftJoin('Robots', 'r.id = RobotsParts.robots_id', 'r');
等