Exemplo n.º 1
0
 /**
  * @param string $key
  * @return mixed|null
  * @throws CM_Exception_Invalid
  */
 public function get($key)
 {
     $cacheKey = CM_CacheConst::Option;
     $cache = CM_Cache_Shared::getInstance();
     if (($options = $cache->get($cacheKey)) === false) {
         $query = new CM_Db_Query_Select($this->_getDatabaseClient(), 'cm_option', array('key', 'value'));
         $options = $query->execute()->fetchAllTree();
         $cache->set($cacheKey, $options);
     }
     if (!isset($options[$key])) {
         return null;
     }
     $value = unserialize($options[$key]);
     if (false === $value) {
         throw new CM_Exception_Invalid('Cannot unserialize option.', null, ['key' => $key]);
     }
     return $value;
 }
Exemplo n.º 2
0
 public function testSingleField()
 {
     $query = new CM_Db_Query_Select(self::$_client, 'test', 'foo');
     $this->assertSame('SELECT `foo` FROM `test`', $query->getSqlTemplate());
 }
Exemplo n.º 3
0
 /**
  * @param string            $table
  * @param string|array      $fields Column-name OR Column-names array
  * @param string|array|null $where  Associative array field=>value OR string
  * @param string|null       $order
  * @return CM_Db_Result
  */
 public static function select($table, $fields, $where = null, $order = null)
 {
     $client = self::getClient();
     $query = new CM_Db_Query_Select($client, $table, $fields, $where, $order);
     return $query->execute();
 }