PHPackages                             hustnaive/pdo-db - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. hustnaive/pdo-db

ActiveLibrary

hustnaive/pdo-db
================

162PHP

Since May 19Pushed 9y ago1 watchersCompare

[ Source](https://github.com/hustnaive/pdo-db)[ Packagist](https://packagist.org/packages/hustnaive/pdo-db)[ RSS](/packages/hustnaive-pdo-db/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

pdo-db
======

[](#pdo-db)

pdo-db基于PDO API进行二次封装，主要封装了一下常见的CRUD操作，避免自己写sql。关于PDO库的使用，请移步：

同时，这个封装参考了yii的db的api接口方式，熟悉yii的db-api的人可以较快的入手。

usage
=====

[](#usage)

`composer require --dev "hustnaive/pdo-db"`

instance
--------

[](#instance)

```
$db = new \fangl\db\Connection($dsn, $username, $password);

```

目前只测试了mysql:开头的dsn，其他的没有经过测试，大家如果测试有bug，可以告诉我。

query
-----

[](#query)

```
$db->createCommand($sql,$params=[])->queryXXX();

$db->createCommand('select * from dual where id = :ID',[':ID'=>1])->queryOne();

$db->createCommand('select * from dual')->queryAll();

$db->createCommand('select id from dual')->queryColumn();

```

execute
-------

[](#execute)

```
$db->createCommand($sql,$params=[])->execute();

```

crud
----

[](#crud)

```
$db->createCommand()->insert($table,$columns)->execute();

$db->createCommand()->update($table,$columns,$condition,$params=[])->execute();

$db->createCommand()->delete($table,$condtion,$params)->execute();

$db->createCommand()->truncateTable($table)->execute();

$db->createCommand()->batchInsert($table,$data,$fields);

```

transaction
-----------

[](#transaction)

```
$db->beginTransaction();

//do some thing

if($isOk) {
	$db->commit();
}
else {
	$db->rollback();
}

```

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community5

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/f7f00f69a5bb307f6151a145b72c321069dbd7b35de071100810063589f10def?d=identicon)[hustnaive](/maintainers/hustnaive)

### Embed Badge

![Health badge](/badges/hustnaive-pdo-db/health.svg)

```
[![Health](https://phpackages.com/badges/hustnaive-pdo-db/health.svg)](https://phpackages.com/packages/hustnaive-pdo-db)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
