Documentation TYPO3 par Ameos |
00001 <?php 00002 error_reporting(E_ALL); 00003 include('../adodb.inc.php'); 00004 00005 include('../adodb-active-record.inc.php'); 00006 00007 ########################### 00008 00009 $ADODB_ACTIVE_CACHESECS = 36; 00010 00011 $DBMS = @$_GET['db']; 00012 if ($DBMS == 'mysql') { 00013 $db = NewADOConnection('mysql://root@localhost/northwind'); 00014 } else if ($DBMS == 'postgres') { 00015 $db = NewADOConnection('postgres'); 00016 $db->Connect("localhost","tester","test","test"); 00017 } else 00018 $db = NewADOConnection('oci8://scott:natsoft@/'); 00019 00020 00021 $arr = $db->ServerInfo(); 00022 echo "<h3>$db->dataProvider: {$arr['description']}</h3>"; 00023 00024 $arr = $db->GetActiveRecords('products',' productid<10'); 00025 adodb_pr($arr); 00026 00027 ADOdb_Active_Record::SetDatabaseAdapter($db); 00028 if (!$db) die('failed'); 00029 00030 00031 00032 00033 $rec = new ADODB_Active_Record('photos'); 00034 00035 $rec = new ADODB_Active_Record('products'); 00036 00037 00038 adodb_pr($rec->getAttributeNames()); 00039 00040 echo "<hr>"; 00041 00042 00043 $rec->load('productid=2'); 00044 adodb_pr($rec); 00045 00046 $db->debug=1; 00047 00048 00049 $rec->productname = 'Changie Chan'.rand(); 00050 00051 $rec->insert(); 00052 $rec->update(); 00053 00054 $rec->productname = 'Changie Chan 99'; 00055 $rec->replace(); 00056 00057 00058 $rec2 = new ADODB_Active_Record('products'); 00059 $rec->load('productid=3'); 00060 $rec->save(); 00061 00062 $rec = new ADODB_Active_record('products'); 00063 $rec->productname = 'John ActiveRec'; 00064 $rec->notes = 22; 00065 #$rec->productid=0; 00066 $rec->discontinued=1; 00067 $rec->Save(); 00068 $rec->supplierid=33; 00069 $rec->Save(); 00070 $rec->discontinued=0; 00071 $rec->Save(); 00072 $rec->Delete(); 00073 00074 echo "<p>Affected Rows after delete=".$db->Affected_Rows()."</p>"; 00075 ?>