Mysql-ErrorException:发送QUERY数据包时出错。 PID = 6865

时间:2019-01-08 10:04:03

标签: mysql laravel-5 pdo

在laravel中创建表时出现以下错误错误-

表创建语法-

$sql = 'CREATE TABLE `temp_mobile_03b1effe4c12` (
  `id` bigint(20) unsigned NOT NULL,
  `mobile` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `operator` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `circle` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `country` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  KEY `temp_mobile_03b1effe4c12_id_index` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci';

DB::connection()->getpdo()->exec($sql);

错误-

[2019-01-08 15:18:38] local.ERROR: ErrorException: Error while sending QUERY packet. PID=6865 in /var/www/html/listmanager/deploy/releases/20190107104605/app/Jobs/UpdateBulkListSubscribers.php:303
Stack trace:
#0 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'Error while sen...', '/var/www/html/l...', 303, Array)
#1 /var/www/html/listmanager/deploy/releases/20190107104605/app/Jobs/UpdateBulkListSubscribers.php(303): PDO->exec('CREATE TABLE  t...')
#2 /var/www/html/listmanager/deploy/releases/20190107104605/app/Jobs/UpdateBulkListSubscribers.php(264): App\Jobs\UpdateBulkListSubscribers::createTempTable('temp_mobile_00d...', Array, Array)
#3 /var/www/html/listmanager/deploy/releases/20190107104605/app/Jobs/UpdateBulkListSubscribers.php(227): App\Jobs\UpdateBulkListSubscribers->updateMobileInfo()

1 个答案:

答案 0 :(得分:0)

对于Laravel:运行常规声明 某些数据库声明不返回任何值。对于这些类型的操作,您可以在DB上使用statement方法。尝试以下语法

DB::statement($sql);

例如:

DB::statement('drop table users');