我需要使用 propel orm 2.0.0 从两个表中选择特定的列集。等效查询如下
select b.name as brand_name, b.grade, d.name as dealer_name, d.number
from brand as b join dealer as d
on d.id = b.dealer_id;
我正在努力,两个表上的必要列具有相同的名称,但需要使用不同的列进行连接。
帮助我使用 propel php 代码以及正确的引用站点。官方网站上的文档不是一个好的教程。
最佳答案
如果您正确定义了模型,这应该可行。
$rows = BrandQuery::create()
->select(['name', 'grade'])
->joinWith('dealer')
->withColumn('dealer.name', 'dealer_name')
->withColumn('dealer.number')
->find();
关于php - 如何在 propel 中选择表连接上的特定列?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36534343/