gremo
gremo

Reputation: 48459

Reusing Propel query bug or my bad?

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.

Upvotes: 0

Views: 893

Answers (1)

Maxime
Maxime

Reputation: 235

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.

Upvotes: 1

Related Questions