Doctrine 1.2 & MySQL : Menggunakan LOAD DATA LOCAL INFILE

Pada Ubuntu 12.04 dan menggunakan PHP versi 5.3,10 serta MySQL versi 5.5 ketika menjalan LOAD DATA LOCAL INFILE, seperti pada potongan kode sumber dibawah ini, yang diambil dari AlisJK [1].

....

public static function allocateToDb($db_name) { //allocated AllocatedTable::truncate() ; $output_dir = sfConfig::get("sf_root_dir").DIRECTORY_SEPARATOR."data".DIRECTORY_SEPARATOR."alokasi".DIRECTORY_SEPARATOR.$db_name.DIRECTORY_SEPARATOR."output".DIRECTORY_SEPARATOR ; $allocated_csv = $output_dir.DIRECTORY_SEPARATOR."allocated-raw.csv" ; $sql = "LOAD DATA LOCAL INFILE '{$allocated_csv}' REPLACE INTO TABLE allocated FIELDS TERMINATED BY ',' ENCLOSED BY '\"' LINES TERMINATED BY '\r\n' IGNORE 1 LINES"; $q = Doctrine_Manager::getInstance()->getCurrentConnection(); $result = $q->execute($sql); //failed FailedTable::truncate() ; $output_dir = sfConfig::get("sf_root_dir").DIRECTORY_SEPARATOR."data".DIRECTORY_SEPARATOR."alokasi".DIRECTORY_SEPARATOR.$db_name.DIRECTORY_SEPARATOR."output".DIRECTORY_SEPARATOR ; $failed_csv = $output_dir.DIRECTORY_SEPARATOR."failed.csv" ; $sql = "LOAD DATA LOCAL INFILE '{$failed_csv}' REPLACE INTO TABLE failed FIELDS TERMINATED BY ',' ENCLOSED BY '\"' LINES TERMINATED BY '\r\n' IGNORE 1 LINES"; $q = Doctrine_Manager::getInstance()->getCurrentConnection(); $result = $q->execute($sql); return $result ; }

....

Tidak berjalan sesuai yang diinginkan, dan terjadi error :

1148 Error Message: The used command is not allowed with this MySQL version

Solusinya, harus mengkompilasi ulang PHP yang sudah dipatch [4], cara pada [2] atau [3] pun tidak bisa.

Jika ingin menggunakan LOAD DATA INFILE, kita harus grang permission FILE ke user :

GRANT FILE on *.* to 'username'@'localhost' IDENTIFIED BY 'password';

Referensi