1 Star 0 Fork 10

莫生 / 微擎数据库框架

forked from yoby / 微擎数据库框架 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

PDO封装方法

更新到了微擎最新1.7,使用方法与微擎一样,不过调用方式采用的是命名空间的方法.

安装方法

composer require logoove/pdo dev-master

使用方法

use logoove\pdo\Pdo;
$db = new Pdo('localhost','root','111','3306','tp','oauth_');//主机地址,数据库帐号,密码,端口,表名,表前缀
var_dump($db->get('users'));//查询一条数据
$db->debug();//显示调试语句

更多介绍

表名 
$db->tablename('mc_members')
查询一条数据
$db->get('yoby_demo',['id'=>1]);
$db->get('yoby_demo',['id'=>1],['title','num']);返回特定字段
$db->get('yoby_demo',[],['count(*) as z','title','num','max(num)']);
$db->fetch("SELECT username, uid FROM ".tablename('users')." WHERE uid = :uid LIMIT 1", array(':uid' => 1));
查询单字段
$db->getcolumn('yoby_demo',['id'=>1],'title');
$db->fetchcolumn("SELECT COUNT(*) FROM ".tablename('users'));
查询多条记录
表名,条件,返回字段,主键,排序,限制条数
$db->getall('yoby_demo',[],[],'','id desc','LIMIT '.($pindex-1)* $psize.','.$psize); 
$db->fetchall("SELECT username, uid FROM ".tablename('users'), []);
插入数据,第二个参数数组
$db->insert('yoby_demo',[]);
$id = $db->insertid();插入id
修改
$db->update('yoby_demo',['num +='=>1],['id'=>1]);
删除
$db->delete('yoby_demo',['id'=>1]);
执行sql
$db->query("DELETE FROM ".tablename('users')." WHERE uid = :uid", array(':uid' => 2));
支持多条sql用分号隔开
$db->run($sql);
显示调试语句
$db->debug();
检测某个字段是否存在
$db->fieldexists('shopping_goods', 'credit');
检测某个表是否存在
$db->tableexists($tablename)
检测表是否为空
$db->exists($tb)
获取数据条数
$db->count($tb,['id'=>1])
MIT License Copyright (c) 2017 Yoby Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

pdo的一个封装,方法名全部同微擎1.7+,提取自微擎,完全同微擎一样使用 展开 收起
PHP
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
PHP
1
https://gitee.com/mscsoft/pdo.git
git@gitee.com:mscsoft/pdo.git
mscsoft
pdo
微擎数据库框架
master

搜索帮助