五月天激情丁香,国产精品2019,国产成人精品亚洲2020,国产精品免费视频一区二区三区,开心久久婷婷综合中文字幕,天堂视频在线观看免费完整版

一對(duì)多關(guān)聯(lián) hasMany

定義關(guān)聯(lián)

<?php
declare(strict_types=1);

namespace EasySwoole\FastDb\Tests\Model;

use EasySwoole\FastDb\AbstractInterface\AbstractEntity;
use EasySwoole\FastDb\Attributes\Property;
use EasySwoole\FastDb\Attributes\Relate;
use EasySwoole\FastDb\Tests\Model\UserCar;

/**
 * @property int    $id
 * @property string $name
 * @property int    $status
 * @property int    $score
 * @property string $email
 */
class User extends AbstractEntity
{
    #[Property(isPrimaryKey: true)]
    public int $id;
    #[Property]
    public ?string $name;
    #[Property]
    public ?int $status;
    #[Property]
    public ?int $score;
    #[Property]
    public ?int $create_time;
    #[Property]
    public ?string $info;
    #[Property]
    public ?string $foo;
    #[Property]
    public ?string $bar;
    #[Property]
    public ?int $login_time;
    #[Property]
    public ?int $login_times;
    #[Property]
    public ?int $read;
    #[Property]
    public ?string $title;
    #[Property]
    public ?string $content;
    #[Property]
    public ?string $email;

    public function tableName(): string
    {
        return 'easyswoole_user';
    }

    #[Relate(
        targetEntity: UserCar::class,
        targetProperty: 'user_id'
    )]
    public function cars()
    {
        return $this->relateMany();
    }
}

關(guān)聯(lián)查詢

<?php
$article = User::findRecord(1);
// 獲取用戶擁有的所有車輛品牌
$listResult = $article->cars();
foreach ($listResult as $userCar) {
    echo $userCar->car_name . "\n";
}
// or
$objectArr = $listResult->toArray(); // 轉(zhuǎn)換為 對(duì)象數(shù)組
foreach ($objectArr as $userCar) {
    echo $userCar->car_name . "\n";
}
主站蜘蛛池模板: 99精品国产免费久久国语 | 男女网站视频 | 欧美色惰 | 国产成人aa在线观看视频 | 亚洲综合在线视频 | 海贼王3d2y剧场版 | 99久久免费精品国产免费高清 | 日韩毛片免费看 | 狠狠色婷婷综合天天久久丁香 | 你懂得福利影院 | 国产精品人成人免费国产 | 97视频精品 | 成年私人影院免费视频网站 | 毛片小视频 | 高清内谢| 国产欧美日韩综合一区二区三区 | 久久婷婷丁香 | 国产性自拍 | 成人免费一级片 | 日日精品 | 国产猛烈无遮掩视频免费网站男女 | 深爱开心激情网 | 男人天堂2017 | 久久99久久精品久久久久久 | 全部免费a级毛片 | 澳门久久| 久久久久久久国产视频 | 4444在线观看| 精品久久中文网址 | 国产精品视频网址 | 久久只有精品视频 | 午夜欧美成人 | 婷婷四房综合激情五月性色 | 免费网站在线观看国产v片 免费网站视频 | 综合色桃花久久亚洲 | 精品国产免费人成在线观看 | 日本精品99 | 99视频国产在线 | 亚洲欧美婷婷 | 福利一区在线 | 日本在线日本中文字幕日本在线视频播放 |