diff options
author | Kirylka <kirylanoshko@gmail.com> | 2015-03-31 17:56:47 +0300 |
---|---|---|
committer | Kirylka <kirylanoshko@gmail.com> | 2015-03-31 17:56:47 +0300 |
commit | f5f99c335707d9b11d40f1eb0f6ddb5a993fd31a (patch) | |
tree | d9c0d3532ec9f0f2fb68e31d2611282ae0642181 /codebase/db_postgre.php | |
parent | 458f0aead573842f1df00ce2ae00334c27f66585 (diff) | |
download | connector-php-f5f99c335707d9b11d40f1eb0f6ddb5a993fd31a.zip connector-php-f5f99c335707d9b11d40f1eb0f6ddb5a993fd31a.tar.gz connector-php-f5f99c335707d9b11d40f1eb0f6ddb5a993fd31a.tar.bz2 |
Creating a new connector for yii2.
Diffstat (limited to 'codebase/db_postgre.php')
-rw-r--r-- | codebase/db_postgre.php | 73 |
1 files changed, 0 insertions, 73 deletions
diff --git a/codebase/db_postgre.php b/codebase/db_postgre.php deleted file mode 100644 index a7d1598..0000000 --- a/codebase/db_postgre.php +++ /dev/null @@ -1,73 +0,0 @@ -<?php -/* - @author dhtmlx.com - @license GPL, see license.txt -*/ -require_once("db_common.php"); -/*! Implementation of DataWrapper for PostgreSQL -**/ -class PostgreDBDataWrapper extends DBDataWrapper{ - public function query($sql){ - LogMaster::log($sql); - - $res=pg_query($this->connection,$sql); - if ($res===false) throw new Exception("Postgre - sql execution failed\n".pg_last_error($this->connection)); - - return $res; - } - - 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.=" OFFSET ".$start." LIMIT ".$count; - return $sql; - } - - public function get_next($res){ - return pg_fetch_assoc($res); - } - - public function get_new_id(){ - $res = pg_query( $this->connection, "SELECT LASTVAL() AS seq"); - $data = pg_fetch_assoc($res); - pg_free_result($res); - return $data['seq']; - } - - public function escape($data){ - //need to use oci_bind_by_name - return pg_escape_string($this->connection,$data); - } - - public function tables_list() { - $sql = "SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'"; - $res = pg_query($this->connection, $sql); - $tables = array(); - while ($table = pg_fetch_assoc($res)) { - $tables[] = $table['table_name']; - } - return $tables; - } - - public function fields_list($table) { - $sql = "SELECT * FROM information_schema.constraint_column_usage"; - $result = pg_query($this->connection, $sql); - $field = pg_fetch_assoc($result); - $id = $field['column_name']; - - $sql = "SELECT * FROM information_schema.columns WHERE table_name ='".$table."';"; - $result = pg_query($this->connection, $sql); - $fields = array(); - $id = ""; - while ($field = pg_fetch_assoc($result)) { - $fields[] = $field["column_name"]; - } - return array('fields' => $fields, 'key' => $id ); - } -} -?>
\ No newline at end of file |