Exemple #1
0
 /**
  * Get a number of products from the DB from the specified productIds
  * @param array $productIds Array of productIds
  * @return \stdClass[]
  */
 public function getProductsByProductIds($productIds)
 {
     $query = 'SELECT * FROM aca_product WHERE product_id IN(' . implode(',', $productIds) . ')';
     $this->db->setQuery($query);
     $dbProducts = $this->db->loadObjectList();
     return $dbProducts;
 }
Exemple #2
0
 public function logIn()
 {
     //acquire user input
     if (isset($_POST)) {
         $username = $_POST['username'];
         //          echo '$username='******'<br/>';
         $password = $_POST['password'];
         //          echo '$password='******'<br/>';
     } else {
     }
     //check username and password
     $query = 'SELECT * FROM aca_user WHERE username = "******" AND password="******"';
     //        $query = "SELECT * FROM aca_user WHERE username = $username AND password = $password";
     $this->db->setQuery($query);
     $user = $this->db->loadObject();
     //        session_start(); symfony does it for you
     if (empty($user)) {
         $this->setLoggedOut();
         $this->setErrorMessage('Login Failed. Please Try Again');
     } else {
         $this->setLoggedIn();
         $this->setName($user->name);
         $this->setUserId($user->user_id);
     }
 }
Exemple #3
0
 /**
  * Get a number of products from the DB from the specified productIds
  * @param array $product_ids
  * @return \Aca\Bundle\ShopBundle\Db\stdClass[] ]stdClass[]
  */
 public function getCartProducts($product_ids)
 {
     $list = implode(',', $product_ids);
     $query = "SELECT * FROM aca_product WHERE product_id IN ({$list})";
     $this->db->setQuery($query);
     $shoppingcart = $this->db->loadObjectList();
     return $shoppingcart;
 }
Exemple #4
0
 /**
  * Get a number of products from the DB from the specified productIds
  * @param array $productIds Array of productIds
  * @return \stdClass[]
  */
 public function getProductsByProductIds($productIds)
 {
     $query = 'select * from aca_product where product_id
               in(' . implode(',', $productIds) . ')';
     $this->db->setQuery($query);
     $dbProducts = $this->db->loadObjectList();
     return $dbProducts;
 }
Exemple #5
0
 public function login($username, $password)
 {
     // Check username and password
     $query = 'SELECT * FROM aca_user WHERE username="******" AND password="******"';
     $this->db->setQuery($query);
     $user = $this->db->loadObject();
     // fetches ONE row from the database!
     if (empty($user)) {
         $this->session->set('logged_in', 0);
         $this->session->set('error_message', 'Login failed, please try again');
     } else {
         $this->session->set('logged_in', 1);
         $this->session->set('name', $user->name);
         // $user->name doesn't feel like it's right
         $this->session->set('user_id', $user->user_id);
         // $user->user_id doesn't feel like it's right
     }
     return new RedirectResponse('/');
 }