您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

PHP操作SQLITE

2024/3/24 21:10:38发布25次查看
一直以来,我们操作sqlite,都是基于php默认的sqlite操作模块。 今天介绍一个可以操作sqlite2,和sqlite3的php类,此为我封装的。 ?phpabstract class db{public static function factory($type){return call_user_func(array($type , getinstance));}//查询
一直以来,我们操作sqlite,都是基于php默认的sqlite操作模块。
今天介绍一个可以操作sqlite2,和sqlite3的php类,此为我封装的。
pdo = new pdo($sqlitedsn);//采用pdo操作 } public static function getinstance(){ if(is_null(self::$link)){ self::$link = new self(); } return self::$link; } public function getarray($query){ $return = array(); $rs = $this->pdo->query($query) or die(print_r($this->pdo->errorinfo(), true)); $return = $rs->fetchall(); return $return; } public function exec($query){ $result = $this->pdo->exec($query) or die(print_r($this->pdo->errorinfo(), true)); return $result; } public function getinsertid($query){ $result = $this->pdo->exec($query); return $result; } }
如果想使用上述代码,只要在你的项目中引入这两个文件,或这两段代码。$db = db::factory('sqlite');$db->getarray('select * from table');$db->exec('insert into table values(aa , bb)');
不过如果要使用pdo,请确保你的服务器支持如下显示。
本人淘宝店地址:图米网络http://www.tome178.com or tome178.taobao.com
如果要做企业站或模板站,请直接联系我。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product