I get the error "Uncaught Exception Warning: Packets out of order. Expected 1 received 166. Packet size=52" when running two PDO queries one after the other.
$dbh = new \PDO('mysql:host=' . $dbHost . ';dbname=' . $dbName, $dbUser, $dbPass, array(
\PDO::MYSQL_ATTR_LOCAL_INFILE => true
));
$sql = <<<eof
LOAD DATA LOCAL INFILE '$csv'
INTO TABLE $table
FIELDS TERMINATED BY ';' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '
'
IGNORE 1 LINES
($columns);
ALTER TABLE $table ADD COLUMN disabled INT DEFAULT 0
eof;
$dbh->query($sql);
$sql = 'SELECT COUNT(id) FROM '.$table.' WHERE myfield IS NULL';
$dbh->query($sql);
What I'm trying to do : after import of large CSV file (about 30 MB and 40k lines) into database, I want to count how many rows are empty in a field, to fill them in a later query.
I noticed I can run the first query if I comment out the second one, and then I can run the second query if I comment out the first one. If I try to run them one after the other, it fails. I tried raising memory packet to 20M from 8M, and also to set $dbh->setAttribute(\PDO::ATTR_EMULATE_PREPARES, true); with no success. Similar code worked with a smaller dataset earlier. Any pointers very welcome!