merge in branch for direct messaging integration by EMR Direct
[openemr.git] / library / adodb / tests / test-pgblob.php
blobc190e5b85ec6556917dc2b26463984d502bc9beb
1 <?php
3 function getmicrotime()
5 $t = microtime();
6 $t = explode(' ',$t);
7 return (float)$t[1]+ (float)$t[0];
10 function doloop()
12 global $db,$MAX;
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;
33 include_once('../adodb.inc.php');
34 $db = NewADOConnection('postgres7');
35 $db->PConnect('localhost','tester','test','test') || die("failed connection");
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);
40 $MAX = 1000;
42 adodb_pr($db->ServerInfo());
44 echo "<h4>Testing PREPARE/EXECUTE PLAN</h4>";
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>';
53 $db->_bindInputArray = false;
54 $t = getmicrotime();
55 doloop();
56 echo '<p>',$MAX,' times, no plan=',getmicrotime() - $t,'</p>';
60 echo "<h4>Testing UPDATEBLOB</h4>";
61 $db->debug=1;
63 ### TEST BEGINS
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');
70 ### CLEANUP
72 $db->Execute("delete from photos where id=9999");
74 ### VALIDATION
76 if ($v !== $val) echo "<b>*** ERROR: Inserted value does not match downloaded val<b>";
77 else echo "<b>*** OK: Passed</b>";
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;