[ Index ]
 

Code source de vtiger CRM 5.0.2

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/adodb/tests/ -> test-pgblob.php (source)

   1  <?php
   2  
   3  function getmicrotime()
   4  {
   5      $t = microtime();
   6      $t = explode(' ',$t);
   7      return (float)$t[1]+ (float)$t[0];
   8  }
   9  
  10  function doloop()
  11  {
  12  global $db,$MAX;
  13      
  14      $sql = "select id,firstname,lastname from adoxyz where 
  15          firstname not like ? and lastname not like ? and id=?";
  16      $offset = 0;
  17      /*$sql = "select * from juris9.employee join juris9.emp_perf_plan on epp_empkey = emp_id 
  18          where emp_name not like ? and emp_name not like ? and emp_id=28000+?";
  19      $offset = 28000;*/
  20      for ($i=1; $i <= $MAX; $i++) {
  21          $db->Param(false);
  22          $x = (rand() % 10) + 1;
  23          $db->debug= ($i==1);
  24          $id = $db->GetOne($sql,
  25              array('Z%','Z%',$x));
  26          if($id != $offset+$x) {
  27              print "<p>Error at $x";
  28              break;
  29          }
  30      }
  31  }
  32  
  33  include_once ('../adodb.inc.php');
  34  $db = NewADOConnection('postgres7');
  35  $db->PConnect('localhost','tester','test','test') || die("failed connection");
  36  
  37  $enc = "GIF89a%01%00%01%00%80%FF%00%C0%C0%C0%00%00%00%21%F9%04%01%00%00%00%00%2C%00%00%00%00%01%00%01%00%00%01%012%00%3Bt_clear.gif%0D";
  38  $val = rawurldecode($enc);
  39  
  40  $MAX = 1000;
  41  
  42  adodb_pr($db->ServerInfo());
  43  
  44  echo "<h4>Testing PREPARE/EXECUTE PLAN</h4>";
  45  
  46  
  47  $db->_bindInputArray = true; // requires postgresql 7.3+ and ability to modify database
  48  $t = getmicrotime();
  49  doloop();
  50  echo '<p>',$MAX,' times, with plan=',getmicrotime() - $t,'</p>';
  51  
  52  
  53  $db->_bindInputArray = false;
  54  $t = getmicrotime();
  55  doloop();
  56  echo '<p>',$MAX,' times, no plan=',getmicrotime() - $t,'</p>';
  57  
  58  
  59  
  60  echo "<h4>Testing UPDATEBLOB</h4>";
  61  $db->debug=1;
  62  
  63  ### TEST BEGINS
  64  
  65  $db->Execute("insert into photos (id,name) values(9999,'dot.gif')");
  66  $db->UpdateBlob('photos','photo',$val,'id=9999');
  67  $v = $db->GetOne('select photo from photos where id=9999');
  68  
  69  
  70  ### CLEANUP
  71  
  72  $db->Execute("delete from photos where id=9999");
  73  
  74  ### VALIDATION
  75  
  76  if ($v !== $val) echo "<b>*** ERROR: Inserted value does not match downloaded val<b>";
  77  else echo "<b>*** OK: Passed</b>";
  78  
  79  echo "<pre>";
  80  echo "INSERTED: ", $enc;
  81  echo "<hr />";
  82  echo"RETURNED: ", rawurlencode($v);
  83  echo "<hr /><p>";
  84  echo "INSERTED: ", $val;
  85  echo "<hr />";
  86  echo "RETURNED: ", $v;
  87  
  88  ?>


Généré le : Sun Feb 25 10:22:19 2007 par Balluche grâce à PHPXref 0.7