Пример #1
0
 public function getAmountOfPages()
 {
     try {
         $dbconn = DatabaseConnection::getConnection();
         $stmt = $dbconn->prepare('SELECT car_id FROM cars');
         $stmt->execute();
         $totalRecords = $stmt->rowCount();
         return ceil($totalRecords / $this->_limitRecords);
     } catch (\PDOException $e) {
         return false;
         echo 'Database error: ' . $e->getMessage();
         die;
     }
 }
Пример #2
0
 public function update()
 {
     try {
         $dbconn = DatabaseConnection::getConnection();
         $stmt = $dbconn->prepare('UPDATE cars SET 
     price=:price,
     cond=:cond,
     img_url=:img_url WHERE vin=:vin');
         $stmt->bindParam(':price', $this->price);
         $stmt->bindParam(':cond', $this->cond);
         $stmt->bindParam(':img_url', $this->img_url);
         $stmt->bindParam(':vin', $this->vin);
         $stmt->execute();
         return true;
     } catch (\PDOException $e) {
         echo 'Database error: ' . $e->getMessage();
         return false;
         die;
     }
 }
Пример #3
0
 public function checkUsersCar($vin)
 {
     try {
         $dbconn = DatabaseConnection::getConnection();
         $stmt = $dbconn->prepare('SELECT car_id FROM cars WHERE created_by=:user_id AND vin=:vin LIMIT 1');
         $stmt->bindParam(':user_id', $this->user_id);
         $stmt->bindParam(':vin', $vin);
         $stmt->execute();
         if ($stmt->rowCount() > 0) {
             return true;
         } else {
             return false;
         }
     } catch (\PDOException $e) {
         echo 'Database error: ' . $e->getMessage();
         return false;
         die;
     }
 }