[ Index ] |
|
Code source de eZ Publish 3.9.0 |
1 <?php 2 // 3 // Definition of eZDBTool class 4 // 5 // Created on: <11-Dec-2002 15:07:25 amos> 6 // 7 // SOFTWARE NAME: eZ publish 8 // SOFTWARE RELEASE: 3.9.0 9 // BUILD VERSION: 17785 10 // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS 11 // SOFTWARE LICENSE: GNU General Public License v2.0 12 // NOTICE: > 13 // This program is free software; you can redistribute it and/or 14 // modify it under the terms of version 2.0 of the GNU General 15 // Public License as published by the Free Software Foundation. 16 // 17 // This program is distributed in the hope that it will be useful, 18 // but WITHOUT ANY WARRANTY; without even the implied warranty of 19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 // GNU General Public License for more details. 21 // 22 // You should have received a copy of version 2.0 of the GNU General 23 // Public License along with this program; if not, write to the Free 24 // Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 25 // MA 02110-1301, USA. 26 // 27 // 28 29 /*! \file ezdbtool.php 30 */ 31 32 /*! 33 \class eZDBTool ezdbtool.php 34 \brief The class eZDBTool does 35 36 */ 37 38 include_once ( 'lib/ezdb/classes/ezdb.php' ); 39 40 class eZDBTool 41 { 42 /*! 43 Constructor 44 */ 45 function eZDBTool() 46 { 47 } 48 49 /*! 50 \return true if the database does not contain any relation objects. 51 \note If db is not specified it will use eZDB::instance() 52 */ 53 function isEmpty( &$db ) 54 { 55 if ( $db === null ) 56 $db =& eZDB::instance(); 57 $relationTypeMask = $db->supportedRelationTypeMask(); 58 $count = $db->relationCounts( $relationTypeMask ); 59 return $count == 0; 60 } 61 62 /*! 63 Tries to remove all relation types from the database. 64 \note If db is not specified it will use eZDB::instance() 65 */ 66 function cleanup( &$db ) 67 { 68 if ( $db === null ) 69 $db =& eZDB::instance(); 70 $relationTypes = $db->supportedRelationTypes(); 71 $result = true; 72 $defaultRegexp = "#^ez|tmp_notification_rule_s#"; 73 foreach ( $relationTypes as $relationType ) 74 { 75 $relationItems = $db->relationList( $relationType ); 76 // This is the default regexp, unless the db driver provides one 77 $matchRegexp = null; 78 if ( method_exists( $db, 'relationMatchRegexp' ) ) 79 { 80 $matchRegexp = $db->relationMatchRegexp( $relationType ); 81 } 82 if ( $matchRegexp === null ) 83 $matchRegexp = $defaultRegexp; 84 foreach ( $relationItems as $relationItem ) 85 { 86 // skip relations that shouldn't be touched 87 if ( $matchRegexp !== false and 88 !preg_match( $matchRegexp, $relationItem ) ) 89 continue; 90 91 if ( !$db->removeRelation( $relationItem, $relationType ) ) 92 { 93 $result = false; 94 break; 95 } 96 } 97 if ( !$result ) 98 break; 99 } 100 return $result; 101 } 102 } 103 104 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sat Feb 24 10:30:04 2007 | par Balluche grâce à PHPXref 0.7 |