Linus Norton Linus Norton - 1 year ago 90
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?

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download