00001 <?php
00002
00016 class NewReleaseDAO extends DAO {
00020 function NewReleaseDAO() {
00021 parent::DAO();
00022 }
00023
00030 function getMonographIdsByAssoc($assocType, $assocId) {
00031 $returner = array();
00032 $result =& $this->retrieve(
00033 'SELECT monograph_id FROM new_releases WHERE assoc_type = ? AND assoc_id = ?',
00034 array((int) $assocType, (int) $assocId)
00035 );
00036
00037 while (!$result->EOF) {
00038 list($monographId) = $result->fields;
00039 $returner[$monographId] = true;
00040 $result->MoveNext();
00041 }
00042
00043 $result->Close();
00044 unset($result);
00045
00046 return $returner;
00047 }
00048
00055 function getMonographsByAssoc($assocType, $assocId) {
00056 $returner = array();
00057 $result =& $this->retrieve(
00058 'SELECT n.monograph_id FROM new_releases n, published_monographs pm
00059 WHERE n.monograph_id = pm.monograph_id AND assoc_type = ? AND assoc_id = ? ORDER BY pm.date_published DESC',
00060 array((int) $assocType, (int) $assocId)
00061 );
00062
00063 $publishedMonographDao =& DAORegistry::getDAO('PublishedMonographDAO');
00064 while (!$result->EOF) {
00065 list($monographId) = $result->fields;
00066 $returner[] =& $publishedMonographDao->getById($monographId);
00067 $result->MoveNext();
00068 }
00069
00070 $result->Close();
00071 unset($result);
00072
00073 return $returner;
00074 }
00075
00082 function insertNewRelease($monographId, $assocType, $assocId) {
00083 $this->update(
00084 'INSERT INTO new_releases
00085 (monograph_id, assoc_type, assoc_id)
00086 VALUES
00087 (?, ?, ?)',
00088 array(
00089 (int) $monographId,
00090 (int) $assocType,
00091 (int) $assocId
00092 )
00093 );
00094 }
00095
00101 function deleteByMonographId($monographId) {
00102 $this->update(
00103 'DELETE FROM new_releases WHERE monograph_id = ?',
00104 (int) $monographId
00105 );
00106 }
00107
00113 function deleteByAssoc($assocType, $assocId) {
00114 $this->update(
00115 'DELETE FROM new_releases WHERE assoc_type = ? AND assoc_id = ?',
00116 array((int) $assocType, (int) $assocId)
00117 );
00118 }
00119
00126 function deleteNewRelease($monographId, $assocType, $assocId) {
00127 $this->update(
00128 'DELETE FROM new_releases
00129 WHERE monograph_id = ? AND
00130 assoc_type = ? AND
00131 assoc_id = ?',
00132 array(
00133 (int) $monographId,
00134 (int) $assocType,
00135 (int) $assocId
00136 )
00137 );
00138 }
00139 }
00140
00141 ?>