本文整理汇总了PHP中UserRepository::create方法的典型用法代码示例。如果您正苦于以下问题:PHP UserRepository::create方法的具体用法?PHP UserRepository::create怎么用?PHP UserRepository::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserRepository
的用法示例。
在下文中一共展示了UserRepository::create方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
public function create($candidate)
{
try {
$userRepository = new UserRepository();
$candidate->user->accounttype = 0;
$userRepository->create($candidate->user);
$null = null;
$req = $this->db->prepare('INSERT INTO candidates VALUES(:id, :userId, :cvId, :firstname, :lastname, :birthdate, :address, :phone, :email)');
$req->bindParam(':id', $candidate->id);
$req->bindParam(':userId', !is_null($candidate->user) ? $candidate->user->id : $null);
$req->bindParam(':cvId', !is_null($candidate->cv) ? $candidate->cv->id : $null);
$req->bindParam(':firstname', $candidate->firstname);
$req->bindParam(':lastname', $candidate->lastname);
$req->bindParam(':birthdate', $candidate->birthdate);
$req->bindParam(':address', $candidate->address);
$req->bindParam(':phone', $candidate->phone);
$req->bindParam(':email', $candidate->email);
$req->execute();
} catch (PDOException $e) {
}
}
示例2: create
public function create($company)
{
try {
$userRepository = new UserRepository();
$company->user->accounttype = 1;
$userRepository->create($company->user);
$null = null;
$req = $this->db->prepare('INSERT INTO companies VALUES(:id, :userId, :name, :description, :address, :phone, :email, :logo, :cities)');
$req->bindParam(':id', $company->id);
$req->bindParam(':userId', !is_null($company->user) ? $company->user->id : $null);
$req->bindParam(':description', $company->description);
$req->bindParam(':name', $company->name);
$req->bindParam(':address', $company->address);
$req->bindParam(':phone', $company->phone);
$req->bindParam(':email', $company->email);
$req->bindParam(':logo', $company->logo);
$req->bindParam(':cities', $company->cities);
$req->execute();
} catch (PDOException $e) {
}
}
示例3: UserRepository
/** @test **/
function it_persists_the_data_into_the_database()
{
$repository = new UserRepository($this->newContainerMock(new User()));
$repository->create(['name' => 'Finn the Human', 'email' => 'finn.the.human@gmail.com']);
$user = User::first();
$this->assertEquals('Finn the Human', $user->name);
$this->assertEquals('finn.the.human@gmail.com', $user->email);
}