3

I've got a question regarding a mysterious doctrine query error. Long story short: I'm trying to store longblob data within my database (which can go up to x00mb for example), so i did the following steps: Create my own longblob type and field, register it according to: https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/cookbook/advanced-field-value-conversion-using-custom-mapping-types.html Doctrine custom data type

My MySQL database looks like: so i think it works? mysql> describe DataBlocks; +-----------------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-----------------+--------------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | data_type_id_id | int(11) | NO | MUL | NULL | | | project_id_id | int(11) | NO | MUL | NULL | | | data_block_name | varchar(100) | YES | | NULL | | | content | longblob | YES | | NULL | | | comment | longtext | YES | | NULL | | | ts_added | datetime | NO | | NULL | | +-----------------+--------------+------+-----+---------+----------------+

My Symfony4.1 FormType file field is as follows:

public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('dataBlockName', TextType::class)
            ->add('content', FileType::class)

I also adjusted the lines in my php.ini file for unlimited file size (i know this isn't really secure but.. it's just for now) post_max_size = 0M upload_max_filesize = 0M

And I get this error when my entity manager flushes the entity:

An exception occurred while executing 'INSERT INTO DataBlocks (data_block_name, content, comment, ts_added, data_type_id_id, project_id_id) VALUES (?, ?, ?, ?, ?, ?)' with params ["BTC_DOGE_tradehistory", Resource id #66, "450mb", "2018-10-08 10:19:44", 1, 1]: Warning: Error while sending QUERY packet. PID=6016

Your help would be kindly appreciated!

FYI: it works for small files, but when i try to upload something big it becomes that vague error

1 Answers1

1

The query describe in the exception tells you that the column content has for value a PHP resource. So i think it's a cast problem. Blob data are stored as bytes string. You also have possible issue with server configuration. There is Apache/Nginx or whatever, PHP but also the server sql.

Here an example for mysql: doc

GuillaumeL
  • 509
  • 3
  • 14
  • Thank you for your answer. Just read the doc a bit more, https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_max_allowed_packet states that "You must increase this value if you are using large BLOB columns or long strings. It should be as big as the largest BLOB you want to use.". Haven't tested this (already used another solution), but looks like this should be the answer. – Wannes Fransen May 22 '19 at 16:03