protected function add(Announcement $announcement) { $q = $this->dao->prepare('INSERT INTO ' . $this->table() . ' SET TITLE = :title, DESCRIPTION = :description, PRICE_PUBLIC = :pricePublic, IS_FULL_DAY_PRICE = :isFullDayPrice, CAUTION = :caution, PHOTO_MAIN = :photoMain, PHOTO_OPTION_1 = :photoOption1, PHOTO_OPTION_2 = :photoOption2, TIPS = :tips, RAW_MATERIAL = :rawMaterial, ADDRESS_1 = :address1, ADDRESS_2 = :address2, ZIP_CODE = :zipCode, CITY = :city, COUNTRY = :country, REGION_ID =:regionId, DEPARTMENT_ID =:departmentId, IS_PUBLISHED = :isPublished, PUBLICATION_DATE = :publicationDate, END_PUBLICATION_DATE = :endPublicationDate, CATEGORY_ID = :categoryId, SUB_CATEGORY_ID = :subCategoryId, USER_ID = :userId, STATE_ID = :stateId, ADMIN_COMMENT = :adminComment, REF_ANNOUNCEMENT_ID = :refAnnouncementId'); $q->bindValue(':title', $announcement->getTitle()); $q->bindValue(':description', $announcement->getDescription()); $q->bindValue(':pricePublic', $announcement->getPricePublic()); $q->bindValue(':isFullDayPrice', $announcement->getIsFullDayPrice()); $q->bindValue(':caution', $announcement->getCaution()); $q->bindValue(':photoMain', $announcement->getPhotoMain()); $q->bindValue(':photoOption1', $announcement->getPhotoOption1()); $q->bindValue(':photoOption2', $announcement->getPhotoOption2()); $q->bindValue(':tips', $announcement->getTips()); $q->bindValue(':rawMaterial', $announcement->getRawMaterial()); $q->bindValue(':address1', $announcement->getAddress1()); $q->bindValue(':address2', $announcement->getAddress2()); $q->bindValue(':zipCode', $announcement->getZipCode()); $q->bindValue(':city', $announcement->getCity()); $q->bindValue(':country', $announcement->getCountry()); $q->bindValue(':regionId', $announcement->getRegionId()); $q->bindValue(':departmentId', $announcement->getDepartmentId()); $q->bindValue(':isPublished', $announcement->getIsPublished()); $q->bindValue(':publicationDate', $announcement->getPublicationDate()); $q->bindValue(':endPublicationDate', $announcement->getEndPublicationDate()); $q->bindValue(':categoryId', $announcement->getCategoryId(), PDO::PARAM_INT); $q->bindValue(':subCategoryId', $announcement->getSubCategoryId(), PDO::PARAM_INT); $q->bindValue(':userId', $announcement->getUserId(), PDO::PARAM_INT); $q->bindValue(':stateId', $announcement->getStateId(), PDO::PARAM_INT); $q->bindValue(':adminComment', $announcement->getAdminComment()); $q->bindValue(':refAnnouncementId', $announcement->getRefAnnouncementId(), PDO::PARAM_INT); $q->execute(); $announcement->setId($this->dao->lastInsertId()); }
/** * Internal function to return an Announcement object from a row. * @param $row array * @return Announcement */ function &_returnAnnouncementFromRow(&$row) { $announcement = new Announcement(); $announcement->setId($row['announcement_id']); $announcement->setAssocType($row['assoc_type']); $announcement->setAssocId($row['assoc_id']); $announcement->setTypeId($row['type_id']); $announcement->setDateExpire($this->dateFromDB($row['date_expire'])); $announcement->setDatePosted($this->datetimeFromDB($row['date_posted'])); $this->getDataObjectSettings('announcement_settings', 'announcement_id', $row['announcement_id'], $announcement); return $announcement; }
public function testPut() { $announcement = new Announcement(); $announcement->setId('1'); $announcement->setTitle('Annonce test'); $announcement->setSubtitle('Description modifiée'); $announcement->setContent('Besoin de mécanicien contre cours de cuisine'); $announcement->setPostDate('2012-12-14 18:07:27'); $announcement->setConclued('0'); $announcementMapper = new AnnouncementMapper(); $announcementMapper->setId(1); $announcementMapper->updateAnnouncement($announcement); $this->assertEquals($announcement, $announcementMapper->selectAnnouncement()); }
public function testGetSetId() { $announcement = new Announcement(); $announcement->setId(1); $this->assertEquals(1, $announcement->getId()); }