Advertisement
Guest User

Untitled

a guest
Mar 7th, 2016
854
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. public static function listPagesByPrefix( $prefix ) {
  2. $dbr = wfGetDB( DB_SLAVE );
  3.  
  4. $title = Title::newFromText( $prefix );
  5. if ( $title ) {
  6. $ns = $title->getNamespace();
  7. $prefix = $title->getDBkey();
  8. } else {
  9. // Prolly won't work too good
  10. // @todo handle bare namespace names cleanly?
  11. $ns = 0;
  12. }
  13.  
  14. $conds = [
  15. 'ar_namespace' => $ns,
  16. 'ar_title' . $dbr->buildLike( $prefix , $dbr->anyString() ),
  17. ];
  18.  
  19. **$sql = " SELECT ar_namespace , ar_title , COUNT(*) as count FROM archive WHERE MATCH(ar_title) AGAINST('$prefix' IN BOOLEAN MODE) AND ar_namespace = $ns GROUP BY ar_namespace , ar_title ORDER BY ar_namespace , ar_title LIMIT 100";
  20.  
  21. **return $dbr->query( $sql, __METHOD__ );
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement