承接 tf-pro/yii2-mysql-json 相关项目开发

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

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

tf-pro/yii2-mysql-json

Composer 安装命令:

composer require tf-pro/yii2-mysql-json

包简介

extend yii2-ActiveRecord And yii2-ActiveQuery with use mysql json make simple.

README 文档

README

The extension yii2-ActiveRecord And yii2-ActiveQuery with use mysql json make simple.

Installation

The preferred way to install this extension is through composer.

Either run

composer require tf/yii2-mysql-json

or add

"tf-pro/yii2-mysql-json": "~1.0"

to the require section of your composer.json.

Basic Usage

Your Model file must extend this extension class;

use TFPro\Yii2MysqlJson\ActiveRecordJson;

class YourModel extent ActiveRecordJson
{

}

Then if you want to use it to search column with json.

jsonWhere

This func like use Model::find()->where(\[Query::where()\]); column search is column->"$.jsonColumn1.jsonColumn2...";

public function search()
{
    YourModel::findJson()
        ->jsonWhere(['content->"$.en.content"' => 'who'])
        ->jsonWhere(['>', 'content->"$.en.content"' , 'who'])
}

jsonContainsWhere

This func Support mysql JSON_CONTAINS(target, candidate[, path]); This query is equivalent to the query, but the difference is that the query is an inclusion relation, that is, the field contains the value of the value; Column A multilevel field supporting JSON fields is segmented using '.';

public function search()
{
    YourModel::findJson()
        ->jsonContainsWhere('content.en.content', 'who')
}

jsonExtractWhere

This func Support JSON_EXTRACT(json_doc, path[, path] ...) in query; Column A multilevel field supporting JSON fields is segmented using '.'; Can use operate to search。

public function search()
{
    YourModel::findJson()
        ->jsonContainsWhere('content.en.content', 'who', '>')
}

jsonSelect

This func Support JSON_EXTRACT(json_doc, path) AS xx in query select; Column A multilevel field supporting JSON fields is segmented using '.';

public function search()
{
    YourModel::findJson()
        ->jsonSelect(['content.en.content', 'content.en.text' => 'tt']])
}

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固