News for hackers. Stuff that matters.
Re:Just open sourced my 10k LOC PHP & MySQL invoicing app by lftl on Wednesday June 20, 2012 @12:17AM (#4135603)
Interesting, I've been using Propel for so long I've probably internalized all the gotchas. What in particular caught you off guard?
Re:Just open sourced my 10k LOC PHP & MySQL invoicing app by chrismsnz on Wednesday June 20, 2012 @11:07PM (#4140347)
My favourite is probably:

Say you want to add a product to an existing order in the database...

$orderProduct = new OrderProduct(); $order = OrderPeer::retrieveByPK(1);

$order->addOrderProduct($orderProduct);

Now, if ANYWHERE after this point in the code, something calls $order->getOrderProducts() before you call $order->save() (like a validation routine or something) you will lose that new OrderProduct and it will not be persisted.

It's bit me more than once, especially as you start to spread code around that depends on traversing the relationships - can be a very tricky bug to spot.

Re:Just open sourced my 10k LOC PHP & MySQL invoicing app by lftl on Thursday June 21, 2012 @12:52AM (#4140604)
Propel's implementation of related collections definitely could use some improvement. In your example, you wouldn't necessarily lose your new object, it just wouldn't be persisted through a call to the parent order to save. My general habit is to call save on a newly created object directly, and as soon as possible. Regardless, I definitely agree this is one (and there are some other points) where Propel definitely has rough edges.