Postgresql Count Array Elements In Php