[ 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/ -> service_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 Mot business persistence abstraction.
  20  //
  21  
  22  if (defined("_SERVICEMYSQL"))
  23      return;
  24  
  25  define("_SERVICEMYSQL", "1");
  26  
  27  require_once dirname(__FILE__). "/../service.php";
  28  
  29  /**
  30   * service_mysql is an implementation for MySQL of service class.
  31   * @package    BD_mysql
  32   * @author     Erwan Le Bescond <elebescond@clever-age.com>
  33   * @access    public
  34   */
  35  class Service_mysql extends Service {
  36      // {{{ getLock($nom, $timeout = 0)
  37  
  38      /**
  39       * unlock AGORA.
  40       *
  41       *
  42       * @return  mixed   boolean or PEAR::Error object
  43       * @param $nom
  44       * @param $timeout
  45       * @access public
  46       */
  47  
  48  	function getLock ($nom, $timeout = 0) {
  49          $result = array();
  50          $db = &$this->_getDB();
  51  
  52          if (DB::isError($db)) {
  53              return PEAR::raiseError("[" . get_class($this). " service : getLock()] " . $db->getMessage(). "", null,
  54                                      null, null,
  55                                      null, null,
  56                                      false);
  57          }
  58  
  59          global $spip_mysql_db, $table_prefix;
  60  
  61          if ($table_prefix)
  62              $nom = "$table_prefix:$nom";
  63  
  64          if ($spip_mysql_db)
  65              $nom = "$spip_mysql_db:$nom";
  66  
  67          $nom = addslashes($nom);
  68  
  69          $query = "SELECT GET_LOCK('$nom', $timeout) AS result";
  70  
  71          $queryResult = $db->query($query);
  72  
  73          if (DB::isError($queryResult)) {
  74              return PEAR::raiseError("[" . get_class($this). " DB_message : getLock()] " . $queryResult->getMessage(). "", null, null, null, null, null, false);
  75          }
  76  
  77          if ($row = $queryResult->fetchRow()) {
  78              //spip_log("Service_mysql: '$query' renvoie ".$row['result']);
  79              return $row['result'];
  80          }
  81      }
  82  
  83      // }}}
  84  
  85      // {{{ releaseLock($nom)
  86  
  87      /**
  88       * unlock AGORA.
  89       *
  90       *
  91       * @return  mixed   void or PEAR::Error object
  92       * @param $nom
  93       * @access public
  94       */
  95  
  96  	function releaseLock ($nom) {
  97          $db = &$this->_getDB();
  98  
  99          if (DB::isError($db)) {
 100              return PEAR::raiseError("[" . get_class($this). " service : releaseLock()] " . $db->getMessage(). "", null, null, null, null, null, false);
 101          }
 102  
 103          global $spip_mysql_db, $table_prefix;
 104  
 105          if ($table_prefix)
 106              $nom = "$table_prefix:$nom";
 107  
 108          if ($spip_mysql_db)
 109              $nom = "$spip_mysql_db:$nom";
 110  
 111          $nom = addslashes($nom);
 112          $query = "SELECT RELEASE_LOCK('$nom')";
 113  
 114          //echo $query;
 115          $queryResult = $db->query($query);
 116  
 117          if (DB::isError($queryResult)) {
 118              return PEAR::raiseError("[" . get_class($this). " DB_message : releaseLock()] " . $queryResult->getMessage(). "", null, null, null, null, null, false);
 119          }
 120      }
 121  
 122  // }}}
 123  
 124  }
 125  ?>


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