2009-12-28 6 views
0

내 서버 PDO 버전의 버그로 인해 MySQLi를 사용하도록 전환했습니다. 그러나 Zend_DBMySQLi adaptor에는 exec 기능이 없으므로 또 다른 문제점이 있습니다. (Zend PDO adaptor did), 이는 SQL 스크립트를 실행할 수 없음을 의미합니다. (DROP TABLE 및 CREATE TABLE 쿼리의로드 포함).MySQLi 및 Zend_DB를 사용하여 준비되지 않은 쿼리

그래서 난 그냥 할 수있는 곳 :

$sqlQuery = file_get_contents('schema.sql'); 
$db = Zend_Db_Table_Abstract::getDefaultAdapter(); 
$db->exec($sqlQuery); 

나는 젠드 MySQLi 어댑터를 사용하여이 작업을 수행 할 수있는 방법을 찾을 수 없습니다. 어떤 아이디어?

답변

1

시도 :

$sqlQuery = file_get_contents('schema.sql'); 
$adapter = Zend_Db_Table_Abstract::getDefaultAdapter(); 
$mysqli = $adapter->getConnection(); // i think the returns the Mysqli Instance directly... 
$mysqli->multi_query($sqlQuery); 
0

이 내가 무슨 짓을

$bootstrap = $application->getBootstrap(); 
$bootstrap->bootstrap(‘db’); 
$config = $bootstrap->getResource(‘db’)->getConfig(); 
$runCommand = “mysql -h “.$config["host"].” -P “.$config["port"].” -u’”.$config["username"].”‘ -p’”.$config["password"].”‘ “.$config["dbname"].” < “.dirname(__FILE__) . ‘/schema.mysql.sql’; 
echo $runCommand; 
system($runCommand); 

상세 정보 : http://www.unexpectedit.com/zend-php/zend-db-exec-a-sql-file

관련 문제