本文整理汇总了PHP中UserMapper::selectUser方法的典型用法代码示例。如果您正苦于以下问题:PHP UserMapper::selectUser方法的具体用法?PHP UserMapper::selectUser怎么用?PHP UserMapper::selectUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserMapper
的用法示例。
在下文中一共展示了UserMapper::selectUser方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: insertMessage
/**
*
* @param Message $message_
* @param array $arrayFilter
* @throws InvalidArgumentException
*/
public function insertMessage(Message $message_, array $arrayFilter = array())
{
try {
if (is_null($this->table)) {
throw new InvalidArgumentException('Attribute "table" can\'t be NULL !');
}
$userMapper = new UserMapper();
$userMapper->setId($message_->getIdSender());
$user_sender = $userMapper->selectUser();
$userMapper->setId($message_->getIdReceiver());
$user_receiver = $userMapper->selectUser();
if (!is_null($user_sender->getId()) && !is_null($user_receiver->getId())) {
return parent::insert($this->table, $message_, $arrayFilter);
} elseif (is_null($user_sender->getId())) {
throw new Exception('User sender does not exist !');
} elseif (is_null($user_receiver->getId())) {
throw new Exception('User receiver does not exist !');
}
} catch (InvalidArgumentException $e) {
print $e->getMessage();
exit;
} catch (Exception $e) {
print $e->getMessage();
exit;
}
}
示例2: insertComment
/**
*
* @param Comment $comment_
* @param array $arrayFilter
* @throws InvalidArgumentException
*/
public function insertComment(Comment $comment_, array $arrayFilter = array())
{
try {
if (is_null($this->table)) {
throw new InvalidArgumentException('Attribute "table" can\'t be NULL !');
}
$userMapper = new UserMapper();
$announcementMapper = new AnnouncementMapper();
$userMapper->setId($comment_->getIdUser());
$user = $userMapper->selectUser();
$announcementMapper->setId($comment_->getIdAnnouncement());
$announcement = $announcementMapper->selectAnnouncement();
if (!is_null($user->getId()) && !is_null($announcement->getId())) {
return parent::insert($this->table, $comment_, $arrayFilter);
} elseif (is_null($user->getId())) {
throw new Exception('User is inexistant !');
} elseif (is_null($announcement->getId())) {
throw new Exception('Announcement is inexistant !');
}
} catch (InvalidArgumentException $e) {
print $e->getMessage();
exit;
} catch (Exception $e) {
print $e->getMessage();
exit;
}
}
示例3: testDelete
public function testDelete()
{
$userMapper = new UserMapper();
$userMapper->setId(2);
$userMapper->deleteUser();
$this->assertEquals(new User(), $userMapper->selectUser());
}
示例4: insertIncoming
/**
*
* @param Incoming $incoming_
* @param array $arrayFilter
* @throws InvalidArgumentException
*/
public function insertIncoming(Incoming $incoming_, array $arrayFilter = array())
{
try {
if (is_null($this->table)) {
throw new InvalidArgumentException('Attribute "table" can\'t be NULL !');
}
$userMapper = new UserMapper();
$userMapper->setId($incoming_->getIdUser());
$user = $userMapper->selectUser();
if (!is_null($user->getId())) {
return parent::insert($this->table, $incoming_, $arrayFilter);
} elseif (isset($user) && is_null($user->getId())) {
throw new Exception('User does not exist !');
}
} catch (Exception $e) {
print $e->getMessage();
exit;
}
}
示例5: User
<?php
/**
* Get the HTTP method and differents data.
*/
$http = Rest::initProcess();
switch ($http->getMethod()) {
case 'get':
$user_ = new User();
$userMapper = new \UserMapper();
$usersObject = $userMapper->selectUser(true);
$result = true;
if (is_array($usersObject) && !is_null($usersObject)) {
foreach ($usersObject as $userObject) {
$result = emptyObject($userObject);
}
}
if (!$result) {
foreach ($usersObject as $userObject) {
$usersArray[] = extractData($userObject);
}
if ($http->getHttpAccept() == 'json') {
Rest::sendResponse(200, json_encode($usersArray), 'application/json');
} else {
if ($http->getHttpAccept() == 'xml') {
$options = array('indent' => ' ', 'addDecl' => false, XML_SERIALIZER_OPTION_RETURN_RESULT => true, "defaultTagName" => "user");
$serializer = new XML_Serializer($options);
Rest::sendResponse(200, $serializer->serialize($usersArray), 'application/xml');
}
}
} else {
示例6: User
<?php
/**
* Get the HTTP method and differents data.
*/
$http = Rest::initProcess();
switch ($http->getMethod()) {
case 'get':
$user_ = new User();
$userMapper = new \UserMapper();
$userObject = $userMapper->selectUser();
$userArray = extractData($userObject);
if (!empty($userArray)) {
if ($http->getHttpAccept() == 'json') {
Rest::sendResponse(200, json_encode($userArray), 'application/json');
} else {
if ($http->getHttpAccept() == 'xml') {
$options = array('indent' => ' ', 'addDecl' => false, "defaultTagName" => "user", XML_SERIALIZER_OPTION_RETURN_RESULT => true);
$serializer = new XML_Serializer($options);
Rest::sendResponse(200, $serializer->serialize($userArray), 'application/xml');
}
}
} else {
Rest::sendResponse(204);
}
break;
case 'delete':
$user_ = new \User();
$userMapper = new \UserMapper();
if ($userMapper->deleteUser()) {
Rest::sendResponse(200);