如何执行执行多个操作的SQL语句?
当我尝试执行以下代码时,出现错误Fuel\Core\Database_Exception [ 1064 ]: You have an error in your SQL syntax;
嵌入了MySQL的PHP
$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();
答案 0 :(得分:2)
此刻你不能。
您可以通过获取当前数据库连接来解决此问题,并直接使用本机PHP调用
$db = \DB::instance()->connection();
$result = $db->exec($sql); // for PDO
Afaik本机MySQL驱动程序根本不支持多个语句。