承接 dandylion/advancedmedoo 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

dandylion/advancedmedoo

Composer 安装命令:

composer require dandylion/advancedmedoo

包简介

Adds extra features to Medoo

README 文档

README

Welcome to Advanced Medoo, a powerful extension for Medoo that takes your PHP database interactions to the next level. Say goodbye to repetitive database code and hello to a more efficient way of working with databases!

Features

  • Custom Column Selection: Advanced Medoo allows you to select columns in a more versatile way, making it easier to fetch the data you need.
  • Patch and Sync Functions: Simplify data synchronization with patching and syncing functions, designed to streamline your workflow.
  • Column Similarity Search: Easily determine how similar a specific column is to a given string with the "SIMILAR" function.

Installation

You can quickly install Advanced Medoo using Composer. This will also automatically install Medoo.

composer require dandylion/advancedmedoo

Usage

Getting started with Advanced Medoo is a breeze. Here's an example of how to use it:

use Dandylion\AdvancedMedoo;

// Initialize Advanced Medoo with your database configuration
$database = new AdvancedMedoo([
    'database_type' => 'mysql',
    'database_name' => 'your_database',
    'server' => 'localhost',
    'username' => 'your_username',
    'password' => 'your_password'
]);

Select all columns from table

$database->select(
    'user',
    '[>]post'=>'user_id'
    [
        'user.name'
        'post.*'
    ]
);
//[{
//    "name": "my_name",
//    "user_id": 1,
//    "text": "post_text"
//    "date": "01/01/1970"
//}]

/* You can also put text in brackets to prepend a string in front of all the columns incase of duplicate column names */

$database->select(
    'user',
    '[>]post'=>'user_id'
    [
        'user.name'
        'post.* (post_)'
    ]
);

//[{
//    "name": "my_name",
//    "post_user_id": 1,
//    "post_text": "post_text",
//    "post_date": "01/01/1970"
//}]

Patch method (allows you to update or create a record without having to check if the record exists)

//[
//    {
//        "user_id": 1,
//        "post_id": 1,
//        "text": "This is my first post",
//        "privacy": "public"
//    },
//    {
//        "user_id": 2,
//        "post_id": 2,
//        "text": "This is a different user post",
//        "privacy": "public"
//    }
//]
$database->patch(
    'posts',
    [
        [
            "user_id": 1,
            "post_id": 1,
            "text": "This is my first post",
            "privacy": "private"
        ],
        [
            "user_id": 1,
            "post_id": 3,
            "text": "This is my second post",
            "privacy": "public"
        ]
    ],
    [ // uses AND to check if record exists
        "user_id",
        "post_id"
    ]
);
//[
//    {
//        "user_id": 1,
//        "post_id": 1,
//        "text": "This is my first post",
//        "privacy": "private"
//    },
//    {
//        "user_id": 2,
//        "post_id": 2,
//        "text": "This is a different user post",
//        "privacy": "public"
//    },
//    {
//        "user_id": 1,
//        "post_id": 3,
//        "text": "This is my second post",
//        "privacy": "public"
//    }
//]

Sync method (same as patch method except will also delete records not found)

//[
//    {
//        "user_id": 1,
//        "post_id": 1,
//        "text": "This is my first post",
//        "privacy": "public"
//    },
//    {
//        "user_id": 2,
//        "post_id": 2,
//        "text": "This is a different user post",
//        "privacy": "public"
//    }
//]
$database->patch(
    'posts',
    [
        [
            "user_id": 1,
            "post_id": 1,
            "text": "This is my first post",
            "privacy": "private"
        ],
        [
            "user_id": 1,
            "post_id": 3,
            "text": "This is my second post",
            "privacy": "public"
        ]
    ],
    [ // uses AND to check if record exists
        "user_id",
        "post_id"
    ]
);
//[
//    {
//        "user_id": 1,
//        "post_id": 1,
//        "text": "This is my first post",
//        "privacy": "private"
//    },
//    {
//        "user_id": 1,
//        "post_id": 3,
//        "text": "This is my second post",
//        "privacy": "public"
//    }
//]

SIMILAR stored procedure

This stored procedure calculates how similar a column is to a given string.

Please run this sql query on the database before using the sql function.

DROP FUNCTION IF EXISTS SIMILAR;
DELIMITER //
CREATE FUNCTION SIMILAR(s1 VARCHAR(255), s2 VARCHAR(255))
RETURNS FLOAT
DETERMINISTIC
BEGIN
    DECLARE s1_len, s2_len, i, j, matches INT;
    DECLARE s3,checker VARCHAR(255);
    IF LENGTH(s1) > LENGTH(s2) THEN
    SET s3 = s2;
    SET s2 = s1;
    SET s1 = s3;
    END IF;
    SET s1_len = LENGTH(s1) - 2;
    SET s2_len = LENGTH(s2) - 2;
    SET i = 1;
    SET matches = 0;
    WHILE i <= s1_len DO
        SET j = 1;
        SET checker = SUBSTRING(s1,i,3);
        WHILE j <= s2_len DO
            IF checker = SUBSTRING(s2,j,3) THEN
                SET matches = matches + 1;
            END IF;
        SET j = j + 1;
        END WHILE;
        SET i = i + 1;
    END WHILE;
    RETURN matches/s1_len;
END//
DELIMITER ;

The SIMILAR function can be used in the column section of the select and get methods.


License

Advanced Medoo is licensed under the MIT License.

Acknowledgments

We extend our gratitude to the Medoo community for their exceptional database library.

Elevate your coding game with Advanced Medoo!

dandylion/advancedmedoo 适用场景与选型建议

dandylion/advancedmedoo 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 45 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 09 月 11 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 dandylion/advancedmedoo 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-09-11