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;
 }
Esempio n. 2
0
 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;
 }
Esempio n. 3
0
 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;
 }
 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();
 }
 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;
 }
 /**
   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;
 }
Esempio n. 7
0
<?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);
    }
}
<?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 :)');
}
Esempio n. 9
0
<?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);
}
Esempio n. 10
0
<?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');
    }
}
<?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 :)');
}
Esempio n. 12
0
 /**
  * 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;
 }