I want to integrate a postgres request in symfony with the statement, however I can't communicate the right path for the copy
$RAW_QUERY = 'copy data(subject,predicate,object,lang) from :text DELIMITER \';\' CSV HEADER';
$statement = $this->emi->getConnection()->prepare($RAW_QUERY);
$statement->bindValue('text', $this->params->get('kernel.project_dir') . '/imports/flux.csv');
$statement->executeStatement();
error:
SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "$1"
LINE 1: copy data(subject,predicate,object,lang) from $1 DELIMITER '...
^
CodePudding user response:
The COPY filename is not a substitutable parameter, and COPY itself is not a preparable command. You will have to interpolate the filename into the command and run it directly.