【发布时间】:2014-03-27 10:09:45
【问题描述】:
如果我们想使用 Phalcon 中的查询构建器将多个表连接到单个查询中。它要求为所有需要连接的表创建模型。
这是缺点还是优点?
$m = Firstmodel::query()
->columns("col1, col2")
->where("col3 = '2'")
->join("model2", "col1 = col5", 'a')
->join("model3", "col6 = col7", 'b')
->orderBy("col1")
->execute();
只需一个连接查询,它就可以完美运行。但是有 2 个像上面这样的连接查询会出现以下错误:
Scanning error before '] JOIN [] JOIN [...'
when parsing: SELECT col1, col2 FROM [Firstmodel]
JOIN [model2] AS [a] ON col1 = col5
JOIN [] JOIN [] JOIN [] JOIN [] WHERE col3 = '2' ORDER BY col1 (180)
是否有其他方法可以在不创建模型的情况下连接表?
【问题讨论】: