2008年7月21日星期一

Re: [fw-db] executing .sql file using zend_db

Wiadomość napisana w dniu 2008-07-21, o godz. 17:08:41, przez Bill
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

http://wojciech.naruniec.info/

没有评论: