Are you using E_ALL?
Any error messages?
My first suspect is you are hitting php.ini time_limit setting, or
possibly the memory_limit.
On Sun, August 12, 2007 7:09 am, Alain Roger wrote:
> Hi,
>
> I'm still working on importing CSV file content (20.000 records) to
> database
> PostgreSQL.
>
> when i run the query, once i stored into my table 5218 records,
> another
> time 5231 another time 4713 and so on....
> every time the amount of records imported to DB is different.
>
> Do you have any idea from where it could come ?
>
> Here is my PHP code :
>
>> while (($data = fgetcsv($handle, 1000, ",")) !== FALSE)
>> {
>> $num = count($data);
>>
>> if($row>1)
>> {
>>
>> $charsetIN ='windows-1250';
>> $charsetOUT = 'UTF-8';
>>
>> $publisher = iconv($charsetIN, $charsetOUT,
>> $data[0]);
>> $program = iconv($charsetIN,
>> $charsetOUT,
>> $data[1]);
>> $version = iconv($charsetIN,
>> $charsetOUT,
>> $data[2]);
>> $path = iconv($charsetIN,
>> $charsetOUT, $data[4]);
>> $path =
>> str_replace("\\","\\\\",$path);
>> $licensing_file = iconv($charsetIN, $charsetOUT,
>> $data[5]);
>> $barcode = iconv($charsetIN,
>> $charsetOUT,
>> $data[6]);
>> $pcinfo_id = iconv($charsetIN,
>> $charsetOUT,
>> $data[8]);
>>
>> $date_audit = iconv($charsetIN,
>> $charsetOUT,
>> trim(str_replace(" ","",$data[11])));
>>
>> $locality = iconv($charsetIN,
>> $charsetOUT,
>> $data[13]);
>> $area = iconv($charsetIN,
>> $charsetOUT, $data[12]);
>> $username = iconv($charsetIN,
>> $charsetOUT,
>> $data[14]);
>> $personal_number = iconv($charsetIN, $charsetOUT,
>> $data[15]);
>>
>>
>> $result = pg_query($dbconn,"set search_path = sw_audit;");
>> echo "result (set search_path) = ".$result."<br/><br/>";
>> $res=pg_query("SELECT nextval('tmp_importedxls_rec_id_seq')
>> as
>> key");
>> $row=pg_fetch_array($res, 0);
>> $key=$row['key'];
>>
>> $sql = "INSERT INTO tmp_importedxls (rec_id, publisher,
>> program,
>> version, path, licensing_file, date_audit, barcode, pcinfo_ident,
>> area,
>> locality, users, personal_number)
>> VALUES ($key,
>> '$publisher',
>> '$program',
>> '$version',
>> '$path',
>>
>> '$licensing_file','".SplitDate(".",$date_audit)."',
>> '$barcode',
>> '$pcinfo_id',
>> '$area',
>> '$locality',
>> '$username',
>> '$personal_number');";
>>
>> //echo "SQL : " .$sql."<br/><br/>";
>>
>> $result = pg_query($dbconn,$sql);
>> if (!$result)
>> {
>> die("Error in SQL query: " . pg_last_error());
>> }
>> else
>> {
>> echo "result (INSERT INTO) = ".$result."<br />";
>> }
>>
>> }
>> $row++;
>> }
>> fclose($handle);
>>
>> pg_close($dbconn);
>
>
>
> thanks a lot for any help.
>
>
> --
> Alain
> ------------------------------------
> Windows XP SP2
> PostgreSQL 8.2.3
> Apache 2.2.4
> PHP 5.2.3
>
--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php