Does using FULLTEXT in MySQL require for me to use a different syntax in php to retrieve the results?

  full-text-search, fulltext-index, mysql, php

Here’s my code:

$terminosBuscados = 'Vender la porteria'

$x = $conectarDB->prepare(" 
    SELECT DISTINCT 
    titulo,
    FROM_UNIXTIME(fecha, '%d-%m-%Y') AS fecha,
    cuerpo,
    tipoContenido,
    autor
    FROM searchIndex 
    WHERE match(titulo) 
    AGAINST (' ? ' IN BOOLEAN MODE)
    ORDER BY contenidoID DESC
    ");
$x->bindParam(1, $terminosBuscados);
$x->execute();
$y = $x->fetchAll(PDO::FETCH_ASSOC);

This is showing no results at all ($y returns null), when trying the query itself in phpMyAdmin does work and show results.

FYI, I’ve ust added a FULLTEXT index into the table and adapted my working code to use that index.

Thanks!

Source: Ask PHP

LEAVE A COMMENT