Welcome Guest, Not a member yet? Register   Sign In
Different results in match against fulltext search
#1

[eluser]Dannymx[/eluser]
Well, the problem is that I'm getting different results when changing the AGAINST parameter.

When I use a word as the parameter I get the correct result I want, but when I use a variable that contains that word I get nothing.

Code that works as expected:

Code:
$this->db->select('titulo, autor, editorial, id');
$this->db->where('MATCH (titulo, autor, editorial) AGAINST ("dummies" IN BOOLEAN MODE)', NULL, FALSE);
$busqueda_libros = $this->db->get('libros');

And I get nothing when doing this:

Code:
$titulo = 'dummies';

this->db->select('titulo, autor, editorial, id');
$this->db->where('MATCH (titulo, autor, editorial) AGAINST ("$titulo" IN BOOLEAN MODE)', NULL, FALSE);
$busqueda_libros = $this->db->get('libros');

As you can see the only change was the AGAINST parameter now using a variable.
The fields are already set in fulltext.

Maybe I am missing something, but I tried almost everything.

Edit: Also I want to know if is possible to use more than one parameter in AGAINST, like 2 or 3 variables.
#2

[eluser]Dannymx[/eluser]
Well, never mind I guess I just found the solution, it actually works as I wanted, but I'm not sure if it is how it's supposed to be done so here's my solution:

I just added this when searching with one variable:
Code:
AGAINST ("'.$titulo.'" IN BOOLEAN MODE)

And with more than one:
Code:
AGAINST ("'.$titulo.' '.$titulo2.'" IN BOOLEAN MODE)


I would appreciate any advice.




Theme © iAndrew 2016 - Forum software by © MyBB