我有一个大于max_allowed_packet
(1MB)的文本,为什么我不能用下面的代码插入数据?
$db = new PDO('mysql:dbname=test;host=localhost', 'root', '5u4f1d');
$db->exec('SET NAMES utf8');
$stmt = $db->prepare('INSERT `book` (`text`) VALUES (?)');
$tx = file_get_contents('./test.html');
$stmt->bindParam(1, $tx, PDO::PARAM_LOB);
$db->beginTransaction();
$stmt->execute();
$db->commit();
它说:Fatal error: Cannot pass parameter 1 by reference
,但我从以下位置复制代码: - http://www.php.net/manual/en/pdo.lobs.php
数据库结构:
CREATE TABLE `book`
(`text` mediumtext COLLATE utf8_unicode_ci NOT NULL)
ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;