定制 astraller/yii2-mongodb-embedded 二次开发

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

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

astraller/yii2-mongodb-embedded

Composer 安装命令:

composer require astraller/yii2-mongodb-embedded

包简介

Yii2 extension to work with embedded documents in MongoDB.

README 文档

README

Yii2 extension to work with embedded documents in MongoDB.


This extension requires MongoDB PHP Extension version 1.0.0 or higher.
This extension requires MongoDB server version 3.0 or higher.

Installation

The preferred way to install this extension is through composer.
Either run

php composer.phar require --prefer-dist astraller/yii2-mongodb-embedded

or add

"astraller/yii2-mongodb-embedded": "^1.*"

to the require section of your composer.json.

Usage

  • Your model must be inherited from astraller\mongodb\MongoModel class.
  • Add embedAttributes method
    public function embedAttributes() {
        return [
            'conditions' => [
                'class' => DialogConditions::class,
                'type'  => 'many',
            ],
            'text'       => [
                'class' => Text::class,
                'type'  => 'one',
            ],
            'variants' => [
                'class' => Dialog::class,
                'type' => 'manyById'
            ]
        ];
    }
  • Your embedded documents must be inherited from EmbeddedDocument class.
<?php
namespace app\models;

use astraller\mongodb\MongoEmbedModel;

class Vector3 extends MongoEmbedModel
{

    public $x;
    public $y;
    public $z;

    public function rules()
    {
        return [
            [['x', 'y', 'z'], 'required'],
        ];
    }

    public function t(){
        return "[X: {$this->x}; Y: {$this->y}; Z: {$this->z}]";
    }

}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-09-25

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固