I have a mysql query like below
SELECT count(id) as total,
MIN(product_price) as min_price,
MAX(product_price) as max_price
FROM `products_details`
WHERE subcat_id = 425
AND MATCH(alternate_name, product_desc, keywords) AGAINST ('+gas +(>lighter <lighters)' IN BOOLEAN MODE)
This query should be return count value as 7 as per the table records.
But when I executing this query using php in my website it is returning the count value as 59.
When I ran this query directly to phpmyadmin I'm getting correct result.
Can anyone tell why I'm getting this kind of problem and how can I solve this.
Note: When I changed this query like below in when I was ran in phpmyadmin I'm getting the wrong result 59.
SELECT count(id) as total,
MIN(product_price) as min_price,
MAX(product_price) as max_price
FROM `products_details`
WHERE subcat_id = 425
AND MATCH(alternate_name, product_desc, keywords) AGAINST ('+gas +(>lighter <lighters)' IN BOOLEAN MODE)
The method of executing this query using php like below
if (!isset($connection))
die('Database connection is not valid');
$result = @mysql_query($sql, $connection) or die('Could not connect: ' . mysql_error() . ' :: executeQuery');
if (!$result)
return;
if (!@mysql_num_fields($result))
return false;
else {
$result = $result;
}
if (!isset($result))
die('Error in Query');
else {
$ret = null;
if ($object = mysql_fetch_object($result)) {
$ret = $object;
}
mysql_free_result($result);
return $ret;
}