public function execute($cacheOptions = null)
{
self::$_hiddenParamNumber = 0;
$this->_sql = $this->_buildSql();
if ($cacheOptions !== null) {
$_cacheOptions = $this->_getCacheOptions($cacheOptions);
$data = $this->modelsCache->get($_cacheOptions['key']);
if ($data !== false) {
return json_decode($data, true)['rows'];
}
}
try {
$result = $this->modelsManager->getReadConnection(end($this->_models))->fetchAll($this->_sql, $this->_bind);
} catch (\Exception $e) {
throw new QueryBuilderException(':message sql: :sql bind: :bind', ['message' => $e->getMessage(), 'sql' => $this->_sql, 'bind' => json_encode($this->_bind)]);
}
if (isset($_cacheOptions)) {
$this->modelsCache->set($_cacheOptions['key'], json_encode($this->_buildCacheData($result, -1), JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE), $_cacheOptions['ttl']);
}
return $result;
}