在线看片18_亚洲性吧_在线污_神马午夜达达兔_奇米色网_在线免费看污

一對多關聯 hasMany

定義關聯

<?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();
    }
}

關聯查詢

<?php
$article = User::findRecord(1);
// 獲取用戶擁有的所有車輛品牌
$listResult = $article->cars();
foreach ($listResult as $userCar) {
    echo $userCar->car_name . "\n";
}
// or
$objectArr = $listResult->toArray(); // 轉換為 對象數組
foreach ($objectArr as $userCar) {
    echo $userCar->car_name . "\n";
}
主站蜘蛛池模板: 伊人爱爱 | 国产最新在线视频 | 亚洲无线视频 | 亚洲涩涩涩| 亚洲国产精品久久久久久 | 国产精品1区 | 国产精品麻豆免费版 | 91网页在线观看 | 国产精品二区在线观看 | 超碰在线播放97 | 欧美性猛交xx| 久久一久久 | 超碰免费公开在线 | 欧美午夜激情影院 | 亚洲黄色中文字幕 | av影音先锋 | 97香蕉久久夜色精品国产 | 国产99对白在线播放 | 欧美日韩精品久久久 | 538精品视频 | www午夜| 日韩精品视频网 | 免费黄色高清视频 | 天天色成人网 | 日本精品一区二区 | 国产三级在线观看视频 | 五月天激情图片 | 日本欧美国产在线 | 色偷偷资源 | 日韩av在线免费播放 | 中文字幕视频二区 | 天堂在线视频免费 | 日韩精品久久久 | 一级午夜| 天天干天天操 | 草久在线 | 成人在线播放网站 | a级黄色片免费看 | 四虎永久在线精品 | 亚洲日日夜夜 | 一区二区三区免费在线观看 |