本文整理匯總了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);
}