[ Index ] |
|
Code source de SPIP Agora 1.4 |
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 Signature business persistence abstraction. 20 // 21 22 if (defined("_BD_SIGNATUREMYSQL")) 23 return; 24 25 define("_BD_SIGNATUREMYSQL", "1"); 26 27 require_once dirname(__FILE__). "/../signature.php"; 28 29 /** 30 * BD_signature_mysql is an implementation for MySQL of BD_signature business class. 31 * @package BD_mysql 32 * @author Erwan Le Bescond <elebescond@clever-age.com> 33 * @access public 34 */ 35 class BD_signature_mysql extends BD_signature { 36 37 // {{{ howManySignatureForStatutsAndDateTime($statut1, $statut2, $id_article) 38 39 /** 40 * This method returns the number of signature 41 * @return int 42 * @access public 43 */ 44 function howManySignatureForStatutsAndDateTime ($statut1, $statut2, $id_article = null) { 45 $howManySignatures = 0; 46 $db = &$this->_getDB(); 47 48 if (DB::isError($db)) { 49 return PEAR::raiseError( 50 "[" . get_class( 51 $this). " DB_signature : howManySignatureForStatutsAndDateTime()] " . $db->getMessage(). "", 52 null, 53 null, 54 null, 55 null, 56 null, 57 false); 58 } 59 60 $query 61 = "SELECT COUNT(*) AS cnt FROM " . $GLOBALS['table_prefix']. "_signatures WHERE (statut='$statut1' OR statut='$statut1') AND date_time>DATE_SUB(NOW(),INTERVAL 180 DAY)"; 62 63 if ($id_article != null) 64 $query .= " AND id_article=$id_article"; 65 66 $result = $db->getOne($query); 67 68 if (DB::isError($result)) { 69 return PEAR::raiseError( 70 "[" . get_class( 71 $this). " DB_signature : howManySignatureForStatutsAndDateTime()] " . $result->getMessage(). "", 72 null, 73 null, 74 null, 75 null, 76 null, 77 false); 78 } 79 else { 80 $howManySignatures = $result; 81 } 82 83 return $howManySignatures; 84 } 85 86 // }}} 87 88 // {{{ deleteForStatutsAndDateTime($statut1, $statut2) 89 90 /** 91 * This method is used to delete $statut1 and $statut2 signatures 92 * @access public 93 */ 94 function deleteForStatutsAndDateTime ($statut1, $statut2) { 95 $db = &$this->_getDB(); 96 97 if (DB::isError($db)) { 98 return PEAR::raiseError( 99 "[" . get_class( 100 $this). " DB_signature : deleteForStatutsAndDateTime()] " . $db->getMessage(). "", 101 null, 102 null, 103 null, 104 null, 105 null, 106 false); 107 } 108 109 $query 110 = "DELETE FROM " . $GLOBALS['table_prefix']. "_signatures WHERE NOT (statut='$statut1' OR statut='$statut2') AND date_time<DATE_SUB(NOW(),INTERVAL 10 DAY)"; 111 112 $result = $db->query($query); 113 114 if (DB::isError($result)) { 115 return PEAR::raiseError( 116 "[" . get_class( 117 $this). " DB_signature : deleteForStatutsAndDateTime()] " . $result->getMessage(). "", 118 null, 119 null, 120 null, 121 null, 122 null, 123 false); 124 } 125 } 126 127 // }}} 128 } 129 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sat Feb 24 14:40:03 2007 | par Balluche grâce à PHPXref 0.7 |