Hello everybody!
I need to automatically create a unique cache key before the query is executed. This key must be the same no matter what you use to get the data:
1) Using "find" method:
$items = \PathTo\Config::find([
            'config_id = 4',
    ]);2) Or using query:
$phql = "SELECT * FROM \PathTo\Config WHERE config_id = :config_id:";
$query = $this->getDI()->get('modelsManager')->createQuery($phql);
$query->setBindParams([
    'config_id' => 4
]);
Dumping $query->getSql() returns different results:
In first case it returns:
SELECT core_config_data.config_id, core_config_data.scope, core_config_data.scope_id, core_config_data.path, core_config_data.value FROM core_config_data WHERE core_config_data.config_id = 4
In case with query it returns:
SELECT core_config_data.config_id, core_config_data.scope, core_config_data.scope_id, core_config_data.path, core_config_data.value FROM core_config_data WHERE core_config_data.config_id = :config_id
And in mysql log file I see the following query in both cases:
SELECT core_config_data.config_id, core_config_data.scope, core_config_data.scope_id, core_config_data.path, core_config_data.value FROM core_config_data WHERE core_config_data.config_id = 4
The question: How can I get a real SQL that is send to MYSQL server without ''= :config_id" etc?