Changeset 8222 for sandbox/2.5.1-evolucao/phpgwapi/inc/adodb/tests/test.php
- Timestamp:
- 09/26/13 15:41:49 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sandbox/2.5.1-evolucao/phpgwapi/inc/adodb/tests/test.php
r34 r8222 1 1 <?php 2 2 /* 3 V4.80 8 Mar 2006 (c) 2000-20 07 John Lim (jlim#natsoft.com.my). All rights reserved.3 V4.80 8 Mar 2006 (c) 2000-2012 John Lim (jlim#natsoft.com). All rights reserved. 4 4 Released under both BSD license and Lesser GPL library license. 5 5 Whenever there is any discrepancy between the two licenses, … … 11 11 12 12 13 if (!defined('E_STRICT')) define('E_STRICT',E_NOTICE);13 //if (!defined('E_STRICT')) define('E_STRICT',0); 14 14 error_reporting(E_ALL|E_STRICT); 15 15 … … 147 147 print "<i>date1</i> (1969-02-20) = ".$db->DBDate('1969-2-20'); 148 148 print "<br><i>date1</i> (1999-02-20) = ".$db->DBDate('1999-2-20'); 149 print "<br><i>date1.1</i> 1999 = ".$db->DBDate("'1999'");149 print "<br><i>date1.1</i> 1999 injection attack= ".$db->DBDate("'1999', ' injection attack '"); 150 150 print "<br><i>date2</i> (1970-1-2) = ".$db->DBDate(24*3600)."<p>"; 151 151 print "<i>ts1</i> (1999-02-20 13:40:50) = ".$db->DBTimeStamp('1999-2-20 1:40:50 pm'); 152 152 print "<br><i>ts1.1</i> (1999-02-20 13:40:00) = ".$db->DBTimeStamp('1999-2-20 13:40'); 153 153 print "<br><i>ts2</i> (1999-02-20) = ".$db->DBTimeStamp('1999-2-20'); 154 print "<br><i>ts2</i> (1999-02-20) = ".$db->DBTimeStamp("'1999-2-20', 'injection attack'"); 154 155 print "<br><i>ts3</i> (1970-1-2 +/- timezone) = ".$db->DBTimeStamp(24*3600); 155 156 print "<br> Fractional TS (1999-2-20 13:40:50.91): ".$db->DBTimeStamp($db->UnixTimeStamp('1999-2-20 13:40:50.91+1')); … … 484 485 CREATE TABLE PHOTOS 485 486 ( 486 ID NUMBER(16) ,487 ID NUMBER(16) primary key, 487 488 PHOTO BLOB, 488 489 DESCRIPTION VARCHAR2(4000 BYTE), … … 597 598 print "<b>Error in using Cursor Variables 1</b><p>"; 598 599 } 599 $rs->Close();600 if ($rs) $rs->Close(); 600 601 601 602 print "<h4>Testing Stored Procedures for oci8</h4>"; … … 638 639 //$db->debug=1; 639 640 print "<p>Testing Bulk Insert of 3 rows</p>"; 641 642 // $db->debug=1; 643 // $db->Execute('select * from table where val=? AND value=?', array('val'=>'http ://www.whatever.com/test?=21', 'value'=>'blabl')); 644 640 645 641 646 $sql = "insert into ADOXYZ (id,firstname,lastname) values (".$db->Param('0').",".$db->Param('1').",".$db->Param('2').")"; 647 $db->bulkBind = true; 642 648 $db->StartTrans(); 649 $db->debug=99; 643 650 $db->Execute($sql,$arr); 644 651 $db->CompleteTrans(); 652 $db->bulkBind = false; 645 653 $rs = $db->Execute('select * from ADOXYZ order by id'); 646 654 if (!$rs || $rs->RecordCount() != 3) Err("Bad bulk insert"); … … 842 850 843 851 print "<p>CacheSelectLimit Test...</p>"; 844 $db->debug=1;845 852 $rs = $db->CacheSelectLimit('select id, firstname from ADOXYZ order by id',2); 853 854 if (ADODB_ASSOC_CASE == 2 || $db->dataProvider == 'oci8') { 855 $id = 'ID'; 856 $fname = 'FIRSTNAME'; 857 }else { 858 $id = 'id'; 859 $fname = 'firstname'; 860 } 861 846 862 847 863 if ($rs && !$rs->EOF) { … … 850 866 print_r($rs->fields); 851 867 } 852 if ($rs->fields[ 'id'] != 1) {Err("Error"); print_r($rs->fields);};853 if (trim($rs->fields[ 'firstname']) != 'Caroline') {print Err("Error 2"); print_r($rs->fields);};868 if ($rs->fields[$id] != 1) {Err("Error"); print_r($rs->fields);}; 869 if (trim($rs->fields[$fname]) != 'Caroline') {print Err("Error 2"); print_r($rs->fields);}; 854 870 855 871 $rs->MoveNext(); 856 if ($rs->fields[ 'id'] != 2) {Err("Error 3"); print_r($rs->fields);};872 if ($rs->fields[$id] != 2) {Err("Error 3"); print_r($rs->fields);}; 857 873 $rs->MoveNext(); 858 874 if (!$rs->EOF) { … … 862 878 } 863 879 864 print "<p>FETCH_MODE = ASSOC: Should get 1, Caroline </p>";880 print "<p>FETCH_MODE = ASSOC: Should get 1, Caroline ASSOC_CASE=".ADODB_ASSOC_CASE."</p>"; 865 881 $rs = $db->SelectLimit('select id,firstname from ADOXYZ order by id',2); 866 882 if ($rs && !$rs->EOF) { 867 if (ADODB_ASSOC_CASE == 2) { 868 $id = 'ID'; 869 $fname = 'FIRSTNAME'; 870 }else { 871 $id = 'id'; 872 $fname = 'firstname'; 873 } 883 874 884 if ($rs->fields[$id] != 1) {Err("Error 1"); print_r($rs->fields);}; 875 885 if (trim($rs->fields[$fname]) != 'Caroline') {Err("Error 2"); print_r($rs->fields);}; … … 888 898 $rs = $db->SelectLimit('select id,firstname from ADOXYZ order by id',1); 889 899 if ($rs && !$rs->EOF) { 890 if (isset($rs->fields[ 'id'])) Err("FETCH_NUM has ASSOC fields");900 if (isset($rs->fields[$id])) Err("FETCH_NUM has ASSOC fields"); 891 901 if ($rs->fields[0] != 1) {Err("Error 1"); print_r($rs->fields);}; 892 902 if (trim($rs->fields[1]) != 'Caroline') {Err("Error 2");print_r($rs->fields);}; … … 902 912 if ($rs && !$rs->EOF) { 903 913 $arr = $rs->GetRowAssoc(); 904 if ($arr['ID'] != 1) {Err("Error 1");print_r($arr);}; 905 if (trim($arr['FIRSTNAME']) != 'Caroline') {Err("Error 2"); print_r($arr);}; 914 915 if ($arr[strtoupper($id)] != 1) {Err("Error 1");print_r($arr);}; 916 if (trim($arr[strtoupper($fname)]) != 'Caroline') {Err("Error 2"); print_r($arr);}; 906 917 $rs->MoveNext(); 907 918 if (!$rs->EOF) Err("Error EOF"); … … 919 930 print "<p>GetCol Test</p>"; 920 931 $col = $db->GetCol('select distinct firstname from ADOXYZ order by 1'); 932 if (!is_array($col)) Err("Col size is wrong"); 933 if (trim($col[0]) != 'Alan' or trim($col[9]) != 'Yat Sun') Err("Col elements wrong"); 934 935 936 $col = $db->CacheGetCol('select distinct firstname from ADOXYZ order by 1'); 921 937 if (!is_array($col)) Err("Col size is wrong"); 922 938 if (trim($col[0]) != 'Alan' or trim($col[9]) != 'Yat Sun') Err("Col elements wrong"); … … 1087 1103 } 1088 1104 print "Testing GetAssoc() "; 1105 1106 1107 if ($db->dataProvider == 'mysql') { 1108 $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; 1109 $arr = $db->GetAssoc("SELECT 'adodb', '0'"); 1110 var_dump($arr); 1111 die(); 1112 } 1113 1089 1114 $savecrecs = $ADODB_COUNTRECS; 1090 1115 $ADODB_COUNTRECS = false; … … 1167 1192 $rs = $db->CacheExecute(6,"select distinct firstname,lastname from ADOXYZ"); 1168 1193 print_r($rs->fields); echo $rs->fetchMode;echo "<br>"; 1169 echo $rs->Fields( 'firstname');1194 echo $rs->Fields($fname); 1170 1195 1171 1196 $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; 1172 1197 $rs = $db->CacheExecute(6,"select distinct firstname,lastname from ADOXYZ"); 1173 1198 print_r($rs->fields);echo "<br>"; 1174 echo $rs->Fields( 'firstname');1199 echo $rs->Fields($fname); 1175 1200 $db->debug = false; 1176 1201 … … 1214 1239 echo "<p> GenID test: "; 1215 1240 for ($i=1; $i <= 10; $i++) 1216 echo "($i: ",$val = $db->GenID($db->databaseType.'abcseq 6' ,5), ") ";1241 echo "($i: ",$val = $db->GenID($db->databaseType.'abcseq7' ,5), ") "; 1217 1242 if ($val == 0) Err("GenID not supported"); 1218 1243 … … 1328 1353 print "</pre>"; 1329 1354 } 1330 print " CacheFlush ";1331 $db->CacheFlush();1355 #print " CacheFlush "; 1356 #$db->CacheFlush(); 1332 1357 1333 1358 $date = $db->SQLDate('d-m-M-Y-\QQ h:i:s A'); … … 1436 1461 else Err("Pivot sql error"); 1437 1462 1438 $pear = true; //true;1463 $pear = false; //true; 1439 1464 $db->debug=false; 1440 1465 … … 1710 1735 $$k = $v; 1711 1736 } 1712 if (strpos(PHP_VERSION,'5') === 0) { 1713 //$testaccess=1; 1714 //$testmssql = 1; 1715 //$testsqlite=1; 1716 } 1737 1717 1738 ?> 1718 1739 <html> … … 1730 1751 <a href=test-perf.php>Perf Monitor</a><p> 1731 1752 <?php 1732 include('./testdatabases.inc.php');1733 1734 echo "<br>vers=",ADOConnection::Version();1735 1753 1736 1754 1737 1755 include_once('../adodb-time.inc.php'); 1738 1756 if (isset($_GET['time'])) adodb_date_test(); 1757 flush(); 1758 1759 include_once('./testdatabases.inc.php'); 1760 1761 echo "<br>vers=",ADOConnection::Version(); 1762 1763 1739 1764 1740 1765 ?> 1741 <p><i>ADODB Database Library (c) 2000-20 07John Lim. All rights reserved. Released under BSD and LGPL, PHP <?php echo PHP_VERSION ?>.</i></p>1766 <p><i>ADODB Database Library (c) 2000-2012 John Lim. All rights reserved. Released under BSD and LGPL, PHP <?php echo PHP_VERSION ?>.</i></p> 1742 1767 </body> 1743 1768 </html>
Note: See TracChangeset
for help on using the changeset viewer.