News for hackers. Stuff that matters.
Re:Just open sourced my 10k LOC PHP & MySQL invoicing app by lftl on Monday June 18, 2012 @06:54PM (#4129019)
Out of curiosity what are you doing in PHP where memory usage is an issue? PHP's standard life cycle, while having numerous disadvantages, avoids a lot of problems with memory usage.

It's a rather different beat, but you might checkout Propel (http://propelorm.org) for a different take on a PHP ORM. It has a static build phase unlike Doctrine which turns some people off, but if you can get past that it's a rather nice ORM.

Re:Just open sourced my 10k LOC PHP & MySQL invoicing app by chrismsnz on Tuesday June 19, 2012 @08:28PM (#4135011)
If you think that your project is going to grow into a substantial code base, I would NOT recommend Propel.

A lot about their active record implementation violates POLA with various gotchas and code generation gets tedious and unwieldy with models that contain many fields or relations.

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.
Re:Just open sourced my 10k LOC PHP & MySQL invoicing app by renownedmedia on Monday June 18, 2012 @08:33PM (#4129507)
With this project in particular, each time someone hits the main page there are 6 php scripts executed in parallel. I was hitting some limits with my VPS during those spikes.