2013-10-24 55 views
0

如何執行執行多個操作的SQL語句?FuelPHP - 如何執行自定義的多行MySQL語句?

當我嘗試執行下面的代碼,我得到一個錯誤Fuel\Core\Database_Exception [ 1064 ]: You have an error in your SQL syntax;

PHP與MySQL內嵌

$sql = " 
    SET @sql = CONCAT(
     'CREATE TEMPORARY TABLE IF NOT EXISTS temp_compiled_properties AS 
     (SELECT 
      id, 
      ', @sql, ' 
     FROM properties 
     WHERE properties.property_id = ? 
     GROUP BY properties.property_id)'); 

    PREPARE stmt FROM @sql; 
    EXECUTE stmt USING @property_id; 
    DEALLOCATE PREPARE stmt;"; 

    DB::query($sql)->execute(); 

回答

2

此刻你不能。

你可以解決它通過提取當前的數據庫連接,並使用本機PHP直接

$db = \DB::instance()->connection(); 
$result = $db->exec($sql); // for PDO 

調用AFAIK本地MySQL驅動根本不支持多個語句。