diff options
author | Stanislau Wolski <stanislau.wolski@gmail.com> | 2013-10-18 14:02:16 +0300 |
---|---|---|
committer | Stanislau Wolski <stanislau.wolski@gmail.com> | 2013-10-18 14:02:16 +0300 |
commit | c2e1fd58b0c848118cf8554de50f788199d609e2 (patch) | |
tree | bd30b3b7de59b34120705465e8628a740cdb513d /codebase/connector/db_phpci.php | |
download | scheduler-c2e1fd58b0c848118cf8554de50f788199d609e2.zip scheduler-c2e1fd58b0c848118cf8554de50f788199d609e2.tar.gz scheduler-c2e1fd58b0c848118cf8554de50f788199d609e2.tar.bz2 |
[add] version 4.0v4.0.0
Diffstat (limited to 'codebase/connector/db_phpci.php')
-rw-r--r-- | codebase/connector/db_phpci.php | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/codebase/connector/db_phpci.php b/codebase/connector/db_phpci.php new file mode 100644 index 0000000..b9a5879 --- /dev/null +++ b/codebase/connector/db_phpci.php @@ -0,0 +1,63 @@ +<?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"); + } + + return new PHPCIResultSet($res); + } + + 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 $res; + private $start; + private $count; + + public function __construct($res){ + $this->res = $res; + $this->start = $res->current_row; + $this->count = $res->num_rows; + } + public function next(){ + if ($this->start != $this->count){ + return $this->res->row($this->start++,'array'); + } else { + $this->res->free_result(); + return null; + } + } +} +?>
\ No newline at end of file |