Linus Norton Linus Norton - 2 months ago 16
MySQL Question

Using MySQL "SOURCE /path/to/file.sql" with PDO

This works when I run it from the mysql cli client but not when I run it through PDO, does anyone know why?


source is a command that allow you to execute list of SQL in mysql CLI,
but PDO is a database driver library (api) that compiled into PHP,
both are in different domain

Details of source :-

You can either :-

exec("/PATH/mysql < $file");

Or break each line of SQL (inside the file),
execute one-by-one each in PDO