Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

ezdbtool.php
Go to the documentation of this file.
1 <?php
17 class eZDBTool
18 {
23 static function isEmpty( $db )
24 {
25 if ( $db === null )
26 $db = eZDB::instance();
27 $relationTypeMask = $db->supportedRelationTypeMask();
28 $count = $db->relationCounts( $relationTypeMask );
29 return $count == 0;
30 }
31
36 static function cleanup( $db )
37 {
38 if ( $db === null )
39 $db = eZDB::instance();
40 $relationTypes = $db->supportedRelationTypes();
41 $result = true;
42 $defaultRegexp = "#^ez|tmp_notification_rule_s#";
43 foreach ( $relationTypes as $relationType )
44 {
45 $relationItems = $db->relationList( $relationType );
46 // This is the default regexp, unless the db driver provides one
47 $matchRegexp = null;
48 if ( method_exists( $db, 'relationMatchRegexp' ) )
49 {
50 $matchRegexp = $db->relationMatchRegexp( $relationType );
51 }
52 if ( $matchRegexp === null )
53 $matchRegexp = $defaultRegexp;
54 foreach ( $relationItems as $relationItem )
55 {
56 // skip relations that shouldn't be touched
57 if ( $matchRegexp !== false and
58 !preg_match( $matchRegexp, $relationItem ) )
59 continue;
60
61 if ( !$db->removeRelation( $relationItem, $relationType ) )
62 {
63 $result = false;
64 break;
65 }
66 }
67 if ( !$result )
68 break;
69 }
70 return $result;
71 }
72 }
73
74 ?>
eZDBTool
The class eZDBTool does.
Definition: ezdbtool.php:18
eZDBTool\cleanup
static cleanup( $db)
Definition: ezdbtool.php:36
eZDBTool\isEmpty
static isEmpty( $db)
Definition: ezdbtool.php:23
eZDB\instance
static instance( $databaseImplementation=false, $databaseParameters=false, $forceNewInstance=false)
Definition: ezdb.php:117
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.