public function query($sqlStatement, $bindParams = null, $bindTypes = null)
{
/**
* The key is the full sql statement + its parameters
*/
if (is_array($bindParams)) {
$key = \Phalcon\Kernel::preComputeHashKey($sqlStatement . '//' . join('|', $bindParams));
} else {
$key = \Phalcon\Kernel::preComputeHashKey($sqlStatement);
}
/**
* Check if the result is already cached
*/
if ($this->_cache->exists($key)) {
$value = $this->_cache->get($key);
if (!is_null($value)) {
return $value;
}
}
$this->internalConnect();
/**
* Executes the queries
*/
$data = parent::query($sqlStatement, $bindParams, $bindTypes);
if (is_object($data)) {
$result = new Serializable($data);
$this->_cache->save($key, $result);
return $result;
}
$this->_cache->save($key, $data);
return false;
}