After googling I founded that SQL_CALC_FOUND_ROWS
can result the total number of rows available in table before applying limit
.
But I have very complex sql query with php when searching for some text in database and also want to know total available result in database.
SELECT i.name 'title',i.add_time 'time',round(i.price) 'price',round(i.new_price) 'new_price',
s.store_address 'address', s.name 'name'
FROM store_items i,stores s
WHERE i.store_id = s.store_id
AND (i.name like '%samsung glaxy%' AND
i.name like '%samsung%' AND i.name like '%galaxy%'
OR i.name like '%samsung%' OR i.name like '%galaxy%')
ORDER BY
CASE WHEN i.name like '%%'
AND i.name like '%samsung%' AND i.name like '%galaxy%' THEN 1
WHEN i.name like '%samsung%' OR i.name like '%galaxy%' THEN 2
END,
i.price ASC
LIMIT 0,25"
How it can be possible to get total number of available rows by matching the following results.
Is it can be possible by using SQL_CALC_FOUND_ROWS
sql function. or some other way is available in PHP
.