mediawikimediawiki-apimediawiki-extensionsmediawiki-templates

How to use "WHERE column LIKE" sql query in core MediaWiki


I have just started developing and modifying extensions. Currently, I'm modifying an extension in which I have to show matching page results with the searched term entered by the user.

Here I'm using the default ORM thing provided by the Mediawiki. In the documentation provided by MediaWiki they have mentioned all sorts of querying but not how exactly specified how to use the "WHERE column LIKE" query.

Currently My query looks like this.

        $pages = $dbr->newSelectQueryBuilder()
        ->select( ['_pageName'] )       
        ->where( ['_pageName' => "$term"] ) 
        ->limit( 15 )
        ->from( 'my_table' )
        ->fetchResultSet();

This is a query for the WHERE clause only. Just wanted to know how to query with LIKE.


Solution

  • ->where( "_pageName LIKE '%$term%'" ). You can pass conditions as strings to the where method.