예제 #1
0
 public static function getObjectList($dto, $objectArray)
 {
     $objectList = array();
     $index = strtolower(substr($dto, 0, -3));
     for ($i = 0; $i < sizeof($objectArray); $i++) {
         $objectList[$index . $i] = DataModelUtils::getObjectDTO($dto, $objectArray[$i]);
     }
     return $objectList;
 }
예제 #2
0
 public function checkIfAddressExist(\AddressDTO $addressDTO)
 {
     $objectArray = array();
     $query = "SELECT * FROM " . ADDRESS_TABLE . " WHERE longitude = " . $addressDTO->getLongitude() . " AND latitude = " . $addressDTO->getLatitude();
     try {
         $this->userAutentication();
         $objectArray = $this->getDB()->execQuery($query);
         if (is_null($objectArray)) {
             return NULL;
         } else {
             return DataModelUtils::getObjectDTO(ADDRESSDTO, $objectArray[0]);
         }
     } catch (PDOException $pdoe) {
         throw $pdoe;
     } catch (Exception $e) {
         throw $e;
     }
 }
예제 #3
0
 public function getPostByPostId($postId)
 {
     $query = "select \n                pt.postid as POSTID,\n                pt.TEXT\tas TEXT,\n                pt.DATE as DATE,\n                postph.LONGITUDE as LONGITUDE,\n                postph.LATITUDE as LATITUDE,\n                postph.PHOTOID as POSTPHOTOID,\n                postph.PHOTOURL as POSTPHOTOURL,\n                authut.USERID as AUTHORID,\n                authut.USERNAME as AUTHORUSERNAME,\n                authph.PHOTOURL as AUTHORPHOTOURL,\n                authph.PHOTOID as AUTHORPHOTOID,\n                dashut.USERID as DASHBOARDUSERID,\n                dashph.PHOTOURL as DASHBOARDPHOTOURL,\n                dashph.PHOTOID as DASHBOARDPHOTOID,\n                dashut.USERNAME as DASHBOARDUSERNAME" . " from sat_post pt, sat_photo postph, sat_user authut, sat_photo authph,sat_user dashut, sat_photo dashph" . " where pt.postid = " . $postId . " and pt.dashboardid = dashut.userid " . " and postph.photoid = pt.photoid " . " and pt.authorid = authut.userid " . " and authut.profilephoto = authph.photoid " . " and dashut.profilephoto = dashph.photoid " . " order by pt.date desc";
     //        var_dump($query);
     try {
         $this->userAutentication();
         $objectDto = $this->getDB()->execQuery($query);
         if (is_null($objectDto)) {
             return NULL;
         } else {
             $objectListDTO = DataModelUtils::getObjectDTO(POSTDTO, $objectDto[0]);
             return $objectListDTO;
         }
     } catch (PDOException $pdoe) {
         throw $pdoe;
     } catch (UserNotAuthenticatedExceptionDTO $authExp) {
         throw $authExp;
     } catch (Exception $e) {
         throw $e;
     }
 }
예제 #4
0
 public function getUserByUserId($userId)
 {
     $query = "select ut.*, pht.* from sat_user ut, sat_photo pht where ut.userid = {$userId}  and ut.PROFILEPHOTO = pht.PHOTOID ";
     try {
         $objectArray = $this->getDB()->execQuery($query);
         if (is_null($objectArray)) {
             return NULL;
         } else {
             $objectDTO = DataModelUtils::getObjectDTO(USERDTO, $objectArray[0]);
             return $objectDTO;
         }
     } catch (PDOException $pdoe) {
         throw $pdoe;
     } catch (Exception $e) {
         throw $e;
     }
 }
예제 #5
0
 public function getPhotoByPhotoId($photoId)
 {
     $query = "select * from  " . PHOTO_TABLE . " where PHOTOID = {$photoId} ";
     try {
         $this->userAutentication();
         $objectArray = $this->getDB()->execQuery($query);
         if (is_null($objectArray)) {
             return NULL;
         } else {
             $objectDTO = DataModelUtils::getObjectDTO(PHOTODTO, $objectArray[0]);
             return $objectDTO;
         }
     } catch (PDOException $pdoe) {
         throw $pdoe;
     } catch (UserNotAuthenticatedExceptionDTO $authExp) {
         throw $authExp;
     } catch (Exception $e) {
         throw $e;
     }
 }
예제 #6
0
 public function getAlbumByAlbumId($albumId)
 {
     $query = "SELECT at.*, pht.* from sat_album at, sat_photo pht WHERE " . " at.COVER = pht.PHOTOID AND " . " at.albumid = {$albumId}";
     try {
         $this->userAutentication();
         $objectArray = $this->getDB()->execQuery($query);
         if (is_null($objectArray)) {
             return NULL;
         } else {
             $objectDTO = DataModelUtils::getObjectDTO(ALBUMDTO, $objectArray[0]);
             return $objectDTO;
         }
     } catch (PDOException $pdoe) {
         throw $pdoe;
     } catch (UserNotAuthenticatedExceptionDTO $authExp) {
         throw $authExp;
     } catch (Exception $e) {
         throw $e;
     }
 }