source: trunk/phpgwapi/inc/adodb/tests/test-pgblob.php @ 2

Revision 2, 2.0 KB checked in by niltonneto, 17 years ago (diff)

Removida todas as tags usadas pelo CVS ($Id, $Source).
Primeira versão no CVS externo.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1<?php
2
3function getmicrotime()
4{
5        $t = microtime();
6        $t = explode(' ',$t);
7        return (float)$t[1]+ (float)$t[0];
8}
9
10function doloop()
11{
12global $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
33include_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
42adodb_pr($db->ServerInfo());
43
44echo "<h4>Testing PREPARE/EXECUTE PLAN</h4>";
45
46
47$db->_bindInputArray = true; // requires postgresql 7.3+ and ability to modify database
48$t = getmicrotime();
49doloop();
50echo '<p>',$MAX,' times, with plan=',getmicrotime() - $t,'</p>';
51
52
53$db->_bindInputArray = false;
54$t = getmicrotime();
55doloop();
56echo '<p>',$MAX,' times, no plan=',getmicrotime() - $t,'</p>';
57
58
59
60echo "<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
76if ($v !== $val) echo "<b>*** ERROR: Inserted value does not match downloaded val<b>";
77else echo "<b>*** OK: Passed</b>";
78
79echo "<pre>";
80echo "INSERTED: ", $enc;
81echo "<hr>";
82echo"RETURNED: ", rawurlencode($v);
83echo "<hr><p>";
84echo "INSERTED: ", $val;
85echo "<hr>";
86echo "RETURNED: ", $v;
87
88?>
Note: See TracBrowser for help on using the repository browser.