[ 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/sqlite/ -> visite_sqlite.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 Visite business persistence abstraction.
  20  //
  21  require_once dirname(__FILE__). "/../visite.php";
  22  
  23  require_once dirname(__FILE__). "/SQLite_functions.php";
  24  
  25  /**
  26   * BD_visite_sqlite is an implementation for sqlite of BD_visite business class.
  27   * @package    BD_sqlite
  28   * @author     Olivier Mansour
  29   * @access    public
  30   */
  31  class BD_visite_sqlite extends BD_visite {
  32      // {{{ howManyDistinctVisite()
  33  
  34  	function howManyDistinctVisite () {
  35          $howManyVisite = 0;
  36          $db = &$this->_getDB();
  37  
  38          if (DB::isError($db)) {
  39              return PEAR::raiseError(
  40                         "[" . get_class($this). " DB_visite : howManyDistinctVisite()] " . $db->getMessage(). "", null,
  41                         null, null,
  42                         null, null,
  43                         false);
  44          }
  45  
  46          //$query = "SELECT COUNT(DISTINCT ip) AS total_visites FROM spip_visites_temp";
  47          // adaptation aux contraintes de sqlite 
  48          $query = "SELECT COUNT(ip) AS total_visites FROM (SELECT DISTINCT ip from spip_visites_temp)";
  49          $query = $this->_traiteQuery($query);
  50          $result = $db->query($query);
  51  
  52          if (DB::isError($result)) {
  53              return PEAR::raiseError(
  54                         "[" . get_class($this). " DB_visite : howManyDistinctVisite()] " . $result->getMessage(). "",
  55                         null,
  56                         null,
  57                         null,
  58                         null,
  59                         null,
  60                         false);
  61          }
  62  
  63          if ($row = $result->fetchRow()) {
  64              $howManyVisite = intval($row["total_visites"]);
  65          }
  66  
  67          $result->free();
  68          return $howManyVisite;
  69      }
  70  
  71      // }}}
  72  
  73      // {{{ howManyDistinctVisiteForAnArticle($id_article = null)
  74  
  75  	function howManyDistinctVisiteForAnArticle ($id_article = null) {
  76          $howManyVisite = 0;
  77          $db = &$this->_getDB();
  78  
  79          if (DB::isError($db)) {
  80              return PEAR::raiseError(
  81                         "[" . get_class(
  82                                   $this). " DB_visite : howManyDistinctVisiteForAnArticle()] " . $db->getMessage(). "",
  83                         null,
  84                         null,
  85                         null,
  86                         null,
  87                         null,
  88                         false);
  89          }
  90  
  91          //$query = "SELECT COUNT(DISTINCT ip) AS c FROM spip_visites_temp";
  92          $query = "SELECT COUNT(ip) AS total_visites FROM (SELECT DISTINCT ip from spip_visites_temp)";
  93  
  94          if ($id_article != null) {
  95              $query .= " WHERE type='article' AND id_objet=$id_article";
  96          }
  97  
  98          $query = $this->_traiteQuery($query);
  99          $result = $db->query($query);
 100  
 101          if (DB::isError($result)) {
 102              return PEAR::raiseError(
 103                         "[" . get_class(
 104                                   $this). " DB_visite : howManyDistinctVisiteForAnArticle()] " . $result->getMessage(). "", null, null, null, null, null, false);
 105          }
 106  
 107          if ($row = $result->fetchRow()) {
 108              $howManyVisite = intval($row["c"]);
 109          }
 110  
 111          $result->free();
 112          return $howManyVisite;
 113      }
 114  
 115      // }}}
 116  
 117      // {{{ _fetchData()
 118  
 119      /**
 120       * This method is used to fetch result set fields into the object fields
 121       * @access  private
 122       * @param   array $row content of fetched data
 123       */
 124  
 125  	function _fetchData ($row) {
 126          SQLite_CleanName($row);
 127          BD_visite::_fetchData($row);
 128      }
 129  
 130  // }}}
 131  }
 132  ?>


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