Пример #1
0
 public function testautoincrementIntoDb()
 {
     $aid = 77;
     $pid = Api_Dao_Photo::createPhoto($aid, 'a caption', '', 2, '', '', '');
     $this->assertTrue($pid !== false);
     $subjectId = 2;
     $text = "cvsUrl";
     $xcoord = 21;
     $ycoord = 43;
     $id;
     try {
         $numRows = $this->getNumAllPhotoTags();
         $id = Api_Dao_PhotoTag::createPhotoTag($pid, $subjectId, $text, $xcoord, $ycoord, null);
         $this->assertEquals($numRows + 1, $this->getNumAllPhotoTags());
         $this->assertNotNull($id);
         $row = $this->getPhotoTag($id);
         $this->assertEquals($id, $row['ptid']);
         $this->assertEquals($pid, $row['pid']);
         $this->assertEquals($subjectId, $row['subject_id']);
         $this->assertEquals($text, $row['text']);
         $this->assertEquals($xcoord, $row['xcoord']);
         $this->assertEquals($ycoord, $row['ycoord']);
     } catch (Exception $exception) {
         throw $exception;
     }
     Api_Dao_PhotoTag::deletePhotoTag($id);
     $this->assertEquals($numRows, $this->getNumAllPhotoTags());
     Api_Dao_Photo::deletePhoto($pid);
 }
Пример #2
0
 public static function getOnePhoto($pid, $aid, $caption, $link, $owner, $src, $srcBig, $srcSmall)
 {
     $id = Api_Dao_Photo::createPhoto($aid, $caption, $link, $owner, $src, $srcBig, $srcSmall, null);
     if ($id) {
         return Api_Dao_Photo::getPhotoById($id);
     }
     return null;
 }
Пример #3
0
 /**
  * One or more of the following fields is required:
  * Photo ID
  * Album ID
  * Subject ID
  *
  * This function figures out which combo should be used to query the DB and then
  * calls the correct DAO function.
  *
  * @param unknown_type $pids
  * @param unknown_type $album_id
  * @param unknown_type $subject_id
  */
 public static function getPhotos($pids = array(), $albumId = null, $subjectId = null)
 {
     $pidCount = count($pids);
     if ($pidCount > 0 && $albumId === null && $subjectId === null) {
         return Api_Dao_Photo::getPhotosByPids($pids)->toArray();
     } else {
         if ($pidCount == 0 && $albumId !== null && $subjectId === null) {
             return Api_Dao_Photo::getPhotosByAlbumId($albumId)->toArray();
         } else {
             if ($pidCount == 0 && $albumId === null && $subjectId !== null) {
                 return Api_Dao_Photo::getPhotosBySubjectId($subjectId)->toArray();
             } else {
                 if ($pidCount > 0 && $albumId !== null && $subjectId === null) {
                     return Api_Dao_Photo::getPhotosByPidsAndAlbumId($pids, $albumId)->toArray();
                 } else {
                     if ($pidCount > 0 && $albumId === null && $subjectId !== null) {
                         return Api_Dao_Photo::getPhotosByPidsAndSubjectId($pids, $subjectId)->toArray();
                     } else {
                         if ($pidCount == 0 && $albumId !== null && $subjectId !== null) {
                             return Api_Dao_Photo::getPhotosByAlbumIdAndSubjectId($albumId, $subjectId)->toArray();
                         } else {
                             if ($pidCount > 0 && $albumId !== null && $subjectId !== null) {
                                 return Api_Dao_Photo::getPhotosByPidsAndAlbumIdAndSubjectId($pids, $albumId, $subjectId)->toArray();
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Пример #4
0
 public function testautoincrementIntoDb()
 {
     $pid = null;
     $aid = 234;
     $caption = "cap";
     $link = "cvsUrl";
     $owner = 543;
     $src = "src";
     $srcBig = "srcBig";
     $srcSmall = "srcSmall";
     try {
         $numRows = $this->getNumAllPhotos();
         $pid = Api_Dao_Photo::createPhoto($aid, $caption, $link, $owner, $src, $srcBig, $srcSmall, null);
         $this->assertEquals($numRows + 1, $this->getNumAllPhotos());
         $this->assertNotNull($pid);
         $row = $this->getPhoto($pid);
         $this->assertEquals($aid, $row['aid']);
         $this->assertEquals($caption, $row['caption']);
         $this->assertEquals($link, $row['link']);
         $this->assertEquals($owner, $row['owner']);
         $this->assertEquals($pid, $row['pid']);
         $this->assertEquals($src, $row['src']);
         $this->assertEquals($srcBig, $row['src_big']);
         $this->assertEquals($srcSmall, $row['src_small']);
     } catch (Exception $exception) {
         Api_Dao_Photo::deletePhoto($pid);
         throw $exception;
     }
     Api_Dao_Photo::deletePhoto($pid);
     $this->assertEquals($numRows, $this->getNumAllPhotos());
 }