Documentation TYPO3 par Ameos

test-pgblob.php

00001 <?php
00002 
00003 function getmicrotime()
00004 {
00005         $t = microtime();
00006         $t = explode(' ',$t);
00007         return (float)$t[1]+ (float)$t[0];
00008 }
00009 
00010 function doloop()
00011 {
00012 global $db,$MAX;
00013         
00014         $sql = "select id,firstname,lastname from adoxyz where 
00015                 firstname not like ? and lastname not like ? and id=?";
00016         $offset = 0;
00017         /*$sql = "select * from juris9.employee join juris9.emp_perf_plan on epp_empkey = emp_id 
00018                 where emp_name not like ? and emp_name not like ? and emp_id=28000+?";
00019         $offset = 28000;*/
00020         for ($i=1; $i <= $MAX; $i++) {
00021                 $db->Param(false);
00022                 $x = (rand() % 10) + 1;
00023                 $db->debug= ($i==1);
00024                 $id = $db->GetOne($sql,
00025                         array('Z%','Z%',$x));
00026                 if($id != $offset+$x) {
00027                         print "<p>Error at $x";
00028                         break;
00029                 }
00030         }
00031 }
00032 
00033 include_once('../adodb.inc.php');
00034 $db = NewADOConnection('postgres7');
00035 $db->PConnect('localhost','tester','test','test') || die("failed connection");
00036 
00037 $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";
00038 $val = rawurldecode($enc);
00039 
00040 $MAX = 1000;
00041 
00042 adodb_pr($db->ServerInfo());
00043 
00044 echo "<h4>Testing PREPARE/EXECUTE PLAN</h4>";
00045 
00046 
00047 $db->_bindInputArray = true; // requires postgresql 7.3+ and ability to modify database
00048 $t = getmicrotime();
00049 doloop();
00050 echo '<p>',$MAX,' times, with plan=',getmicrotime() - $t,'</p>';
00051 
00052 
00053 $db->_bindInputArray = false;
00054 $t = getmicrotime();
00055 doloop();
00056 echo '<p>',$MAX,' times, no plan=',getmicrotime() - $t,'</p>';
00057 
00058 
00059 
00060 echo "<h4>Testing UPDATEBLOB</h4>";
00061 $db->debug=1;
00062 
00063 ### TEST BEGINS
00064 
00065 $db->Execute("insert into photos (id,name) values(9999,'dot.gif')");
00066 $db->UpdateBlob('photos','photo',$val,'id=9999');
00067 $v = $db->GetOne('select photo from photos where id=9999');
00068 
00069 
00070 ### CLEANUP
00071 
00072 $db->Execute("delete from photos where id=9999");
00073 
00074 ### VALIDATION
00075 
00076 if ($v !== $val) echo "<b>*** ERROR: Inserted value does not match downloaded val<b>";
00077 else echo "<b>*** OK: Passed</b>";
00078 
00079 echo "<pre>";
00080 echo "INSERTED: ", $enc;
00081 echo "<hr />";
00082 echo"RETURNED: ", rawurlencode($v);
00083 echo "<hr /><p>";
00084 echo "INSERTED: ", $val;
00085 echo "<hr />";
00086 echo "RETURNED: ", $v;
00087 
00088 ?>


Généré par Le spécialiste TYPO3 avec  doxygen 1.4.6