定制 mrmadclown/mnemosyne 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

mrmadclown/mnemosyne

最新稳定版本:v1.3

Composer 安装命令:

composer require mrmadclown/mnemosyne

包简介

Mnemosyne a PDO Database Layer

README 文档

README

License: MIT Latest Stable Version Total Downloads example workflow example workflow

This is a simple PDO based mysql Query Builder

Installation

composer require mrmadclown/mnemosyne

Usage

The Builder gets constructed by passing an instance of the PDO::class to the \MrMadClown\Mnemosyne\Builder::class

use \PDO;

$pdo = new \PDO();
$builder = new \MrMadClown\Mnemosyne\Builder($pdo);

With the Builder Object a mysql query can be build similar to how a query would be written:

...

$builder->select('*')->from('users')->where('id', 1);

Important

By default, the PDO Fetch Mode is set to PDO::FETCH_CLASS | PDO::FETCH_PROPS_LATE; which means you have to have a class which represents your table

#User.php
class User {
    public int $id;
    public string $name;
}

$builder->setClassName(User::class)->fetchAll(); // returns an array of Users

you can use the magic __set method to map your database columns into your model. If you don`t want a different FetchMode you can call $builder->setFetchMode(\PDO::FETCH_ASSOC) to change the fetch mode of the Builder instance.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-08-27