关系 API:where() 无法使用命名空间类确定列

2024-01-28

我正在尝试做这样的事情

$u = \Entity\UserQuery::create()->where('User.Username = ?', "john")->findOne();

但我收到这个错误

无法确定要绑定到子句“User.Username = ?”中的参数的列

虽然相同的代码在非命名空间上下文中工作正常。

我知道有更好的方法可以做到这一点,但我想知道为什么会失败


众所周知的问题:

  • https://github.com/propelorm/Propel/issues/87 https://github.com/propelorm/Propel/issues/87
  • https://github.com/propelorm/Propel/issues/137 https://github.com/propelorm/Propel/issues/137

解决问题的最佳方法是使用别名:

$u = \Entity\UserQuery::create('alias')
    ->where('alias.Username = ?', "john")
    ->findOne();

下面的代码应该也能工作:

$u = \Entity\UserQuery::create('alias')
    ->where('Entity\UserQuery.Username = ?', "john") // or ->where('\Entity\UserQuery.Username = ?', "john")
    ->findOne();

问候, 威廉

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

关系 API:where() 无法使用命名空间类确定列 的相关文章

随机推荐