PHP only store 1048576 characters in array

前端 未结 1 1048
礼貌的吻别
礼貌的吻别 2021-01-20 14:45

I\'m working on a project that parses huge text files and store some of the information in MySQL DB. I noticed one of the field was missing info when it was displayed, howev

相关标签:
1条回答
  • 2021-01-20 15:09

    PDO's default buffer size is 1 MB (1048576), try bumping it up to 2 MB (2097152)

    If you are using PDO directly, pass this as the 4th argument

    $pdo = new PDO(
        $dsn,
        $username,
        $password,
        array(PDO::MYSQL_ATTR_MAX_BUFFER_SIZE => 2097152)
    );
    

    If you are using Laravel, this can be done via the config/database.php file by adding an array of options to your connection

    // ...
        'mysql' => array(
            'driver'    => 'mysql',
            // ...
            'charset'   => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix'    => '',
            'options'   => array(
                PDO::MYSQL_ATTR_MAX_BUFFER_SIZE => 2097152
            ),
        ),
    // ...
    
    0 讨论(0)
提交回复
热议问题