[ 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 // Sub Implementation for handling spip-agora table prefixes of the SQLScript class 20 // 21 22 require_once (dirname(__FILE__). '/../SQLScript.php'); 23 24 /** 25 * SQLScript_spipagora is a helper class to execute 26 * specially formatted SQL scripts. It allows handling 27 * of spip-agora $table_prefix variable 28 * 29 * @auhthor Antoine Angénieux <aangenieux@clever-age.com> 30 * @version 1.0 31 */ 32 33 class SQLScript_spipagora extends SQLScript { 34 35 // {{{ properties 36 37 /** 38 * _tablePrefix table prefix to be used for the spip-agora installation 39 * @var String 40 * @access private 41 */ 42 var $_tablePrefix; 43 44 // {{{ constructor 45 46 function SQLScript_spipagora ($sqlFile, $fileType = BLOCKMODE) { 47 if (!($fileType == BLOCKMODE || $fileType == LINEMODE)) { 48 die ("<br>Filetype specified is neither BLOCKMODE nor LINEMODE ! fileType = $fileType"); 49 } 50 51 $this->_sqlFile = $sqlFile; 52 $this->_fileType = $fileType; 53 } 54 55 // }}} 56 57 // {{{ destructor 58 59 function _SQLScript () { 60 $this->_sqlFile = null; 61 } 62 63 // }}} 64 65 // {{{ _executeQuery() 66 67 /** 68 * Execute the passed query. Query processing is achieved based 69 * on the query mode passed. 70 * Dirty implementation based on copy/paste from SPIP original code 71 * @param $db DB or MDB reference to an open connection 72 * @param $query String representing the SQL query to execute 73 */ 74 75 function _executeQuery (&$dbInstance, $query) { 76 $query = trim($query); 77 $query = substr($query, 0, strlen($query) - 1); 78 79 if ($GLOBALS['flag_pcre']) { 80 if (preg_match('/\s(VALUES|WHERE)\s/i', $query, $regs)) { 81 $suite = strstr($query, $regs[0]); 82 $query = substr($query, 0, -strlen($suite)); 83 } 84 $query = preg_replace('/([,\s])spip_/', '\1' . $db . $GLOBALS['table_prefix']. '_', $query). $suite; 85 } 86 else { 87 if (eregi('[[:space:]](VALUES|WHERE)[[:space:]]', $query, $regs)) { 88 $suite = strstr($query, $regs[0]); 89 $query = substr($query, 0, -strlen($suite)); 90 } 91 $query = ereg_replace('([[:space:],])spip_', '\1' . $db . $GLOBALS['table_prefix']. '_', $query). $suite; 92 } 93 94 return $dbInstance->query($query); 95 } 96 97 // }}} 98 99 } 100 ?>
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 |