Changeset 11848

Show
Ignore:
Timestamp:
08/30/07 11:30:56 (1 year ago)
Author:
netblade
Message:

Colletrizied name-check, refs #102

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/midcom/midcom.core/midcom/baseclasses/database/article.php

    r4739 r11848  
    4848            return true; 
    4949        } 
    50          
    51         $qb = midcom_baseclasses_database_article::new_query_builder(); 
    52         $qb->add_constraint('name', '=', $this->name); 
    53          
     50 
     51        $mc = midcom_baseclasses_database_article::new_collector('name', $this->name); 
     52        $mc->add_constraint('name', '=', $this->name); 
     53 
    5454        if ($this->id) 
    5555        { 
    56             $qb->add_constraint('id', '<>', $this->id); 
    57         } 
    58          
     56            $mc->add_constraint('id', '<>', $this->id); 
     57        } 
     58 
    5959        if ($this->up != 0) 
    6060        { 
    6161            // "Reply article", we care only about the up field 
    62             $qb->add_constraint('up', '=', $this->up); 
     62            $mc->add_constraint('up', '=', $this->up); 
    6363        } 
    6464        else 
    6565        { 
    6666            // Toplevel article, check topic 
    67             $qb->add_constraint('topic', '=', $this->topic); 
    68         } 
    69          
     67            $mc->add_constraint('topic', '=', $this->topic); 
     68        } 
     69 
    7070        // Run the uniqueness check 
    71         $matches = $qb->execute_unchecked(); 
    72         if (count($matches) > 0) 
     71        if ($mc->count > 0) 
    7372        { 
    7473            // This name is already taken