blob: 15ed95fe612acb7492034f117e12abc4f673ce1d (
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
73
|
<?php
/*
@author dhtmlx.com
@license GPL, see license.txt
*/
require_once("db_common.php");
/*! Implementation of DataWrapper for PDO
if you plan to use it for Oracle - use Oracle connection type instead
**/
class PHPCIDBDataWrapper extends DBDataWrapper{
private $last_result;//!< store result or last operation
public function query($sql){
LogMaster::log($sql);
$res=$this->connection->query($sql);
if ($res===false) {
throw new Exception("CI - sql execution failed");
}
if (is_object($res))
return new PHPCIResultSet($res);
return new ArrayQueryWrapper(array());
}
public function get_next($res){
$data = $res->next();
return $data;
}
public function get_new_id(){
return $this->connection->insert_id();
}
public function escape($str){
return $this->connection->escape_str($str);
}
public function escape_name($data){
return $this->connection->protect_identifiers($data);
}
}
class PHPCIResultSet{
private $is_result_done = false;
private $res;
private $start;
private $count;
public function __construct($res){
if(is_bool($res)) {
$this->$is_result_done = true;
return $this;
}
$this->res = $res;
$this->start = $res->current_row;
$this->count = $res->num_rows();
}
public function next(){
if($this->is_result_done)
return null;
if ($this->start != $this->count){
return $this->res->row($this->start++,'array');
} else {
$this->res->free_result();
return null;
}
}
}
?>
|