如何使用NotORM
中的哪个类?
CODE
SELECT tbl1.description,
concat(tbl2.first_name, ' ', + tbl2.last_name) name,
count(tbl3.description)
FROM table1 tbl1, table3 tbl3,table2 tbl2
WHERE tbl1.id = tbl3.s_id
and tbl1.value= tbl2.value
group by tbl1.description,name
答案 0 :(得分:0)
我想,只是你可以这样试试
$db->table1()->select("description,(SELECT first_name FROM table2 where table2.value=table1.value)as firstname")->group("description")->fetch();
答案 1 :(得分:0)
NotORM旨在与具有良好名称的表和列一起使用。默认的命名约定会导致这种请求(如果我猜你需要的话):
SELECT table1.description,
CONCAT(table2.first_name, ' ', + table2.last_name) name,
COUNT(table3.description)
FROM table1, table2, table3
WHERE table1.id = table3.table1_id
AND table2.id = table1.table2_id
GROUP BY table1.description, name
在notOrm中
$db->table1()
->select("table3.description")
->select("CONCAT(table2.first_name, ' ', + table2.last_name) AS name")
->select("COUNT(table3.description) AS c")
->group("table1.description, name");
无需将这些表连接在一起。这是NotOrm的工作。