ChangeLog
[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
33 $rec = new ADODB_Active_Record('photos');
34
35 $rec = new ADODB_Active_Record('products');
36
37
38 adodb_pr($rec->getAttributeNames());
39
40 echo "<hr>";
41
42
43 $rec->load('productid=2');
44 adodb_pr($rec);
45
46 $db->debug=1;
47
48
49 $rec->productname = 'Changie Chan'.rand();
50
51 $rec->insert();
52 $rec->update();
53
54 $rec->productname = 'Changie Chan 99';
55 $rec->replace();
56
57
58 $rec2 = new ADODB_Active_Record('products');
59 $rec->load('productid=3');
60 $rec->save();
61
62 $rec = new ADODB_Active_record('products');
63 $rec->productname = 'John ActiveRec';
64 $rec->notes = 22;
65 #$rec->productid=0;
66 $rec->discontinued=1;
67 $rec->Save();
68 $rec->supplierid=33;
69 $rec->Save();
70 $rec->discontinued=0;
71 $rec->Save();
72 $rec->Delete();
73
74 echo "<p>Affected Rows after delete=".$db->Affected_Rows()."</p>";
75 ?>