Skip to content

shuiguang/simpleMysql

Repository files navigation

simpleMysql

simple mysql driver for php

常用操作:

//从配置新建数据库连接

$db = new DB($db_config);

//统计数据表总记录行数,返回整型数字

$total = $db -> table($db_table) -> total();

//查询一条记录,返回一维数组

$task = $db -> table($db_table) -> where(array('id' => 1)) -> find();

//查询多条记录,返回二维数组

$tasks = $db -> table($db_table) -> limit('2,3') -> order('id desc') -> select();

//新增一条记录

$arr = array( 'data' => 'test', );

$last_insert_id = $db -> table($db_table) -> insert($arr);

//更新一条记录

$arr = array( 'id' => $last_insert_id, 'data' => 'ok', );

$db -> table($db_table) -> where(array('id' => $last_insert_id)) -> update($arr);

//删除一条记录

$db -> table($db_table) -> where(array('id' => $last_insert_id)) -> delete();

//新特性:MyISAM写锁定和读锁定

$db -> writeLock($db_table);

$db -> writeLock($db_table);

//解锁

$db -> unlock();

About

simple mysql driver for php

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages