我有以下两个表:
table_a:
id_table_a: { type: integer, primaryKey: true, autoIncrement: true, required: true }
name: { type: varchar(255) }
id_table_b: { type: integer, foreignTable: table_b, foreignReference: id_table_b }
table_b:
id_table_b: { type: integer, primaryKey: true, autoIncrement: true, required: true }
value_1: { type: varchar(255) }
value_2: { type: integer }
我想使用 select 方法构建 SQL 查询以跳过水合,同时在连接表上使用别名:
TableAQuery::create()
->useTableBQuery('a')
// some filters methods
->endUse()
->useTableBQuery('b')
// some filters methods
->endUse()
->select(array('a.value_1', 'b.value_2'))
->find();
现在问题来了。推动不断变化a
和b
别名以table_b
生成不正确的 SQL,如下所示:
SELECT table_b.value_1 AS "a.value_1", table_b.value_2 AS "b.value_2" FROM `table_a`
LEFT JOIN `table_b` `a` ON (table_a.id_table_b=a.id_table_b)
LEFT JOIN `table_b` `b` ON (table_a.id_table_b=b.id_table_b)
代替
SELECT a.value_1 AS value_1, b.value_2 AS value_2 FROM `table_a`
LEFT JOIN `table_b` `a` ON (table_a.id_table_b=a.id_table_b)
LEFT JOIN `table_b` `b` ON (table_a.id_table_b=b.id_table_b)
我该如何处理?我使用 Propel 1.6.9
更新
我还检查了推进 1.7.1,没有区别。