Exemple #1
0
 /**
  * The queries executed are stored in the cache
  *
  * @param string $sqlStatement
  * @param array $bindParams
  * @param array $bindTypes
  * @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->_connect();
     /**
      * 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;
 }
Exemple #2
0
 /**
  * Return array of supported platform settings for optimized builds
  *
  * @param string $output32Dir
  * @param string $output64Dir
  * @return array
  */
 protected function getPlatformsSettings($output32Dir, $output64Dir)
 {
     return array('32bit' => array('dir' => $output32Dir, 'hashFunc' => function ($string) {
         return Kernel::preComputeHashKey32($string) . 'UL';
     }), '64bit' => array('dir' => $output64Dir, 'hashFunc' => function ($string) {
         return Kernel::preComputeHashKey64($string) . 'UL';
     }));
 }