added php to write queries