本文整理汇总了PHP中UserMapper::map方法的典型用法代码示例。如果您正苦于以下问题:PHP UserMapper::map方法的具体用法?PHP UserMapper::map怎么用?PHP UserMapper::map使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserMapper
的用法示例。
在下文中一共展示了UserMapper::map方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: findById
public function findById($id)
{
$row = $this->query('SELECT * FROM users_tb WHERE id = ' . (int) $id)->fetch();
if (!$row) {
return null;
}
$user = new User();
UserMapper::map($user, $row);
return $user;
}
示例2: find
public function find($type = null)
{
$result = array();
foreach ($this->query($this->getFindSql($type)) as $row) {
$user = new User();
UserMapper::map($user, $row);
$result[$user->getUserId()] = $user;
}
return result;
}
示例3: find
public function find($status = null)
{
$result = array();
$sql = 'SELECT id, first_name, user_password , status FROM user_tb WHERE ' . 'status = "' . $status . '";';
foreach ($this->query($sql) as $row) {
$user = new User();
UserMapper::map($user, $row);
$result[$user->getId()] = $user;
}
return $result;
}
示例4: findUserByEmail
public function findUserByEmail(User $user)
{
$result = array();
$email = $user->getEmail();
$sql = 'SELECT id FROM users_tb WHERE ' . 'email = "' . $email . '";';
foreach ($this->query($sql) as $row) {
$user = new User();
UserMapper::map($user, $row);
}
return $user->getId();
}
示例5: read
public function read()
{
$result = array();
$sql = 'SELECT * FROM user_tb';
foreach ($this->query($sql) as $row) {
$user = new User();
UserMapper::map($user, $row);
$result[$user->getId()] = $user;
}
return $result;
}
示例6: find
/**
find user's detail by sql
*/
public function find($status = null)
{
$result = array();
$sql = 'SELECT user_id, first_name, last_name, email, phone_number FROM products;';
//product_name
foreach ($this->query($sql) as $row) {
$user = new User();
UserMapper::map($user, $row);
$result[$user->getUserId()] = $user;
}
return $result;
}
示例7: array
<?php
$errors = array();
$userObj = new User();
if (array_key_exists('signin', $_POST)) {
$data = array('email' => $_POST['user']['email'], 'user_password' => $_POST['user']['user_password']);
UserMapper::map($userObj, $data);
$errors = Validator::validate($userObj);
if (empty($errors)) {
$dao = new UserDao();
$_SESSION['user_id'] = $dao->createUser($userObj)->getId();
Utils::redirect(dashboard);
}
}
示例8: User
<?php
$user_id = $_POST['user']['id'];
$user_obj = null;
$updatedUser_obj = null;
$user_obj = new User();
$updatedUser_obj = new User();
if (array_key_exists('find', $_POST)) {
$data = array('id' => $_POST['user']['id']);
UserMapper::map($user_obj, $data);
$dao = new UserDao();
$foundUser = $dao->findById($user_id);
}
if (array_key_exists('update', $_POST)) {
$data = array('id' => $_POST['user']['id'], 'first_name' => $_POST['user']['first_name'], 'user_password' => $_POST['user']['user_password']);
UserMapper::map($updatedUser_obj, $data);
$dao = new UserDao();
$dao->update($updatedUser_obj);
Flash::addFlash('user record(s) updated successfully :)');
}
示例9: array
<?php
$errors = array();
$userObj = new User();
$addressObj = new Address();
$orderObj = new Order();
if (array_key_exists('submit', $_POST)) {
$userData = array('id' => (int) $_SESSION['user_id'], 'first_name' => $_POST['user']['first_name'], 'last_name' => $_POST['user']['last_name']);
$addressData = array('street_no' => $_POST['address']['street_no'], 'street' => $_POST['address']['street'], 'suburb' => $_POST['address']['suburb'], 'city' => $_POST['address']['city'], 'post_code' => $_POST['address']['post_code']);
UserMapper::map($userObj, $userData);
AddressMapper::map($addressObj, $addressData);
//$errors = Validator::validate($userObj);
//if (empty($errors)) {
$userDao = new UserDao();
$addressDao = new AddressDao();
// $_SESSION['address_id'] = ($addressDao->create($addressObj)->getId());
$userDao->completeRegistration($userObj, $addressDao->createAddress($addressObj)->getId());
//}
}
if (array_key_exists('order', $_POST)) {
$orderData = array('order_details' => $_POST['orders']['order_details'], 'order_date' => $_POST['orders']['order_date'] . '00:00:00');
OrderMapper::map($orderObj, $orderData);
$orderDao = new OrderDao();
$orderDao->createOrder($orderObj);
}
示例10: array
<?php
$errors = array();
$User = null;
$edit = array_key_exists('id', $_GET);
if ($edit) {
$User = Utils::getUserByGetId();
} else {
// set defaults
$User = new User();
//$User->setDate(new DateTime());
}
if (array_key_exists('cancel', $_POST)) {
} elseif (array_key_exists('save', $_POST)) {
$data = array('email' => $_POST['Users']['email'], 'password' => $_POST['Users']['password']);
// map
UserMapper::map($User, $data);
// validate
$errors = UserValidator::validate($User);
// validate
if (empty($errors)) {
// save
$dao = new UserDao();
$User = $dao->save($User);
Flash::addFlash('Success Booking :)');
// redirect
Utils::redirect('home');
}
}
示例11: User
<?php
$user_id = $_POST['user']['id'];
$user_obj = null;
$user_obj = new User();
if (array_key_exists('delete', $_POST)) {
$data = array('id' => $_POST['user']['id']);
UserMapper::map($user_obj, $data);
$dao = new UserDao();
$dao->delete($user_id);
Flash::addFlash('Record' . $user_id . ' deleted successfully :)');
}
示例12: find
/**
* Find all {@link User}s by search criteria.
* @return array array of {@link User}s
*/
public function find(UserSearchCriteria $search = null)
{
$result = array();
foreach ($this->query($this->getFindSql($search)) as $row) {
$user = new Air2Java\model\Individu();
UserMapper::map($user, $row);
$result[$user->getId()] = $user;
}
return $result;
}