I need to import a csv file into my database. I first wrote the function in SQL but now I need to do it in php, I don't want to change my entire code so I just figured I could execute the SQL query with php but I get an error.
$query="COPY bet_import FROM $1 DELIMITER ',' CSV HEADER";
$result = pg_prepare($dbh, "", $query);
$result = pg_execute($dbh, "",array('bet.csv'));
I get the error:
Error: Warning: pg_prepare(): Query failed: ERROR: syntax error at or near "$1" LINE 1: COPY bet_import FROM $1 DELIMITER ',' CSV HEADER