5

I need to force reread data from DB within one php execution, using propel. I already have a bit hacky solution: call init%modelName% for corresponding classes, but want something better.

Is there any single call or service config option for that? Like killing whole instance pool.

About service: we use symfony2 and don't need cache only in one specific case, hence we can create even separate environment for that.

kirilloid
  • 14,011
  • 6
  • 38
  • 52

2 Answers2

15

You can globally disable the instance pooling by calling: Propel::disableInstancePooling() (Propel::enableInstancePooling() is useful to enable the instance pooling).

Otherwise, you can rely on PEER classes which contain generated methods like clearInstancePool(), and clearRelatedInstancePool().

William Durand
  • 5,439
  • 1
  • 26
  • 37
0

I needed to update realated objects and found out clear%modelName% should be called.

init%modelName% deletes all entries and related entires could never be read. clear[Related]InstancePool don't help.

$foo = FooQuery->create()->findOne();
// meanwhile somebody else updated DB and Propel don't know about that:
mysql_query("INSERT INTO `foo_bars`, (`foo_id`, `bar_id`) VALUES (".$foo->getId().", 1)");
// here we need some magic to force Propel re-read relation table.
$foo->clearFooBars();
// now entries would be re-read
$foo->getFooBars();
kirilloid
  • 14,011
  • 6
  • 38
  • 52