Line | |
---|
1 | <?php |
---|
2 | /////////////////////////////////////////////////////////////////////// |
---|
3 | // We dont use ths db class any more, and use the egroupware db // |
---|
4 | // class instead, rewritten by Shang Wenbin <wbsh@realss.com> // |
---|
5 | /////////////////////////////////////////////////////////////////////// |
---|
6 | |
---|
7 | //include $settings->_ADOdbPath . "adodb.inc.php"; |
---|
8 | |
---|
9 | class DatabaseAccess |
---|
10 | { |
---|
11 | var $db; |
---|
12 | /** |
---|
13 | * just copy the existent class $GLOBALS['phpgw']->db |
---|
14 | */ |
---|
15 | function connect() |
---|
16 | { |
---|
17 | copyobj($GLOBALS['phpgw']->db,$this->db); |
---|
18 | } |
---|
19 | |
---|
20 | /** |
---|
21 | * always return true |
---|
22 | */ |
---|
23 | function ensureConnected() |
---|
24 | { |
---|
25 | if(!is_object($this->db)) |
---|
26 | { |
---|
27 | $this->connect(); |
---|
28 | } |
---|
29 | return true; |
---|
30 | } |
---|
31 | |
---|
32 | function getResultArray($queryStr) |
---|
33 | { |
---|
34 | $resArr = array(); |
---|
35 | |
---|
36 | $res = $this->db->query($queryStr,__LINE__,__FILE__); |
---|
37 | $resArr = $res->GetArray(); |
---|
38 | $res->Close(); |
---|
39 | return $resArr; |
---|
40 | } |
---|
41 | |
---|
42 | /** |
---|
43 | * seems only used for update query |
---|
44 | */ |
---|
45 | function getResult($queryStr) |
---|
46 | { |
---|
47 | return $this->db->query($queryStr,__LINE__,__FILE__); |
---|
48 | } |
---|
49 | |
---|
50 | /** |
---|
51 | * get the last insert id |
---|
52 | * @param string $table |
---|
53 | * @param string $column |
---|
54 | * @return int |
---|
55 | */ |
---|
56 | function getInsertID($table,$column) |
---|
57 | { |
---|
58 | return $this->db->get_last_insert_id($table,$column); |
---|
59 | } |
---|
60 | |
---|
61 | } |
---|
62 | |
---|
63 | |
---|
64 | $db = new DatabaseAccess(); |
---|
65 | $db->connect(); |
---|
66 | |
---|
67 | $GLOBALS['mydms']->db = new DatabaseAccess(); |
---|
68 | $GLOBALS['mydms']->db->connect(); |
---|
69 | |
---|
70 | ?> |
---|
Note: See
TracBrowser
for help on using the repository browser.