minnis/medoo-plus 问题修复 & 功能扩展

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

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

minnis/medoo-plus

Composer 安装命令:

composer require minnis/medoo-plus

包简介

Medoo+, a wrapper to bring even more power to catfan/medoo - the lightweight PHP database framework to accelerate development

README 文档

README

A wrapper to bring even more power to catfan/medoo

the lightweight PHP database framework to accelerate development

Install

The package can be installed using composer:

composer require minnis/medoo-plus

Usage

This package extends catfan/medoo.

It is a drop-in replacement, just change your Medoo\Medoo namespaces to MINNIS\Medoo\Medoo

Medoo+

Improvements:

  • (mysql/mariadb) Connection option ATTR_EMULATE_PREPARES is now default set to false. Integer columns will now return integers instead of strings.
  • Mapping (data/column return types) of fetched data
  • \DateTime as return type on date/datetime/timestamp columns
  • Constants to map return types
  • Minor speed improvement

MAPS! (return type mapping)

Medoo has return type support by adding its type to the column name, like: `'is_active [Bool]'`.

In many cases this works fine but this method has a few drawbacks. These are solved by using a resultmap.

To use a resultmap add MAP (all uppercase) to the $where parameter on the select() or get() method, just like LIMIT, ORDER, etc:

$database->select('table', $columns, [
    'LIMIT' => 10,
    'MAP'   => [
        'column_name'  => Medoo::RETURN_BOOL,
        'other_column' => Medoo::RETURN_DATETIME,
    ],   
]);

Benefits

  • Mapping on wildcard * selects
  • Clean column names in $columns arrays
  • The contents of MAP array can by set by a single variable (easy re-usage)
  • Constants for autocompletion in your IDE
  • A new return type: DateTime object

DateTime

Getting strings from a Date, Datetime or Timestamp column serve little purpose. In most cases you will propably use the value to create a \DateTime object.

Now you can simply map it as return type using Medoo::RETURN_DATETIME.

This return type can be used on date, datetime, timestamp columns, as well on every column returning date[time] using yyyy-mm-dd [hh:mm:ss] notation or a numeric value (unix timestamp).

false (boolean) is returned if the source value is: null, false, an empty string, 0, '0000-00-00', '0000-00-00 00:00:00' and when the DateTime object could not be created due to a invalid value.

Example

<?php

use MINNIS\Medoo\Medoo;

require_once __DIR__ . '/../vendor/autoload.php';

$database = new Medoo(/* see medoo docs for details */);

// Default
$default_medoo = $database->select('users', [
    'username',
    'is_active',
    'signup_date',
], [
    'user_id' => 50,
]);

var_dump($default_medoo);

array(1) {
  [0] =>
  array(3) {
    'username' =>
    string(3) "foo"
    'is_active' =>
    string(1) "1"
    'signup_date' =>
    string(10) "2025-06-01"
  }
}

// Using MAP
$medoo_plus = $database->select('users', [
    'username',
    'is_active',
    'signup_date',
], [
    'user_id' => 50,
    'MAP'     => [
      'is_active'   => Medoo::RETURN_BOOL,
      'signup_date' => Medoo::RETURN_DATETIME,
    ]
]);

var_dump($medoo_plus);

array(1) {
  [0] =>
  array(3) {
    'username' =>
    string(3) "foo"
    'is_active' =>
    bool(true)
    'signup_date' =>
    class DateTime#1 (3) {
      public $date =>
      string(26) "2025-06-01 00:00:00.000000"
      public $timezone_type =>
      int(3)
      public $timezone =>
      string(16) "Europe/Amsterdam"
    }
  }
}

License

This package is under the MIT license.

Documentation

minnis/medoo-plus 适用场景与选型建议

minnis/medoo-plus 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 42 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 06 月 01 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「database」 「orm」 「mysql」 「sqlite」 「doctrine」 「postgresql」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 minnis/medoo-plus 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 minnis/medoo-plus 我们能提供哪些服务?
定制开发 / 二次开发

基于 minnis/medoo-plus 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-06-01