五月天激情丁香,国产精品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";
}
主站蜘蛛池模板: 国产成人精品曰本亚洲77美色 | 伊人国产在线视频 | 999福利视频 | 在线国产毛片 | 四虎影院2019 | 欧美做a一级视频免费观看 欧美做a欧美 | 久久国产成人午夜aⅴ影院 久久国产成人精品国产成人亚洲 | 中文字幕久久亚洲一区 | 成人精品一区二区激情 | 国产一区二区三区免费观看 | 国产高清在线视频一区二区三区 | 黄色aa网站| 欧美女人性 | 欧美午夜精品 | 久久精品不卡 | 久久免费公开视频 | 国产 欧美 日韩 在线 | 黄色小视频在线观看 | 爱视频福利网 | 亚洲欧美日韩精品永久在线 | 成人在线色视频 | 国内精品久久久久久久 | 伊人网在线视频 | 六月婷婷激情 | 久久久小视频 | 潦草影视大全 | 久久久免费观看视频 | 四虎影视国产精品一区二区 | 欧美一区精品 | 国产呦精品一区二区三区下载 | 2021avtt天堂网手机版 | 国产一区二区三区四卡 | 午夜精品久久久久久久99热 | 五月激激激综合网色播免费 | 国产日产一区二区三区四区五区 | 男人女人的免费视频网站 | 国产成人小视频在线观看 | 国产精品成人一区二区1 | 久久国产精品免费专区 | 免费成人看片 | 国产亚洲精品高清在线 |