PHPackages                             tenglin/sqlite3-database-class - 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. [Database &amp; ORM](/categories/database)
4. /
5. tenglin/sqlite3-database-class

ActiveLibrary[Database &amp; ORM](/categories/database)

tenglin/sqlite3-database-class
==============================

Wrapper for a PHP sqlite3 class, which utilizes sqlite3 and prepared statements.

1.0.0(5y ago)2421[2 PRs](https://github.com/Mr-Tenglin/sqlite3-database-class/pulls)MITPHPPHP &gt;=5.3.0

Since Jul 28Pushed 2y agoCompare

[ Source](https://github.com/Mr-Tenglin/sqlite3-database-class)[ Packagist](https://packagist.org/packages/tenglin/sqlite3-database-class)[ RSS](/packages/tenglin-sqlite3-database-class/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

sqlite3-database-class
======================

[](#sqlite3-database-class)

> 这项目可能会没头没尾, 就是写起来给自己通过 `Composer` 加载到项目中使用而已.

通过 `Composer` 安装
----------------

[](#通过-composer-安装)

```
composer require tenglin/sqlite3-database-class

```

函数说明
----

[](#函数说明)

```
public create(table, data) -- 加数据
public update(table, data [, array = [] ] ) -- 更新数据
public delete(table [, array = [] ] ) -- 删除数据
public detail(table [, array = [] ] ) -- 查询单数据
public items(table [, limit = [] [, &callback = [] [, columns = '*' ] ] ] ) -- 查询列表数据
public join(table, condition [, type = 'INNER' ] ) -- 多表连接
public where(prop, value [, operator = '='] ) -- and 查询
public orwhere(prop, value [, operator = '='] ) -- or 查询
public orderby(field [, direction = 'DESC'] ) -- 排序

```

使用 sqlite3-database-class
-------------------------

[](#使用-sqlite3-database-class)

### 接入sqlite3类

[](#接入sqlite3类)

```
require_once('sqlite3db.php');
```

### 调用sqlite3类

[](#调用sqlite3类)

```
$db = new SQLite3DB('./data.db', 'ejcms_');

// 或是

$db = new SQLite3DB();
$db->dbfile = './data.db';
$db->prefix = 'ejcms_';
```

### 加数据

[](#加数据)

```
$id = $db->create('user', [
    'name' => 'sqlite'
]);
// INSERT INTO [ejcms_user] (name) VALUES ('sqlite');
print_r($id);
```

### 批量加数据

[](#批量加数据)

```
$ids = $db->create('user', [
    [
        'name' => 'sqlite'
    ], [
        'name' => 'abc'
    ], [
        'name' => 'sqlite3'
    ],
]);
// INSERT INTO [ejcms_user] (name) VALUES ('sqlite');
// INSERT INTO ......
print_r($ids);
```

### 更新数据

[](#更新数据)

```
$db->update('user', [
    'name' => 'database'
], ['id' => '1']);
// UPDATE ejcms_user SET [name] = 'database' WHERE id = '1';

// 或是

$db->where('id', [1, 2, 3], 'in');
$db->update('user', [
    'name' => 'database'
]);
// UPDATE ejcms_user SET [name] = 'database' WHERE id in ('1', '2', '3');
```

### 删除数据

[](#删除数据)

```
$db->delete('user', ['id' => '1']);
// DELETE FROM [ejcms_user] WHERE id = '1';

// 或是

$db->where('id', [1, 2, 3], 'in');
$db->delete('user');
// DELETE FROM [ejcms_user] WHERE id in ('1', '2', '3');
```

### 查询单条数据

[](#查询单条数据)

```
$result = $db->detail('user', ['id' => '1']);
// SELECT * FROM [ejcms_user] WHERE id = '1' LIMIT 1;
print_r($result);

// 或是

$db->join('user1 b', 'a.id = b.id', 'left');
$result = $db->detail('user a', ['a.id' => '1']);
// SELECT * FROM [ejcms_user a] left JOIN user1 b ON a.id = b.id WHERE a.id = '1' LIMIT 1;
print_r($result);

// 或是

$tables = [];
$tables['table'] = 'user a';
$tables['join'] = ['table' => 'user1 b', 'condition' => 'a.id = b.id', 'type' => 'left'];
$result = $db->detail($tables, ['a.id' => '1']);
// SELECT * FROM [ejcms_user a] left JOIN user1 b ON a.id = b.id WHERE a.id = '1' LIMIT 1;
print_r($result);
```

### 查询列表

[](#查询列表)

```
$db->where('cid', 1);
$result = $db->items('user');
// SELECT * FROM [ejcms_user] WHERE cid = '1';
print_r($result);
```

// 或是

```
$tables = [];
$tables['table'] = 'user a';
$tables['join'] = ['table' => 'user1 b', 'condition' => 'a.id = b.id', 'type' => 'left'];
$db->where('a.cid', 1);
$db->where('a.name', 'sql%', 'like');
$db->orwhere('a.name', 'data');
$db->orderby('a.id', 'desc');
$result = $db->items($tables);
// SELECT * FROM [ejcms_user a] left JOIN user1 b ON a.id = b.id WHERE a.cid = '1' AND a.name like 'sql%' OR a.name = 'data' ORDER BY a.id DESC;
print_r($result);
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2120d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/bc7d4a75476441ecaa778525fe3ed5a80f6f729865dba464f28f485d9b23a48c?d=identicon)[Mr-Tenglin](/maintainers/Mr-Tenglin)

---

Top Contributors

[![Mr-Tenglin](https://avatars.githubusercontent.com/u/31702375?v=4)](https://github.com/Mr-Tenglin "Mr-Tenglin (18 commits)")

---

Tags

phpdatabasesqlite3

### Embed Badge

![Health badge](/badges/tenglin-sqlite3-database-class/health.svg)

```
[![Health](https://phpackages.com/badges/tenglin-sqlite3-database-class/health.svg)](https://phpackages.com/packages/tenglin-sqlite3-database-class)
```

###  Alternatives

[popphp/pop-db

Pop Db Component for Pop PHP Framework

1814.6k11](/packages/popphp-pop-db)[modul-is/orm

Lightweight hybrid ORM/Explorer

1118.1k](/packages/modul-is-orm)[jonas-elias/hyperf-oracle

A oracle handler for hyperf/database.

102.0k](/packages/jonas-elias-hyperf-oracle)

PHPackages © 2026

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