本文整理汇总了PHP中App\Model\User::read方法的典型用法代码示例。如果您正苦于以下问题:PHP User::read方法的具体用法?PHP User::read怎么用?PHP User::read使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类App\Model\User
的用法示例。
在下文中一共展示了User::read方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
public function index($id)
{
$user = User::read(1);
$this->set(['var' => $user->name]);
}
示例2: testBelongsToManySave
public function testBelongsToManySave()
{
/*
* userからセーブ
*/
$user1 = User::create(['name' => 'newUser']);
$skill1 = Skill::create(['name' => 'newSkill']);
$user1->Skill[] = $skill1;
$this->assertEquals(true, $user1->save());
/*
* 本当に保存できたかreadで確認
*/
$savedUser1Skill = Skill::read($user1->Skill[0]->id);
$this->assertEquals('newSkill', $savedUser1Skill->name);
$savedSkill1User = User::read($user1->id);
$this->assertEquals('newUser', $savedSkill1User->name);
/*
* skillからセーブ
*/
$skill2 = Skill::create(['name' => 'newSkill']);
$user2 = User::create(['name' => 'newUser']);
$skill2->User[] = $user2;
$this->assertEquals(true, $skill2->save());
/*
* 本当に保存できたかreadで確認
*/
$savedSkill2User = User::read($skill2->User[0]->id);
$this->assertEquals('newUser', $savedSkill2User->name);
$savedUser2Skill = Skill::read($skill2->id);
$this->assertEquals('newSkill', $savedUser1Skill->name);
}