[李景山php]thinkphp核心源码注释|Sqlite.class.php
来源:互联网 发布:金蝶软件北京分公司 编辑:程序博客网 时间:2024/05/17 06:50
<?php// +----------------------------------------------------------------------// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]// +----------------------------------------------------------------------// | Copyright (c) 2006-2014 http://thinkphp.cn All rights reserved.// +----------------------------------------------------------------------// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )// +----------------------------------------------------------------------// | Author: liu21st <liu21st@gmail.com>// +----------------------------------------------------------------------namespace Think\Db\Driver;use Think\Db\Driver;/** * Sqlite数据库驱动 */class Sqlite extends Driver { /** * 解析pdo连接的dsn信息 * @access public * @param array $config 连接信息 * @return string */ protected function parseDsn($config){ $dsn = 'sqlite:'.$config['database']; return $dsn; } // 这个可以有,这个真心没见过 /** * 取得数据表的字段信息 * @access public * @return array */ public function getFields($tableName) { list($tableName) = explode(' ', $tableName); $result = $this->query('PRAGMA table_info( '.$tableName.' )'); $info = array(); if($result){ foreach ($result as $key => $val) { $info[$val['field']] = array( 'name' => $val['field'], 'type' => $val['type'], 'notnull' => (bool) ($val['null'] === ''), // not null is empty, null is yes 'default' => $val['default'], 'primary' => (strtolower($val['dey']) == 'pri'), 'autoinc' => (strtolower($val['extra']) == 'auto_increment'), ); } } return $info; } // 这个语句真心简单 /** * 取得数据库的表信息 * @access public * @return array */ public function getTables($dbName='') { $result = $this->query("SELECT name FROM sqlite_master WHERE type='table' " . "UNION ALL SELECT name FROM sqlite_temp_master " . "WHERE type='table' ORDER BY name"); $info = array(); foreach ($result as $key => $val) { $info[$key] = current($val); } return $info; } // 评论同上 /** * SQL指令安全过滤 * @access public * @param string $str SQL指令 * @return string */ public function escapeString($str) { return str_ireplace("'", "''", $str); } // 同上 /** * limit * @access public * @return string */ public function parseLimit($limit) { $limitStr = ''; if(!empty($limit)) { $limit = explode(',',$limit); if(count($limit)>1) { $limitStr .= ' LIMIT '.$limit[1].' OFFSET '.$limit[0].' '; }else{ $limitStr .= ' LIMIT '.$limit[0].' '; } } return $limitStr; } // 同上}// 这个很简单,没看懂,默认飘过了............
0 0
- [李景山php]thinkphp核心源码注释|Sqlite.class.php
- [李景山php]thinkphp核心源码注释|Sqlite.class.php
- [李景山php]thinkphp核心源码注释|View.class.php
- [李景山php]thinkphp核心源码注释|Think.class.php
- [李景山php]thinkphp核心源码注释|Template.class.php
- [李景山php]thinkphp核心源码注释|Storage.class.php
- [李景山php]thinkphp核心源码注释|Route.class.php
- [李景山php]thinkphp核心源码注释|Model.class.php
- [李景山php]thinkphp核心源码注释|Log.class.php
- [李景山php]thinkphp核心源码注释|Hook.class.php
- [李景山php]thinkphp核心源码注释|DB.class.php
- [李景山php]thinkphp核心源码注释|Controller.class.php
- [李景山php]thinkphp核心源码注释|Cache.class.php
- [李景山php]thinkphp核心源码注释|Build.class.php
- [李景山php]thinkphp核心源码注释|App.class.php
- [李景山php]thinkphp核心源码注释|Disaptcher.class.php
- [李景山php]thinkphp核心源码注释|Taglib.class.php
- [李景山php]thinkphp核心源码注释|Cx.class.php
- PHP图片上传程序(完整版)
- [李景山php]thinkphp核心源码注释|Oracle.class.php
- 指针及其应用(一)
- laravel 初见 安装 路由 模块化 2016.07.20回顾
- [李景山php]thinkphp核心源码注释|Pgsql.class.php
- [李景山php]thinkphp核心源码注释|Sqlite.class.php
- 【语言-批处理】批处理修改桌面 壁纸
- 内存缓存LruCache实现原理
- 由图与数的关系说起——兼谈XML语言的好处
- SQLite数据库安装及基本操作指南
- ACM找点问题
- [李景山php]thinkphp核心源码注释|Sqlsrv.class.php
- Linux crontab
- 素数因子两种方法的效率