blob: 5250c21cf17a0250f4edcb885421bff3e2aefff3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
<?php
/*
@author dhtmlx.com
@license GPL, see license.txt
*/
require_once("db_common.php");
/*! Implementation of DataWrapper for PostgreSQL
**/
class AdoDBDataWrapper extends DBDataWrapper{
protected $last_result;
public function query($sql){
LogMaster::log($sql);
if (is_array($sql)) {
$res = $this->connection->SelectLimit($sql['sql'], $sql['numrows'], $sql['offset']);
} else {
$res = $this->connection->Execute($sql);
}
if ($res===false) throw new Exception("ADODB operation failed\n".$this->connection->ErrorMsg());
$this->last_result = $res;
return $res;
}
public function get_next($res){
if (!$res)
$res = $this->last_result;
if ($res->EOF)
return false;
$row = $res->GetRowAssoc(false);
$res->MoveNext();
return $row;
}
protected function get_new_id(){
return $this->connection->Insert_ID();
}
public function escape($data){
return $this->connection->addq($data);
}
/*! escape field name to prevent sql reserved words conflict
@param data
unescaped data
@return
escaped data
*/
public function escape_name($data){
if ((strpos($data,"`")!==false || is_int($data)) || (strpos($data,".")!==false))
return $data;
return '`'.$data.'`';
}
protected function select_query($select,$from,$where,$sort,$start,$count){
if (!$from)
return $select;
$sql="SELECT ".$select." FROM ".$from;
if ($where) $sql.=" WHERE ".$where;
if ($sort) $sql.=" ORDER BY ".$sort;
if ($start || $count) {
$sql=array("sql"=>$sql,'numrows'=>$count, 'offset'=>$start);
}
return $sql;
}
}
?>
|