Ejemplo n.º 1
0
 public static function get_instance($type = 'function')
 {
     if (self::$instances == null) {
         self::$instances = array();
     }
     if (empty(self::$instances[$type])) {
         self::$instances[$type] = new SilkCache($type);
     }
     return self::$instances[$type];
 }
 /**
  * Generates an array of column names in the table that perists this class.  This
  * list is then cached during the life of the request.
  *
  * @return array An array of column names
  */
 function get_columns_in_table()
 {
     return SilkCache::get_instance()->call(array(&$this, '_get_columns_in_table'), $this->get_table());
 }
Ejemplo n.º 3
0
 /**
  * Sets the given site perference with the given value.
  *
  * @since 0.6
  */
 public static function set_preference($prefname, $value)
 {
     $doinsert = true;
     $db = db();
     $query = "SELECT sitepref_value from " . db_prefix() . "siteprefs WHERE sitepref_name = " . $db->qstr($prefname);
     $result = $db->Execute($query);
     if ($result && $result->RecordCount() > 0) {
         $doinsert = false;
     }
     if ($result) {
         $result->Close();
     }
     if ($doinsert) {
         $query = "INSERT INTO " . db_prefix() . "siteprefs (sitepref_name, sitepref_value) VALUES (" . $db->qstr($prefname) . ", " . $db->qstr($value) . ")";
         $db->Execute($query);
     } else {
         $query = "UPDATE " . db_prefix() . "siteprefs SET sitepref_value = " . $db->qstr($value) . " WHERE sitepref_name = " . $db->qstr($prefname);
         $db->Execute($query);
     }
     self::$siteprefs[$prefname] = $value;
     SilkCache::clear();
 }