a64f43d2c1210250b88190a550892d86be06729d
[Packages/TYPO3.CMS.git] / typo3 / sysext / adodb / adodb / tests / test-active-recs2.php
1 <?php
2 error_reporting(E_ALL);
3 include('../adodb.inc.php');
4
5 include('../adodb-active-record.inc.php');
6
7 ###########################
8
9 $ADODB_ACTIVE_CACHESECS = 36;
10
11 $DBMS = @$_GET['db'];
12 if ($DBMS == 'mysql') {
13 $db = NewADOConnection('mysql://root@localhost/northwind');
14 } else if ($DBMS == 'postgres') {
15 $db = NewADOConnection('postgres');
16 $db->Connect("localhost","tester","test","test");
17 } else
18 $db = NewADOConnection('oci8://scott:natsoft@/');
19
20
21 $arr = $db->ServerInfo();
22 echo "<h3>$db->dataProvider: {$arr['description']}</h3>";
23
24 $arr = $db->GetActiveRecords('products',' productid<10');
25 adodb_pr($arr);
26
27 ADOdb_Active_Record::SetDatabaseAdapter($db);
28 if (!$db) die('failed');
29
30
31
32 $rec = new ADODB_Active_Record('photos');
33
34 $rec = new ADODB_Active_Record('products');
35
36 adodb_pr($rec->getAttributeNames());
37
38 echo "<hr>";
39
40
41 $rec->load('productid=2');
42 adodb_pr($rec);
43
44 $db->debug=1;
45
46
47 $rec->productname = 'Changie Chan'.rand();
48
49 $rec->insert();
50 $rec->update();
51
52 $rec->productname = 'Changie Chan 99';
53 $rec->replace();
54
55
56 $rec2 = new ADODB_Active_Record('products');
57 $rec->load('productid=3');
58 $rec->save();
59
60 $rec = new ADODB_Active_record('products');
61 $rec->productname = 'John ActiveRec';
62 $rec->notes = 22;
63 #$rec->productid=0;
64 $rec->discontinued=1;
65 $rec->Save();
66 $rec->supplierid=33;
67 $rec->Save();
68 $rec->discontinued=0;
69 $rec->Save();
70 $rec->Delete();
71
72 echo "<p>Affected Rows after delete=".$db->Affected_Rows()."</p>";
73 ?>