BVB Source Codes

The latest thinkphp v5.2 work order system Show Pgsql.class.php Source code

Return Download The latest thinkphp v5.2 work order system: download Pgsql.class.php Source code - Download The latest thinkphp v5.2 work order system Source code - Type:.php
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2006-2014 http://thinkphp.cn All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  8. // +----------------------------------------------------------------------
  9. // | Author: liu21st <liu21st@gmail.com>
  10. // +----------------------------------------------------------------------
  11.  
  12. namespace Think\Db\Driver;
  13. use Think\Db\Driver;
  14.  
  15. /**
  16.  * Pgsql数据库驱动
  17.  */
  18. class Pgsql extends Driver{
  19.  
  20.     /**
  21.      * 解析pdo连接的dsn信息
  22.      * @access public
  23.      * @param array $config 连接信息
  24.      * @return string
  25.      */
  26.     protected function parseDsn($config){
  27.         $dsn  =   'pgsql:dbname='.$config['database'].';host='.$config['hostname'];
  28.         if(!empty($config['hostport'])) {
  29.             $dsn  .= ';port='.$config['hostport'];
  30.         }
  31.         return $dsn;
  32.     }
  33.  
  34.     /**
  35.      * 取得数据表的字段信息
  36.      * @access public
  37.      * @return array
  38.      */
  39.     public function getFields($tableName) {
  40.         list($tableName) = explode(' ', $tableName);
  41.         $result =   $this->query('select fields_name as "field",fields_type as "type",fields_not_null as "null",fields_key_name as "key",fields_default as "default",fields_default as "extra" from table_msg('.$tableName.');');
  42.         $info   =   [];
  43.         if($result){
  44.             foreach ($result as $key => $val) {
  45.                 $info[$val['field']] = array(
  46.                     'name'    => $val['field'],
  47.                     'type'    => $val['type'],
  48.                     'notnull' => (bool) ($val['null'] === ''), // not null is empty, null is yes
  49.                     'default' => $val['default'],
  50.                     'primary' => (strtolower($val['key']) == 'pri'),
  51.                     'autoinc' => (strtolower($val['extra']) == 'auto_increment'),
  52.                 );
  53.             }
  54.         }
  55.         return $info;
  56.     }
  57.  
  58.     /**
  59.      * 取得数据库的表信息
  60.      * @access public
  61.      * @return array
  62.      */
  63.     public function getTables($dbName='') {
  64.         $result =   $this->query("select tablename as Tables_in_test from pg_tables where  schemaname ='public'");
  65.         $info   =   array();
  66.         foreach ($result as $key => $val) {
  67.             $info[$key] = current($val);
  68.         }
  69.         return $info;
  70.     }
  71.  
  72.     /**
  73.      * limit分析
  74.      * @access protected
  75.      * @param mixed $lmit
  76.      * @return string
  77.      */
  78.     public function parseLimit($limit) {
  79.         $limitStr    = '';
  80.         if(!empty($limit)) {
  81.             $limit  =   explode(',',$limit);
  82.             if(count($limit)>1) {
  83.                 $limitStr .= ' LIMIT '.$limit[1].' OFFSET '.$limit[0].' ';
  84.             }else{
  85.                 $limitStr .= ' LIMIT '.$limit[0].' ';
  86.             }
  87.         }
  88.         return $limitStr;
  89.     }
  90.  
  91. }
  92.  
downloadPgsql.class.php Source code - Download The latest thinkphp v5.2 work order system Source code
Related Source Codes/Software:
V3.3.6 Workerman high-performance PHP Socket (framework) - High performance PHP Socket framework Workerman re... 2017-05-03
The phosphor meeting room reservation system MRBS (loop reservation v16.0) - The phosphor meeting room reservation system MRBS ... 2017-05-03
IDC v5.2.3 agent center - IDC Centre IDC for exploitation is a PHP+MySQL age... 2017-05-03
Zen master v9.0.1 project management software - Zen is the first domestic open source project mana... 2017-05-03
Ray speed v7.03 employee files management system - Employee files project is various, and some conten... 2017-05-03
HITCMS Haitian responsive electronic mechanical v3.0 foreign trade website source code - HITCMS Haitian response electronic machinery trade... 2017-05-03
Ray v7.02 speed survey system - Lightning speed survey system is a. NET+MSSQL deve... 2017-05-03
Cool HITCMS reactive black v3.0 enterprise website source code - HITCMS-Haitian response black enterprises website ... 2017-05-03
WebOA v17.2 network office automation system - WebOA network using b/s structure development of o... 2017-05-03
Pure imitation of han site source code, one a 】 【 c9cms kernel v1.0 - Generic http://www.wufazhuce.com/Han one · Config... 2017-05-04
zone.js - Implements Zones for JavaScript ... 2017-05-11
dragonfly - A Ruby gem for on-the-fly processing - suitable fo... 2017-05-11
oh-my-fish - The Fishshell Framework. 2017-05-11
canvas-lms - The open LMS by Instructure, Inc. 2017-05-11
ledger - Double-entry accounting system with a command-line... 2017-05-11
Python - My Python Examples http://w... 2017-05-11
blade - 2017-05-11
LaZagne - Credentials recovery project 2017-05-10
Pull-to-Refresh.Rentals-iOS - This project aims to provide a simple and customiz... 2017-05-10
spoon - Distributing instrumentation tests to all your And... 2017-05-10

 Back to top