[ Index ]
 

Code source de SPIP Agora 1.4

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/Agora1-4/ecrire/include/bd/mysql/ -> syndic_mysql.php (source)

   1  <?php
   2  /*****************************************************
   3  * This file is part of Agora, web based content management system.
   4  *
   5  * Agora is free software; you can redistribute it and/or modify
   6  * it under the terms of the GNU General Public License as published by
   7  * the Free Software Foundation; version 2 of the License.
   8  *
   9  * Agora is distributed in the hope that it will be useful,
  10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12  * GNU General Public License for more details (file "COPYING").
  13  *
  14  * Copyright © Arnaud Martin, Antoine Pitrou et Philippe Rivière.
  15  * List of authors detailed in "copyright_fr.html" file.
  16  * E-mail : agora@sig.premier-ministre.gouv.fr
  17  * Web site : http://www.agora.gouv.fr
  18  *****************************************************/
  19  // Base class for Syndic business persistence abstraction.
  20  //
  21  
  22  if (defined("_BD_SYNDICMYSQL"))
  23      return;
  24  
  25  define("_BD_SYNDICMYSQL", "1");
  26  
  27  require_once dirname(__FILE__). "/../syndic.php";
  28  
  29  /**
  30   * BD_syndic_mysql is an implementation for MySQL of BD_syndic business class.
  31   * @package    BD_mysql
  32   * @author     Erwan Le Bescond <elebescond@clever-age.com>
  33   * @access    public
  34   */
  35  class BD_syndic_mysql extends BD_syndic {
  36  
  37      // {{{ getSyndicIdsForStatutAndDateIndex($statut)
  38  
  39      /**
  40       * Returns an array of Syndic IDS.
  41       *
  42       * @return Array of SyndicsIds
  43       * @param $month
  44       * @param $year
  45       * @access public
  46       */
  47  
  48      function &getSyndicIdsForStatutAndDateIndex ($statut) {
  49          $result = array();
  50          $db = &$this->_getDB();
  51  
  52          if (DB::isError($db)) {
  53              return PEAR::raiseError(
  54                         "[" . get_class(
  55                                   $this). " DB_syndic : getSyndicIdsForStatutAndDateIndex()] " . $db->getMessage(). "",
  56                         null,
  57                         null,
  58                         null,
  59                         null,
  60                         null,
  61                         false);
  62          }
  63  
  64          $query
  65              = "SELECT id_syndic FROM " . $GLOBALS['table_prefix']. "_syndic WHERE statut='$statut' AND date_index < DATE_SUB(NOW(), INTERVAL 7 DAY) ORDER BY date_index";
  66  
  67          $queryResult = $db->limitQuery($query, 0, 1);
  68  
  69          if (DB::isError($queryResult)) {
  70              return PEAR::raiseError(
  71                         "[" . get_class(
  72                                   $this). " DB_syndic : getSyndicIdsForStatutAndDateIndex()] " . $queryResult->getMessage(). "",
  73                         null,
  74                         null,
  75                         null,
  76                         null,
  77                         null,
  78                         false);
  79          }
  80  
  81          while ($row = $queryResult->fetchRow()) {
  82              $result[] = $row['id_syndic'];
  83          }
  84  
  85          $queryResult->free();
  86          return $result;
  87      }
  88  
  89      // }}}
  90  
  91      // {{{ getAllForSyndicationAndStatutAndIntervalHour($syndication, $statut, $hour)
  92  
  93      /**
  94       * Returns an array of Syndication.
  95       *
  96       *
  97       * @return Array of Syndication
  98       * @param $syndication
  99       * @param $statut
 100       * @param $hour
 101       * @access public
 102       */
 103  
 104      function &getAllForSyndicationAndStatutAndIntervalHour ($syndication, $statut, $hour) {
 105          $result = array();
 106          $db = &$this->_getDB();
 107  
 108          if (DB::isError($db)) {
 109              return PEAR::raiseError(
 110                         "[" . get_class(
 111                                   $this). " DB_syndic : getAllForSyndicationAndStatutAndIntervalHour()] " . $db->getMessage(). "",
 112                         null,
 113                         null,
 114                         null,
 115                         null,
 116                         null,
 117                         false);
 118          }
 119  
 120          $query
 121              = "SELECT * FROM " . $GLOBALS['table_prefix']. "_syndic WHERE syndication='$syndication' AND statut='$statut' AND date_syndic < DATE_SUB(NOW(), INTERVAL $hour HOUR) ORDER BY date_syndic";
 122  
 123          //echo "<br>$query<br>";
 124  
 125          $queryResult = $db->limitQuery($query, 0, 1);
 126  
 127          if (DB::isError($queryResult)) {
 128              return PEAR::raiseError(
 129                         "[" . get_class(
 130                                   $this). " DB_syndic : getAllForSyndicationAndStatutAndIntervalHour()] " . $queryResult->getMessage(). "",
 131                         null,
 132                         null,
 133                         null,
 134                         null,
 135                         null,
 136                         false);
 137          }
 138  
 139          while ($row = $queryResult->fetchRow()) {
 140              $resultSyndic = &BD_syndic::factory($this->getDbParameters(), $this->getDbOptions());
 141              $resultSyndic->setSyndicId($row['id_syndic']);
 142              $resultSyndic->setRubriqueId($row['id_rubrique']);
 143              $resultSyndic->setSecteurId($row['id_secteur']);
 144              $resultSyndic->setNomSite($row['nom_site']);
 145              $resultSyndic->setUrlSite($row['url_site']);
 146              $resultSyndic->setUrlSyndic($row['url_syndic']);
 147              $resultSyndic->setDescriptif($row['descriptif']);
 148              $resultSyndic->setMajDate($row['maj']);
 149              $resultSyndic->setSyndication($row['syndication']);
 150              $resultSyndic->setStatut($row['statut']);
 151              $resultSyndic->setDate($row['date_heure']);
 152              $resultSyndic->setDateSyndic($row['date_syndic']);
 153              $resultSyndic->setDateIndex($row['date_index']);
 154              $resultSyndic->setModeration($row['moderation']);
 155              $result[] = &$resultSyndic;
 156          }
 157  
 158          $queryResult->free();
 159          return $result;
 160      }
 161  
 162      // }}}
 163  
 164      // {{{ getAllSyndicForSyndicIdAndsyndication($id_syndic)
 165  
 166      /**
 167       * Returns an array of Syndication.
 168       *
 169       *
 170       * @return Array of Syndication
 171       * @param $id_syndic
 172       * @access public
 173       */
 174  
 175      function &getAllSyndicForSyndicIdAndsyndication ($id_syndic) {
 176          $result = array();
 177          $db = &$this->_getDB();
 178  
 179          if (DB::isError($db)) {
 180              return PEAR::raiseError(
 181                         "[" . get_class(
 182                                   $this). " DB_syndic : getAllSyndicForSyndicIdAndsyndication()] " . $db->getMessage(). "",
 183                         null,
 184                         null,
 185                         null,
 186                         null,
 187                         null,
 188                         false);
 189          }
 190  
 191          $query
 192              = "SELECT * FROM " . $GLOBALS['table_prefix']. "_syndic WHERE id_syndic='$id_syndic' AND syndication IN ('oui', 'sus', 'off')";
 193  
 194          //echo "<br>$query<br>";
 195  
 196          $queryResult = $db->query($query);
 197  
 198          if (DB::isError($queryResult)) {
 199              return PEAR::raiseError(
 200                         "[" . get_class(
 201                                   $this). " DB_syndic : getAllSyndicForSyndicIdAndsyndication()] " . $queryResult->getMessage(). "",
 202                         null,
 203                         null,
 204                         null,
 205                         null,
 206                         null,
 207                         false);
 208          }
 209  
 210          while ($row = $queryResult->fetchRow()) {
 211              $resultSyndic = &BD_syndic::factory($this->getDbParameters(), $this->getDbOptions());
 212              $resultSyndic->setSyndicId($row['id_syndic']);
 213              $resultSyndic->setRubriqueId($row['id_rubrique']);
 214              $resultSyndic->setSecteurId($row['id_secteur']);
 215              $resultSyndic->setNomSite($row['nom_site']);
 216              $resultSyndic->setUrlSite($row['url_site']);
 217              $resultSyndic->setUrlSyndic($row['url_syndic']);
 218              $resultSyndic->setDescriptif($row['descriptif']);
 219              $resultSyndic->setMajDate($row['maj']);
 220              $resultSyndic->setSyndication($row['syndication']);
 221              $resultSyndic->setStatut($row['statut']);
 222              $resultSyndic->setDate($row['date_heure']);
 223              $resultSyndic->setDateSyndic($row['date_syndic']);
 224              $resultSyndic->setDateIndex($row['date_index']);
 225              $resultSyndic->setModeration($row['moderation']);
 226              $result[] = &$resultSyndic;
 227          }
 228  
 229          $queryResult->free();
 230          return $result;
 231      }
 232  
 233  // }}}
 234  }
 235  ?>


Généré le : Sat Feb 24 14:40:03 2007 par Balluche grâce à PHPXref 0.7