$db->query('SELECT c.* , (SELECT COUNT(*) FROM city c2 WHERE c2.parent = c.id) as child_count FROM city c WHERE c.parent='.$parent);