Changeset 1086 for trunk/common


Ignore:
Timestamp:
12/22/09 14:21:51 (2 years ago)
Author:
Prostu
Message:

Show and delete all the pages that have a round name in their text.

Reviewed: http://reviewboard.infoarena.ro/r/115/

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/common/db/textblock.php

    r1074 r1086  
    243243 
    244244// Grep through textblocks. This is mostly a hack needed for macro_grep.php 
    245 function textblock_grep($substr, $page, $regexp = false) { 
     245// Also used for round deletion 
     246function textblock_grep($substr, $page, $regexp = false, $offset = 0, $count = 0) { 
    246247    if (!$regexp) { 
    247248        $compare = "LIKE"; 
     
    255256                      WHERE `name` LIKE '%s' AND 
    256257                            (`text` $compare '%s' OR `title` $compare '%s') 
    257                       ORDER BY `name`", 
     258                      ORDER BY `name` 
     259                      LIMIT %s, %s", 
     260                      db_escape($page), db_escape($substr), db_escape($substr), 
     261                      db_escape($offset), db_escape($count)); 
     262    return db_fetch_all($query); 
     263} 
     264 
     265function textblock_grep_count($substr, $page, $regexp = false) { 
     266    if (!$regexp) { 
     267        $compare = "LIKE"; 
     268    } else { 
     269        $compare = "REGEXP"; 
     270    } 
     271    $query = sprintf("SELECT COUNT(*) as `cnt` 
     272                      FROM ia_textblock 
     273                      WHERE `name` LIKE '%s' AND 
     274                            (`text` $compare '%s' OR `title` $compare '%s')", 
    258275                      db_escape($page), db_escape($substr), db_escape($substr)); 
    259     return db_fetch_all($query); 
     276    return db_fetch($query); 
    260277} 
    261278 
     
    278295    db_query("DELETE FROM `ia_textblock_revision` WHERE `name` = '$pageesc'"); 
    279296    db_query("DELETE FROM `ia_textblock` WHERE `name` = '$pageesc'"); 
    280     if (db_affected_rows() != 1) { 
    281         return true; 
    282     } 
     297 
     298    return (db_affected_rows() != 0); 
    283299} 
    284300 
Note: See TracChangeset for help on using the changeset viewer.