PHPackages                             rain\_sunshine\_cloud/model - 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. rain\_sunshine\_cloud/model

ActiveLibrary

rain\_sunshine\_cloud/model
===========================

这是一个model调度类

015PHP

Since Jun 17Pushed 6y agoCompare

[ Source](https://github.com/RainSunshineCloud/model)[ Packagist](https://packagist.org/packages/rain_sunshine_cloud/model)[ RSS](/packages/rain-sunshine-cloud-model/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

### 一个Model驱动器封装类

[](#一个model驱动器封装类)

用法
--

[](#用法)

```

$sql = Sql::table('table')
            ->where('id','=',1)
            ->insert(['name'=>2,'id'=>1]);
            $model = Sql::table('t1');
$sql = $model->where('id','=',1)->insertAll([['name'=>2,'id'=>1],['id'=>2,'name'=>1]]);

use RainSunshineCloud\Sql;
use RainSunshineCloud\SqlException;
use RainSunshineCloud\Model;
use RainSunshineCloud\ModelException;

try {
    Model::setConfig([
        'uri'       => 'mysql',
        'db'        => '',
        'host'      => '',
        'port'      => '',
        'user'      => '',
        'password'  => '',
    ]);
    $model = Model::prefix('syf_')->table('user')->where('id',3)->delete();
} catch (DriverException $e) {
    echo $e->getMessage();
} catch (SqlException $e) {
    echo $e->getMessage();
} catch (ModelException $e) {
    echo $e->getMessage();
}

```

注意
--

[](#注意)

### Sql 封装的相关方法，请自行查看rain\_sunshine\_cloud/sql 包的相关介绍，也可以自行封装一个Sql的相关方法，通过属性Model::$SqlModel进行修改

[](#sql-封装的相关方法请自行查看rain_sunshine_cloudsql-包的相关介绍也可以自行封装一个sql的相关方法通过属性modelsqlmodel进行修改)

### Driver 驱动器采用的方法，请自行查看相关文档，现默认使用PDO作为驱动器,可以自行更改需继承DriverIngerface接口，通过方法setDriver()进行更改

[](#driver-驱动器采用的方法请自行查看相关文档现默认使用pdo作为驱动器可以自行更改需继承driveringerface接口通过方法setdriver进行更改)

### 该模型克隆时，会克隆Sql模型

[](#该模型克隆时会克隆sql模型)

### ModelAbstract 调度器，用户调度 Sql类和Driver类，以及自身的相关功能

[](#modelabstract-调度器用户调度-sql类和driver类以及自身的相关功能)

#### 需实现的方法有

[](#需实现的方法有)

```
    //查询
    protected abstract function select($mode);
    //查找一条
    protected abstract function find();
    //插入多条
    protected abstract function insertAll(array $data);
    //插入单条
    protected abstract function insert($data);
    //更新
    protected abstract function update(array $data);
    //删除
    protected abstract function delete();
    //替换
    protected abstract function replace(array $data);
    //insert on duplicate key update
    protected abstract function duplicate(array $insert_data,array $update_data);

```

##### 已经实现的有

[](#已经实现的有)

```
//获取最后执行的Sql语句
Model::getLastSql()
Model::getLastSql(true)

//获取Sql模型
$model->getSqlModel()

//设置driver 驱动参数
Model::setConfig

//设置驱动
Model::setDriver

//清空对象
$model ->close

```

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/041cb2d7e5d63d922726b229061fd63ca04abca4dce719fba94eb1dc4129aaea?d=identicon)[RainSunshineCloud](/maintainers/RainSunshineCloud)

---

Top Contributors

[![RainSunshineCloud](https://avatars.githubusercontent.com/u/32010961?v=4)](https://github.com/RainSunshineCloud "RainSunshineCloud (17 commits)")

### Embed Badge

![Health badge](/badges/rain-sunshine-cloud-model/health.svg)

```
[![Health](https://phpackages.com/badges/rain-sunshine-cloud-model/health.svg)](https://phpackages.com/packages/rain-sunshine-cloud-model)
```

PHPackages © 2026

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