Advertisement
Guest User

Untitled

a guest
May 5th, 2017
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.86 KB | None | 0 0
  1. <?php
  2.  
  3. header('Content-type: text/plain');
  4.  
  5. $pg = pg_connect('host=darius port=5432 dbname=unstable_steekr_com user=******* password=**********');
  6.  
  7. pg_query($pg, 'BEGIN;');
  8.  
  9. pg_query($pg, 'CREATE TEMP TABLE pwet ON COMMIT DROP TABLESPACE tbs_index AS SELECT * FROM users;');
  10.  
  11. pg_query($pg, 'DECLARE pwet_cursor SCROLL CURSOR FOR (SELECT * FROM pwet);');
  12.  
  13. $offset = 0;
  14. $limit = 10;
  15.  
  16. while (true)
  17. {
  18.     $move   = pg_query($pg, 'MOVE FORWARD '.$offset.' FROM pwet_cursor;');
  19.     $fetch  = pg_query($pg, 'FETCH FORWARD '.$limit.' FROM pwet_cursor;');
  20.    
  21.     if ($offset !== pg_affected_rows($move))
  22.     {
  23.         echo 'OOOOOOOOOOPSS =======> ';
  24.     }
  25.    
  26.     echo pg_affected_rows($move).' => '.pg_affected_rows($fetch)."\n";
  27.    
  28.     $offset = $offset + $limit;
  29.    
  30.     if (!pg_affected_rows($fetch))
  31.     {
  32.         break;
  33.     }
  34. }
  35.  
  36. pg_query($pg, 'CLOSE pwet_cursor;');
  37. pg_query($pg, 'COMMIT;');
  38.  
  39. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement