~eda-qa/brainbrain/main

« back to all changes in this revision

Viewing changes to dist/admin/cleanup_titles.php

  • Committer: edA-qa mort-ora-y
  • Date: 2010-04-18 11:19:01 UTC
  • Revision ID: eda-qa@disemia.com-20100418111901-opwm0incj57oqz3n
cleanup changes

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
        require_once dirname(__FILE__).'/common.inc';
10
10
                
11
11
        //we'll just let MySQL do all the work
 
12
        print( "Deleting old names..." );
12
13
        $res = dt_connectdb()->exec( "delete from {$brain_dbprefix}titlemap "
13
14
                . "where searchtitle not in "
14
15
                . "(select distinct searchtitle from {$brain_dbprefix}linksto)" 
15
16
                . " AND source=" . BrainEntryTitleMap::SOURCE_OLD
16
17
                );
17
18
        check_error( $res );
 
19
        print( "\n" );
18
20
 
19
21
        
20
22
        //getting rid of duplicates is troublesome (no magical MySQL method)
26
28
                );
27
29
                
28
30
        //count how many of each entry we have (only select those with duplicates)
 
31
        print( "Deleting duplicate names." );
29
32
        $res = dt_connectdb()->query( "select entryid, searchtitle, count(*) as c "
30
33
                . " from {$brain_dbprefix}titlemap "
31
34
                . " where source=" . BrainEntryTitleMap::SOURCE_OLD
33
36
                );
34
37
        check_error( $res );
35
38
        while( ($row = $res->fetchRow()) ) {
 
39
                print( "." );
36
40
                //now delete all but one of those
37
41
                $t = $ex->execute( array( $row['entryid'], $row['searchtitle'], $row['c']-1 ) );
38
42
                check_error( $t );
39
43
        }
 
44
        print( "\n" );
40
45
 
41
46
?>
 
 
b'\\ No newline at end of file'