merge in branch for direct messaging integration by EMR Direct
[openemr.git] / library / adodb / tests / test-active-recs2.php
blobd35751e99f7b8e0115db744c40d0b79724da7a34
1 <?php
2 error_reporting(E_ALL);
3 include('../adodb.inc.php');
5 include('../adodb-active-record.inc.php');
7 ###########################
9 $ADODB_ACTIVE_CACHESECS = 36;
11 $DBMS = @$_GET['db'];
13 $DBMS = 'mysql';
14 if ($DBMS == 'mysql') {
15 $db = NewADOConnection('mysql://root@localhost/northwind');
16 } else if ($DBMS == 'postgres') {
17 $db = NewADOConnection('postgres');
18 $db->Connect("localhost","tester","test","test");
19 } else
20 $db = NewADOConnection('oci8://scott:natsoft@/');
23 $arr = $db->ServerInfo();
24 echo "<h3>$db->dataProvider: {$arr['description']}</h3>";
26 $arr = $db->GetActiveRecords('products',' productid<10');
27 adodb_pr($arr);
29 ADOdb_Active_Record::SetDatabaseAdapter($db);
30 if (!$db) die('failed');
35 $rec = new ADODB_Active_Record('photos');
37 $rec = new ADODB_Active_Record('products');
40 adodb_pr($rec->getAttributeNames());
42 echo "<hr>";
45 $rec->load('productid=2');
46 adodb_pr($rec);
48 $db->debug=1;
51 $rec->productname = 'Changie Chan'.rand();
53 $rec->insert();
54 $rec->update();
56 $rec->productname = 'Changie Chan 99';
57 $rec->replace();
60 $rec2 = new ADODB_Active_Record('products');
61 $rec->load('productid=3');
62 $rec->save();
64 $rec = new ADODB_Active_record('products');
65 $rec->productname = 'John ActiveRec';
66 $rec->notes = 22;
67 #$rec->productid=0;
68 $rec->discontinued=1;
69 $rec->Save();
70 $rec->supplierid=33;
71 $rec->Save();
72 $rec->discontinued=0;
73 $rec->Save();
74 $rec->Delete();
76 echo "<p>Affected Rows after delete=".$db->Affected_Rows()."</p>";