Postgres Loop Through Array Php Functions For Mysql