catfan / Medoo

The lightweight PHP database framework to accelerate the development.
https://medoo.in
MIT License
4.84k stars 1.15k forks source link

Query in MySQL with SQL_CACHE #1040

Closed fernandolcardoso closed 2 years ago

fernandolcardoso commented 2 years ago

Hello everyone, this is my first suggestion for the project, I hope I'm in the right place.

I'm using MySQL and I'm having trouble performing a SELECT query with SQL_CACHE naturally, for example "SELECT SQL_CACHE ..."

I activated the query_cache_type option in MySQL in the 2/demand option and for the cache resources to be used, it is necessary to include SQL_CACHE after the SELECT.

Is there any way to perform this query in Medoo without having to modify the library?

catfan commented 2 years ago

There is no direct way to put SQL_CACHE for the select().

However, you can run this query before the select() to disable the cache.

$database->query("SET SESSION query_cache_type = OFF");
$database->select("table", ["id", "name"]);