Phalcon\Db\Adapter\Cacheable\Mysql::query PHP Method

query() public method

The queries executed are stored in the cache
public query ( string $sqlStatement, array $bindParams = null, array $bindTypes = null ) : Serializable
$sqlStatement string
$bindParams array
$bindTypes array
return Phalcon\Db\Result\Serializable
    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;
    }