Ben Granstrom
Ben Granstrom

Reputation: 51

CodeIgniter equivalent to send_long_data() to avoid exceeding max packet size of mysql

I've been searching everywhere and can't find a solution to my problem. I'm trying to convert a php class I've used in other locations like smf and wordpress to a codeigniter library. My only hiccup at the moment is sending the data back to the database. The reason for the problem is the amount of data returned exceeds the packed size the php.ini file is set to and I don't want to change the ini file as that makes for problems later if needing to migrate or distribute it for others to use. So what I need is the CodeIgniter equivalent to...

// Send XML data in 8196 block chunks
$start=0;

// The XML data may be large in size, so we need to
// send the data in chunks to the MySQL driver to not
// exceed the max packet size for MySQL.
while ($start < strlen($xml))
{
    $end = $start + 8192; 
    if ($end > strlen($xml)) $end = strlen($xml);
    $statement->send_long_data(3,substr($xml,$start,$end-$start));
    $start = $end;
}
$start=0;
while ($start < strlen($xml))
{
    $end = $start + 8192;
    if ($end > strlen($xml)) $end = strlen($xml);
    $statement->send_long_data(4,substr($xml,$start,$end-$start));
    $start = $end;
}
$statement->execute();

I have narrowed down the problem to the send_long_data. I have already modified everything else within the file and runs beautifully. Does anyone know the proper way to deal with the max packet size correctly within CodeIgniter?

Upvotes: 1

Views: 175

Answers (1)

Ben Granstrom
Ben Granstrom

Reputation: 51

Found my problem, the table defaulted to MyISAM and needed to be InnoDB.

For reference to others the sql command to change this is

ALTER TABLE `tablename` ENGINE = InnoDB;

Upvotes: 1

Related Questions