Results 1 to 2 of 2
\r\n \r\n\r\n \r\n \r\n
\r\n
\r\n
\r\n Hi All,
\r\nwhen I try to insert a lot of rows in a postgresql db with for loop php:
\r\n
\r\n
\r\n
PHP Code:
\r\n
\nfunction foo() {\r
\r
    
$input = array(\'bar\');\r
\r
    
$db=connection_pgsql() or die(\'Connessione al DBMS non riuscita\');\r
    for (
$i=0;$i<1000;$i++) \r
    {\r
\r
      echo 
$i;\r
      
pg_prepare"run","INSERT INTO tab1(name) VALUES  ($1)");\r
      
pg_execute("run",$input);\r
\r
    }\r
   \r
    
pg_close($db);\r
} \r
\n
\n
\r\n
In my db are stored only about 100 rows and not 1000 rows. echo $i print not all number from 0 to 1000 but it stops at random number < 1000
\r\n
\r\n
\r\n\r\n \r\n\r\n\r\n
\r\n \r\n \r\n \r\n \r\n \r\n
\r\n
\r\n
\r\n
\r\n \r\n \r\n \r\n \r\n \r\n Reply With Quote Reply With Quote \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n\r\n \r\n\r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n
\r\n
\r\n
\r\n\r\n'; pd[6648245] = '\r\n
  • \r\n
    \r\n
    \r\n \r\n \r\n \r\n \r\n #2\r\n \r\n \r\n \r\n \r\n \r\n
    \r\n\r\n
    \r\n
    \r\n \r\n
    \r\n \r\n
    \r\n \r\n \r\n
    \r\n robert4u is offline\r\n\r\n \r\n \r\n Registered User\r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n
    \r\n
    \r\n \r\n
    \r\n
    \r\n
    Join Date
    Jun 2017
    \r\n \r\n \r\n
    Posts
    7
    \r\n \r\n
    \r\n \r\n \r\n
    \r\n \r\n
    \r\n
    \r\n\r\n
    \r\n \r\n
    \r\n \r\n \r\n\r\n \r\n \r\n
    \r\n
    \r\n
    \r\n Use sleep function, sometimes it overload the server as loop runs very fast.\r\n
    \r\n
    \r\n\r\n \r\n\r\n\r\n
    \r\n \r\n \r\n \r\n \r\n \r\n
    \r\n
    \r\n
    \r\n
    \r\n \r\n \r\n \r\n \r\n \r\n Reply With Quote Reply With Quote \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n\r\n \r\n\r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n
    \r\n
    \r\n
    \r\n
  • \r\n'; // next/previous post info pn[6646110] = "6648245,6648245"; pn[0] = ",6646110"; pn[6648245] = "6646110,6646110"; // cached usernames pu[0] = guestphrase; pu[337199] = "chileme88"; pu[367137] = "robert4u"; // -->

    Threaded View

    1. #1
      Join Date
      Dec 2013
      Posts
      3

      Question Unanswered: Insert into postgresql db with loop for

      Hi All,
      when I try to insert a lot of rows in a postgresql db with for loop php:

      PHP Code:
      function foo() {

          
      $input = array('bar');

          
      $db=connection_pgsql() or die('Connessione al DBMS non riuscita');
          for (
      $i=0;$i<1000;$i++) 
          {

            echo 
      $i;
            
      pg_prepare"run","INSERT INTO tab1(name) VALUES  ($1)");
            
      pg_execute("run",$input);

          }
         
          
      pg_close($db);

      In my db are stored only about 100 rows and not 1000 rows. echo $i print not all number from 0 to 1000 but it stops at random number < 1000

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •