I tried your query, but didn't get expected results:
I created a parent, added 3 children (different date of birth) and saved the whole thing. In the DB everything is stored correctly, so that worked. But after reloading, childNumber always returns 0. For testing I removed the "c.parentID = parentID" clause and I still get 0 as a response. Seems that either "date" is not mapped to the current class property or that the comparison does not work.
A look at the SQL query gives me
Code:
(SELECT COUNT(*) FROM tbl_children c WHERE c.date < date ) as formula1_0_
This seems to me like "date" is not processed properly. I expected
Code:
(SELECT COUNT(*) FROM tbl_children c WHERE c.date < ? ) as formula1_0_
as values normally get replaced by a '?'.
thanks again
Christian