Karwin:
> Currently the only way to execute a SQL script is to with the PHP
> system()
> function. Run the mysql command-line tool with appropriate arguments.
There is another way to achieve this:
// $schema is content of *.sql file
$schema = explode(";\n", $schema);
$schema = array_map('trim',$schema);
$schema = array_filter($schema, 'strlen');
try {
foreach ($schema as $sql) {
$db->query($sql);
}
} catch (Exception $e) {
// [...]
}
Greetings,
Wojciech Naruniec
没有评论:
发表评论