错误的 COM_STMT_PREPARE 响应大小.收到 7. LARAVEL 错误

2022-01-15 00:00:00 mariadb php mysql laravel laravel-5.2

我有一个使用 laravel 开发的博客.在我的本地 PC 中,一切正常.但是当我将它上传到实时共享托管服务器时,它会引发如下错误:

MySqlConnector.php 第 124 行中的

ErrorException:错误的 COM_STMT_PREPARE 响应大小.收到 7

我的服务器配置如下

<块引用>

  1. 服务器:MariaDB
  2. 服务器版本:10.1.20-MariaDB - MariaDB 服务器
  3. PHP 5.6

我找不到任何解决方案.任何帮助将不胜感激.

解决方案

我也遇到了同样的问题.我的网络托管服务提供商是 000webhost.只需在数据库配置文件 (config/database.php) 中将此 PDO 属性 PDO::ATTR_EMULATE_PREPARES 设置为 true,它应该可以正常工作.

例如:

'mysql' =>['司机' =>'mysql','主机' =>env('DB_HOST', 'localhost'),//.......'选项' =>[PDO::ATTR_EMULATE_PREPARES =>真的,]],

此外,如果您已缓存配置或在生产环境中运行,您可能需要运行 php artisan config:cache.

I have a blog that is developed using laravel. In my local PC, everything is okay. But when I upload it in live shared hosting server it throws error like below:

ErrorException in MySqlConnector.php line 124:
Wrong COM_STMT_PREPARE response size. Received 7

My server configuration is given below

  1. Server: MariaDB
  2. Server version: 10.1.20-MariaDB - MariaDB Server
  3. PHP 5.6

I could not find any solution. Any help would be greatly appreciated.

解决方案

I also faced the same problem. My web host provider was 000webhost. Just set this PDO attribute PDO::ATTR_EMULATE_PREPARES to true in your database config file (config/database.php) and it should work fine.

Eg:

'mysql' => [
    'driver' => 'mysql',
    'host' => env('DB_HOST', 'localhost'),
    //.......
    'options'   => [PDO::ATTR_EMULATE_PREPARES => true,]
],

Additionally, you may need to run php artisan config:cache if you have cached your configuration or if running in production environment.

相关文章