I'm feeling thoroughly annoyed with the ORM system I'm using in Symfony. All I want to do is merge tags! It should be a matter of an update statement, followed by a delete. But with Doctrine ORM I have to all sorts of confusing things (well, not that confusing, it has to be said, but still…). So I think I might just go back to the simple days when things made sense and database statements behaved properly (i.e. ran when and how you thought they would within a transaction).
Oh, maybe it's not possible!
Can I sort by a function (for example ORDER BY RAND()) in DQL? No, it is not supported to sort by function in DQL. If you need this functionality you should either use a native-query or come up with another solution. As a side note: Sorting with ORDER BY RAND() is painfully slow starting with 1000 rows.
It's the middle of the morning here, but that doesn't matter. I'm attempting to add tags to Twyne (I'd link that, but still haven't implemented hyperlinks in my Sam-flavoured Markdown). It's going fine, it's not a complicated thing to do really, but I'm bumping skulls with Doctrine ORM. I've used it before for a couple of projects, but not for a while, and I'd forgotten how frustrating it is to be poking at DQL or a query builder and trying to make it work --- when the equivalent SQL is simple and easy! I wouldn't mind if this was something complicated, but ordering by the count of a joined table shouldn't take an hour to figure out.