diff options
author | dmitry-radyno <dmitry.radyno@gmail.com> | 2012-12-04 13:51:02 +0200 |
---|---|---|
committer | dmitry-radyno <dmitry.radyno@gmail.com> | 2012-12-04 13:51:02 +0200 |
commit | b3379dafcc6f3df12c63563a2a8123759c180c16 (patch) | |
tree | 2a5546d18aab56fa3c810f885de129393ac707d9 /codebase | |
parent | 2fc255776e42d3a39cc83a0ea90ee4f60e75f0eb (diff) | |
download | connector-php-b3379dafcc6f3df12c63563a2a8123759c180c16.zip connector-php-b3379dafcc6f3df12c63563a2a8123759c180c16.tar.gz connector-php-b3379dafcc6f3df12c63563a2a8123759c180c16.tar.bz2 |
adodb database driver
Diffstat (limited to 'codebase')
-rw-r--r-- | codebase/db_adodb.php | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/codebase/db_adodb.php b/codebase/db_adodb.php new file mode 100644 index 0000000..5250c21 --- /dev/null +++ b/codebase/db_adodb.php @@ -0,0 +1,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; + } + +} +?>
\ No newline at end of file |