OK, quindi sto cercando di eseguire una ricerca di testo completo sulla mia tabella mysql. Ecco l'interrogazionecorrispondenza php mysql senza risultati
SELECT *,
MATCH (title, joke) AGAINST ('welcome') AS relevance,
MATCH (title) AGAINST ('welcome') AS title_relevance
FROM jokes
WHERE MATCH (title, joke) AGAINST ('welcome')
AND flags < 5
ORDER BY title_relevance + relevance + ups DESC, downs ASC LIMIT 0, 30
e qui è il mio tavolo
CREATE TABLE IF NOT EXISTS `jokes` (
`jid` varchar(24) NOT NULL,
`uid` int(11) NOT NULL,
`title` mediumtext NOT NULL,
`joke` longtext NOT NULL,
`ups` int(11) NOT NULL DEFAULT '0',
`downs` int(11) NOT NULL DEFAULT '0',
`flags` int(11) NOT NULL DEFAULT '0',
`createddate` int(11) NOT NULL,
`editdate` int(11) NOT NULL,
PRIMARY KEY (`jid`),
FULLTEXT KEY `searcher` (`title`,`joke`),
FULLTEXT KEY `title` (`title`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
Ho un paio di righe che contengono sia il benvenuto nel titolo, o la battuta, ma non sembrano avere alcuna risultati. Non importa quale parola cerco.
ho provato anche la rimozione e flags < 5
e anche ups DESC, downs ASC LIMIT 0,30
Entrambi non sembrano funzionare.
Questo è quello che faccio con il codice php
if($st->prepare($SearchQuery))
{
if(!$st->execute())
ChromePhp::log("Execute Error: " . $st->error);
else
{
$results = fetchAll($st);
$ret = new stdClass();
$ret->TotalCount = 0;
$ret->Results = $results;
return $ret;
}
}
e questo è fetchAll (che ha lavorato per ogni altra domanda che ho gettato in esso).
function fetchAll($result)
{
$array = array();
if($result instanceof mysqli_stmt)
{
$result->store_result();
$variables = array();
$data = array();
$meta = $result->result_metadata();
while($field = $meta->fetch_field())
$variables[] = &$data[$field->name]; // pass by reference
call_user_func_array(array($result, 'bind_result'), $variables);
$i=0;
while($result->fetch())
{
$array[$i] = array();
foreach($data as $k=>$v)
$array[$i][$k] = $v;
$i++;
// don't know why, but when I tried $array[] = $data, I got the same one result in all rows
}
}
elseif($result instanceof mysqli_result)
{
while($row = $result->fetch_assoc())
$array[] = $row;
}
return $array;
}
Qualcuno ha qualche idea su cosa sto facendo male qui?
Grazie.
La rimozione delle clausole di ordine ha (quasi mai) intenzione di influenzare la mancanza/presenza di risultati. Quanti dati hai nel database? ricorda che il testo completo prenderà in considerazione ogni parola che appare nel 50% + dei campi come rumore e li ignora. –
Cosa succede quando si esegue la query direttamente sul proprio DB (sans su cui si sta interrogando il codice)? – babonk
Quando eseguo l'SQL direttamente nel mio database (tramite SQL in mysqladmin) non ottengo risultati. Ho solo dire 7 voci nel database. –