Welcome Guest, Not a member yet? Register   Sign In
Memory problem with huge sql insertion [solved]
#1

[eluser]dede125a[/eluser]
Hello guys,

I have to insert a lot of recording in a sql base (mysql) form formated files (csv) an i use this code :
Code:
$total = 0;
while (!feof($lefichier)) {
    $ligne = fgets($lefichier);
    if ($ligne!='') {
        //log_message('debug',$ligne);
        list($nom,$prenom,$sexe,$daten,$ine,$us1,$us2,$bac,$us3,$us4,$avis) = explode("|",$ligne);
        // si il s'agit d'autres bacs que généraux ou technique, on n'insert pas les données
        if ($bac=="430" || $bac=="470") {
            $lignedata['nom']         = trim($nom);
            $lignedata['prenom']     = trim($prenom);
            $lignedata['ine']         = trim($ine);
            $lignedata['bac']         = trim($bac);
            $lignedata['result']    = trim($avis);
            
            //insertion dans la db
            $this->db->insert('resultats', $lignedata);
            if (mysql_error()) {
                $message = "<h3>Une erreur s'est produite à l'insertion des données</h3>\n";
                $message .= "<p>".mysql_errno() . ": " . mysql_error() . "</p>\n";
                break;
            }
            $total++;
            $message = "<h3>L'insertion des données s'est bien déroulée</h3>\n";
            
            
        } // endif type bac
    } // endif ligne vide
} // endwhile
$this->firephp->info($message);
fclose($lefichier);
Files contains over 20000 recordings and during the insertion I'v got this error :
Code:
[26-Jun-2009 15:19:11] PHP Fatal error:  Allowed memory size of 8388608 bytes exhausted (tried to allocate 38 bytes) in /Volumes/Serveur/web/opebac2009/system/database/drivers/mysql/mysql_driver.php on line 442

Because I'm not an expert, I guess that goods guys could help me to find a better way ?

Thanks by advance Smile


Messages In This Thread
Memory problem with huge sql insertion [solved] - by El Forum - 06-26-2009, 07:44 AM
Memory problem with huge sql insertion [solved] - by El Forum - 06-26-2009, 08:01 AM
Memory problem with huge sql insertion [solved] - by El Forum - 06-26-2009, 08:51 AM
Memory problem with huge sql insertion [solved] - by El Forum - 06-26-2009, 09:05 AM
Memory problem with huge sql insertion [solved] - by El Forum - 06-26-2009, 09:20 AM
Memory problem with huge sql insertion [solved] - by El Forum - 06-26-2009, 09:29 AM
Memory problem with huge sql insertion [solved] - by El Forum - 06-26-2009, 09:50 AM
Memory problem with huge sql insertion [solved] - by El Forum - 06-26-2009, 10:09 AM
Memory problem with huge sql insertion [solved] - by El Forum - 06-26-2009, 06:23 PM
Memory problem with huge sql insertion [solved] - by El Forum - 06-26-2009, 11:56 PM



Theme © iAndrew 2016 - Forum software by © MyBB