• Main Page
  • Modules
  • Classes
  • Files
  • File List

classes/press/FeatureDAO.inc.php

00001 <?php
00002 
00016 class FeatureDAO extends DAO {
00020    function FeatureDAO() {
00021       parent::DAO();
00022    }
00023 
00030    function getMonographIdsByAssoc($assocType, $assocId) {
00031       $returner = array();
00032       $result =& $this->retrieve(
00033          'SELECT monograph_id, seq FROM features WHERE assoc_type = ? AND assoc_id = ? ORDER BY seq',
00034          array((int) $assocType, (int) $assocId)
00035       );
00036 
00037       while (!$result->EOF) {
00038          list($monographId, $seq) = $result->fields;
00039          $returner[$seq] = $monographId;
00040          $result->MoveNext();
00041       }
00042 
00043       $result->Close();
00044       unset($result);
00045 
00046       return $returner;
00047    }
00048 
00055    function getSequencesByAssoc($assocType, $assocId) {
00056       return array_flip($this->getMonographIdsByAssoc($assocType, $assocId));
00057    }
00058 
00066    function insertFeature($monographId, $assocType, $assocId, $seq) {
00067       $this->update(
00068          'INSERT INTO features
00069             (monograph_id, assoc_type, assoc_id, seq)
00070             VALUES
00071             (?, ?, ?, ?)',
00072          array(
00073             (int) $monographId,
00074             (int) $assocType,
00075             (int) $assocId,
00076             (int) $seq
00077          )
00078       );
00079    }
00080 
00086    function deleteByMonographId($monographId) {
00087       $this->update(
00088          'DELETE FROM features WHERE monograph_id = ?',
00089          (int) $monographId
00090       );
00091    }
00092 
00098    function deleteByAssoc($assocType, $assocId) {
00099       $this->update(
00100          'DELETE FROM features WHERE assoc_type = ? AND assoc_id = ?',
00101          array((int) $assocType, (int) $assocId)
00102       );
00103    }
00104 
00111    function deleteFeature($monographId, $assocType, $assocId) {
00112       $this->update(
00113          'DELETE FROM features
00114          WHERE monograph_id = ? AND
00115             assoc_type = ? AND
00116             assoc_id = ?',
00117          array(
00118             (int) $monographId,
00119             (int) $assocType,
00120             (int) $assocId
00121          )
00122       );
00123    }
00124 
00132    function resequenceByAssoc($assocType, $assocId) {
00133       $returner = array();
00134       $result =& $this->retrieve(
00135          'SELECT monograph_id FROM features WHERE assoc_type = ? AND assoc_id = ? ORDER BY seq',
00136          array((int) $assocType, (int) $assocId)
00137       );
00138 
00139       for ($i=2; !$result->EOF; $i+=2) {
00140          list($monographId) = $result->fields;
00141          $this->update(
00142             'UPDATE features SET seq = ? WHERE monograph_id = ? AND assoc_type = ? AND assoc_id = ?',
00143             array(
00144                $i,
00145                $monographId,
00146                (int) $assocType,
00147                (int) $assocId
00148             )
00149          );
00150          $returner[$monographId] = $i;
00151 
00152          $result->MoveNext();
00153       }
00154 
00155       $result->Close();
00156       unset($result);
00157 
00158       return $returner;
00159    }
00160 }
00161 
00162 ?>

Generated on Mon Sep 17 2012 13:58:55 for Open Monograph Press by  doxygen 1.7.1