Skip to content
李铭昕 edited this page Nov 13, 2017 · 1 revision

Phalcon 模型

关系

<?php
namespace App\Models;

use App\Models\Relation;
use App\Models\User;

class Shop extends \Phalcon\Mvc\Model{
    
    public function initialize(){
        $this->hasManyToMany(
            'shop_id',
            Relation::class,
            'shop_id',
            'user_id',
            User::class,
            'user_id',
            [
                'alias' => 'user', // 别名
                'reusable' => true, // 是否可以复用对象
                'params' => [
                    'condition'=>'is_deleted = ?0',
                    'bind'=>[0],
                    'limit' => 1
                ]
            ]
        );
    }
}
Clone this wiki locally