|
Posted by NC on 01/09/08 19:28
On Jan 9, 8:49 am, michalk...@o2.pl wrote:
>
> The portal runs on apache/php/mysql. Php generates a query, and the
> result returned is from a cache, not from the actual mysql db. The
> data I receive is not up-to-date - to changes I make during this
> time.
> I have tried using mysql_unbuffered_query, but doesn't help.
> I have finally come to the solution. At the end of list of fields
> following SELECT statement, I entered rand() function which causes
> that every query is different from the previous...
> Looks like this: SELECT field1,field2,...,rand() FROM ...
>
> But this solution is ugly and very unproffesional.
> Do you have any better idea?
> How to stop php/apache from buffering/caching mysql query results?
Query caching is a MySQL-level setting; PHP and Apache have nothing to
do with it.
You have two options. One is to stop query caching entirely by
setting query_cache_type = 0 or query_cache_type = OFF in MySQL's
configuration file:
http://dev.mysql.com/doc/refman/4.1/en/server-system-variables.html#option_mysqld_query_cache_type
If you have no access to MySQL's configuration file, you can add a
SQL_NO_CACHE clause to your queries to request that MySQL run the
query rather than return a cached result:
SELECT SQL_NO_CACHE * FROM myTable;
See MySQL documentation:
http://dev.mysql.com/doc/refman/4.1/en/select.html
Cheers,
NC
[Back to original message]
|