关系API:where()无法使用命名空间类确定列 [英] Relational API: where() can not determine the column using namespaced classes
本文介绍了关系API:where()无法使用命名空间类确定列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试做这样的事情
Im trying to do something like this
$ u = \ Entity \ UserQuery :: create()-> where('User.Username =?',"john")-> findOne();
$u = \Entity\UserQuery::create()->where('User.Username = ?', "john")->findOne();
但是我得到这个错误
无法确定要绑定到子句'User.Username =?'中的参数的列
Cannot determine the column to bind to the parameter in clause 'User.Username = ?'
在非命名空间的上下文中使用相同的代码可以正常工作.
While the same code in a non-namespaced context works fine.
我知道有更好的方法,但是我想知道为什么失败
I known that there are better ways to do it, but I want to known why this fails
推荐答案
众所周知的问题:
- https://github.com/propelorm/Propel/issues/87
- https://github.com/propelorm/Propel/issues/137
解决问题的最佳方法是使用别名:
The best way to solve your problem is to use an alias:
$u = \Entity\UserQuery::create('alias')
->where('alias.Username = ?', "john")
->findOne();
以下代码也应正常工作:
The following code should work as well:
$u = \Entity\UserQuery::create('alias')
->where('Entity\UserQuery.Username = ?', "john") // or ->where('\Entity\UserQuery.Username = ?', "john")
->findOne();
关于, 威廉
这篇关于关系API:where()无法使用命名空间类确定列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文