黄p网站_在线看中文字幕_亚洲电影免费观看_成人激情视频_欧美成视频_中国av在线

一對多關聯 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";
}
主站蜘蛛池模板: 中国电影黄色一级片免费观看 | 人人干人人干人人 | 二区久久 | 国产精品一区二区在线观看 | 可以在线观看的av网站 | 天天草草草 | 国产精品美女久久久久aⅴ国产馆 | 亚洲 欧美 日韩 在线 | 国产午夜精品久久久久久久 | 欧美一区成人 | 在线观看91视频 | 国产精品久久久久久无遮挡 | 国产精品不卡 | 91天堂 | 91麻豆产精品久久久久久 | 国产高清一区二区三区 | 日韩在线成人av | 99精品在线观看 | 欧美激情一区二区三级高清视频 | 日韩一二三四 | 欧美操穴 | 成人免费一区二区三区视频网站 | 伊人久麻豆社区 | 欧美久久视频 | 国产一区 | 精品国产一区二区三区四 | 欧美一级毛片久久99精品蜜桃 | 国产综合久久 | 中文字幕一二区 | 免费观看电视在线高清视频 | 亚洲高清视频一区二区三区 | 欧美日韩国产在线播放 | 日韩毛片 | 中文字幕欧美日韩一区 | 成人婷婷 | 国产精品福利91 | 亚洲一区二区黄 | 欧美video | 亚洲一区二区三区视频 | 精品99久久| 国产免费一区二区 |