推进翻译错误的表名 [英] Propel translating the wrong table names

查看:42
本文介绍了推进翻译错误的表名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

            ->joinOrigin('origin')
            ->joinLocation('location', \Criteria::LEFT_JOIN)
            ->where("LOWER(IF(location.code IS NOT NULL,location.code, origin.code)) NOT IN ?", $not_in_old_job_search_array)

是我从原始 SQL 移植的 Propel 查询的一部分.locationorigin 是指向同一个表的两个外键(在 schema.xml 中如此声明).Propel 正确添加了连接:

Is a part of a Propel query I am porting from raw SQL. location and origin are two foreign keys (declared as such in the schema.xml) which point to the same table. Propel adds the joins properly:

INNER JOIN `idb_countries` `origin` 
ON (idb_ads.idb_countries_ididb_origin=origin.ididb_countries) 
LEFT JOIN `idb_countries` `location` 
ON (idb_ads.idb_countries_ididb_job_location=location.ididb_countries)

但是 where 子句是这样的:

but the where clause comes out like this:

LOWER(IF(idb_countries.code IS NOT NULL,idb_countries.code, idb_countries.code)) NOT IN (:p5,:p6,:p7)) 

我怎样才能避免这种情况?

How can I avoid this?

我的 propel 版本是 1.7.0,我的 php 版本是 5.4.9

My propel version is 1.7.0, and my php version is 5.4.9

推荐答案

我认为您的问题比 推进:从别名连接表中选择列.

尝试使用这个 where() 调用:

Try using this where() call:

->where(
    "LOWER(IF(location.Code IS NOT NULL,location.Code, origin.Code)) NOT IN ?",
    $not_in_old_job_search_array
)

您会注意到唯一的区别是我已将代码"更改为代码".where() 方法需要列的 PHP 名称,而不是实际的列名称.别名与 PHP 名称一起存储,因此代码"让它知道使用别名,而代码"则不.

You'll notice the only difference is that I've changed "code" to "Code". The where() method is expecting the PHP name of the column, not the actual column name. The aliases are stored with the PHP name, so "Code" lets it know to use the alias while "code" does not.

这篇关于推进翻译错误的表名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆