cathedral/db 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

cathedral/db

Composer 安装命令:

composer require cathedral/db

包简介

Database Layer database interfaces and classes.

README 文档

README

$Id$ ($Date$)

Database class for use with builder and its generated code.

Custom methods

There are a few custom methods you can create to easily modify your data before sending it to client.

  • customQueryOptions
    • runs prior to data access
    • lets you modify where clauses
    • check query string values
  • customResponseOptions
    • runs last, just prior to sending data
    • has full access to the json response object
  • getListPost
    • runs after data fetched from db
  • createPre
    • check data before db record gets created
/**
 * Gets the query string parameters for pagination
 *
 * @param array $options
 * @param array $params
 *
 * @return void
 */
public function customQueryOptions(&$options, $params): void {
    if (isset($params['fk_champions'])) $options['where']['fk_champions'] = intval($params['fk_champions']);
}

/**
 * Gets the query string parameters for pagination
 *
 * @param mixed $json
 * @return void
 */
public function customResponseOptions(&$json): void {
    /** @var JsonModel $json */
    $payload = $json->getVariable('payload');

    for ($i = 0; $i < \count($payload); $i++) $payload[$i]['champion'] = $this->_champions[$payload[$i]['fk_champions']];

    $json->setVariable('extra', ['champions' => $this->_champions]);
    $json->setVariable('payload', $payload);
}

/**
 * Modify the resultset
 *
 * @param mixed $data
 * @return void
 */
public function getListPost($data): void {
    $data->buffer();
    foreach($data as $d) $this->_champions[$d->Champion()->id] = $d->Champion()->name;
}

/**
 * Check data before creating record
 *
 * @param mixed $data
 * @return null|string error
 */
public function createPre(&$data): ?string {
    // check data
    return null;
}
    ```

## Auth configurations

...

统计信息

  • 总下载量: 38
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-12-03

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固