Postgres Loop Through Array Php Functions Syntax In Python