Re: [PHP] very strange behavior.... incomplete query performed
There was no error message...hust after few secunds it stop as normaly it should do... but i add - set_time_limit(0); and it works. adding around 20.000 records to database takes some time :-) around 1:41 minutes. I was thinking that i could be faster... :-( Alain On 8/13/07, Richard Lynch [EMAIL PROTECTED] wrote: 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($row1) { $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? -- Alain Windows XP SP2 PostgreSQL 8.2.3 Apache 2.2.4 PHP 5.2.3
Re: [PHP] very strange behavior.... incomplete query performed
Alain Roger wrote: There was no error message...hust after few secunds it stop as normaly it should do... but i add - set_time_limit(0); and it works. adding around 20.000 records to database takes some time :-) around 1:41 minutes. I was thinking that i could be faster... :-( After doing your iconv stuff, turn it back into a csv file and use \copy like: \copy table from '/path/to/file.csv' Also see http://www.postgresql.org/docs/8.2/interactive/populate.html for some ideas. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] very strange behavior.... incomplete query performed
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($row1) { $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
[PHP] very strange behavior.... incomplete query performed
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($row1) { $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
Re: [PHP] very strange behavior.... incomplete query performed
On 8/12/07, Alain Roger [EMAIL PROTECTED] 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 : snip thanks a lot for any help. -- Alain Might it be that your script times out? try setting the time limit to unlimited: set_time_limit(0); Apache (or w/e your server is) might still timeout, but these values are a lot higher.. :) Tijnema -- Vote for PHP Color Coding in Gmail! - http://gpcc.tijnema.info -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] very strange behavior.... incomplete query performed
Tijnema wrote: On 8/12/07, Alain Roger [EMAIL PROTECTED] 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 : snip thanks a lot for any help. -- Alain Might it be that your script times out? try setting the time limit to unlimited: set_time_limit(0); Apache (or w/e your server is) might still timeout, but these values are a lot higher.. :) And if that is the case I would strongly recommend that you turn display_errors on and set error_reporting to E_ALL, at least for that script or if this is a development server do it in php.ini. -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php