Failed to get complete data from mysql database column using laravel 4

I am having a weird problem: I have a table that stores CSV data in file_content. I am trying to get the content of a file in my Laravel application using SQL, but this data breaks at some point. It only returns partial data. The data size is about 9M.

Table schema:

Field         Type        Collation        Null    Key     Default            
------------  ----------  ---------------  ------  ------  -------- 
id            bigint(15)  (NULL)           NO      PRI     (NULL)
file_id       bigint(15)  (NULL)           YES     MUL     (NULL) 
file_content  longtext    utf8_general_ci  YES             (NULL)
dataTime      timestamp   (NULL)           NO 

      

SQL:

$sql = "SELECT file_content FROM file_data WHERE file_id = {$file_id} ;";
$result = DB::connection('staging_db')->select(DB::raw($sql));

      

When I see dd()

of $result

, then the data is less than half of what should be the result. For example. I have almost 37K rows in a file CSV

that is imported into this column, but when I run the above SQL, it only returns data with 3.2K rows only in CSV

.

It does not seems to be a SQL DB problem when I run the same with Basic PHP mysql_connect & mysql_query the result set returns whole data set but when I do the same with laravel then this issue comes back

Ideas on why and how to solve this?

+3


source to share


1 answer


You have to change the setting in mysql: max_allowed_packet



0


source







All Articles