重用 Propel 查询 bug 还是我的错?
尽管我的代码类似于Propel 网站上的示例。 这是一个错误还是我的错?
$q = MashupSettingQuery::create()->filterByMashup($this);
var_dump($q->count(), $q->findOneByKey('redirect_uri'), $q->count());
输出是:
int 5
object(MashupSetting)[28]
protected 'startCopy' => boolean false
protected 'id' => int 9
protected 'key' => string 'redirect_uri' (length=12)
int 1
也就是说,重新使用不起作用,因为 count()
首先返回 5,然后返回 1。
即使使用 MashupSettingQuery::create()->filterByMashup($this)->keepQuery(true)
也没有解决问题。
Simple Propel reusing query is not working here, despite my code is similar to the example on Propel website. Is this a bug or my bad?
$q = MashupSettingQuery::create()->filterByMashup($this);
var_dump($q->count(), $q->findOneByKey('redirect_uri'), $q->count());
Output is:
int 5
object(MashupSetting)[28]
protected 'startCopy' => boolean false
protected 'id' => int 9
protected 'key' => string 'redirect_uri' (length=12)
int 1
that is, resusing is not working because count()
first returns 5 and then 1.
Even using MashupSettingQuery::create()->filterByMashup($this)->keepQuery(true)
didn't fix the problem.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为这是正常的,因为在第二次计数之前您进行了 findOneByKey 查询,因此第二次计数只是计算此特定查询返回的对象数量。
并且您的查询仅返回一个对象,显然是因为它是一个 findOneByKey。
I think it's normal because just before the second count you make a findOneByKey query, and so the second count just count how many objects this specific query return.
And your query return just one object, obviously because it's a findOneByKey.