par
Fredy07 » 19 août 2009, 07:24
J'ai utlise cette requete:
$word = 'php'; // fonction
$query = "SELECT * FROM recherche1 WHERE MATCH (titre,texte) AGAINST ('$word') UNION SELECT * FROM recherche2 WHERE MATCH (titre,texte) AGAINST ('$word')";
si je cherche php, le resultat est aucun resultat, mais avec fonction comme mot clef, il me donne des resultats, voila la structure des tables:
CREATE TABLE IF NOT EXISTS `recherche1` (
`id` int(2) NOT NULL auto_increment,
`titre` varchar(20) collate latin1_general_ci NOT NULL,
`texte` longtext collate latin1_general_ci NOT NULL,
`url` varchar(30) collate latin1_general_ci NOT NULL,
PRIMARY KEY (`id`),
FULLTEXT KEY `texte` (`titre`,`texte`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=4 ;# MySQL returned an empty result set (i.e. zero rows).
INSERT INTO `recherche1` (`id`, `titre`, `texte`, `url`) VALUES
(1, 'titre 1 de recherche', 'c''est la premiere fois que je code du php', 'code.php'),
(2, 'titre 2 recherche 1', 'j''adore coder du php', 'code1.php'),
(3, 'fonction php', 'fonction', 'code.php');# Affected rows: 3
CREATE TABLE IF NOT EXISTS `recherche2` (
`id` int(2) NOT NULL auto_increment,
`titre` varchar(20) collate latin1_general_ci NOT NULL,
`texte` longtext collate latin1_general_ci NOT NULL,
`url` varchar(30) collate latin1_general_ci NOT NULL,
PRIMARY KEY (`id`),
FULLTEXT KEY `texte` (`titre`,`texte`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=4 ;# MySQL returned an empty result set (i.e. zero rows).
INSERT INTO `recherche2` (`id`, `titre`, `texte`, `url`) VALUES
(1, 'titre 1 de recherche', 'c''est la premiere fois que je code du php', 'code.php'),
(2, 'titre 2 recherche2', 'j''adore coder du php', 'code1.php'),
(3, 'fonction php', 'fonction', 'code.php');# Affected rows: 3
J'ai utlise cette requete:
[php]
$word = 'php'; // fonction
$query = "SELECT * FROM recherche1 WHERE MATCH (titre,texte) AGAINST ('$word') UNION SELECT * FROM recherche2 WHERE MATCH (titre,texte) AGAINST ('$word')";
[/php]
si je cherche php, le resultat est aucun resultat, mais avec fonction comme mot clef, il me donne des resultats, voila la structure des tables:
[php]CREATE TABLE IF NOT EXISTS `recherche1` (
`id` int(2) NOT NULL auto_increment,
`titre` varchar(20) collate latin1_general_ci NOT NULL,
`texte` longtext collate latin1_general_ci NOT NULL,
`url` varchar(30) collate latin1_general_ci NOT NULL,
PRIMARY KEY (`id`),
FULLTEXT KEY `texte` (`titre`,`texte`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=4 ;# MySQL returned an empty result set (i.e. zero rows).
INSERT INTO `recherche1` (`id`, `titre`, `texte`, `url`) VALUES
(1, 'titre 1 de recherche', 'c''est la premiere fois que je code du php', 'code.php'),
(2, 'titre 2 recherche 1', 'j''adore coder du php', 'code1.php'),
(3, 'fonction php', 'fonction', 'code.php');# Affected rows: 3
CREATE TABLE IF NOT EXISTS `recherche2` (
`id` int(2) NOT NULL auto_increment,
`titre` varchar(20) collate latin1_general_ci NOT NULL,
`texte` longtext collate latin1_general_ci NOT NULL,
`url` varchar(30) collate latin1_general_ci NOT NULL,
PRIMARY KEY (`id`),
FULLTEXT KEY `texte` (`titre`,`texte`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=4 ;# MySQL returned an empty result set (i.e. zero rows).
INSERT INTO `recherche2` (`id`, `titre`, `texte`, `url`) VALUES
(1, 'titre 1 de recherche', 'c''est la premiere fois que je code du php', 'code.php'),
(2, 'titre 2 recherche2', 'j''adore coder du php', 'code1.php'),
(3, 'fonction php', 'fonction', 'code.php');# Affected rows: 3
[/php]