承接 nddcoder/sql-to-mongodb-query 相关项目开发

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

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

nddcoder/sql-to-mongodb-query

Composer 安装命令:

composer require nddcoder/sql-to-mongodb-query

包简介

README 文档

README

Latest Version on Packagist GitHub Tests Action Status Total Downloads

Installation

You can install the package via composer:

composer require nddcoder/sql-to-mongodb-query

Online Demo

SQL To MongoDB Query

GUI phpMongoAdmin

phpMongoAdmin

Usage

Parse Find query

$parser = new Nddcoder\SqlToMongodbQuery\SqlToMongodbQuery();
$query = $parser->parse("
    SELECT id, username, email, created_at 
    FROM users
    USE INDEX active_1_created_at_1
    WHERE active = true and created_at >= date('2021-01-01') 
    ORDER BY created_at desc 
    LIMIT 10, 20
");

/*
Nddcoder\SqlToMongodbQuery\Model\FindQuery {#473
  +filter: array:2 [
    "active" => true
    "created_at" => array:1 [
      "$gte" => MongoDB\BSON\UTCDateTime {#926
        +"milliseconds": "1609459200000"
      }
    ]
  ]
  +projection: array:4 [
    "id" => 1
    "username" => 1
    "email" => 1
    "created_at" => 1
  ]
  +sort: array:1 [
    "created_at" => -1
  ]
  +limit: 20
  +skip: 10
  +collection: "users"
  +hint: "active_1_created_at_1"
}

*/

Parse Aggregate query

$parser = new Nddcoder\SqlToMongodbQuery\SqlToMongodbQuery();
$query = $parser->parse("
    SELECT date, count(*)
    FROM clicks
    USE INDEX status_1_created_at_1
    WHERE status = 1 and created_at >= date('2021-07-01') 
    GROUP BY date
    HAVING count(*) > 100
");

/*
Nddcoder\SqlToMongodbQuery\Model\Aggregate {#493
  +pipelines: array:4 [
    0 => array:1 [
      "$match" => array:2 [
        "status" => 1
        "created_at" => array:1 [
          "$gte" => MongoDB\BSON\UTCDateTime {#926
            +"milliseconds": "1625097600000"
          }
        ]
      ]
    ]
    1 => array:1 [
      "$group" => array:2 [
        "_id" => array:1 [
          "date" => "$date"
        ]
        "count(*)" => array:1 [
          "$sum" => 1
        ]
      ]
    ]
    2 => array:1 [
      "$project" => array:3 [
        "date" => "$_id.date"
        "count(*)" => "$count(*)"
        "_id" => 0
      ]
    ]
    3 => array:1 [
      "$match" => array:1 [
        "count(*)" => array:1 [
          "$gt" => 100
        ]
      ]
    ]
  ]
  +collection: "clicks"
  +hint: "status_1_created_at_1"
}
*/

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-12-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固