public function __construct(Model_Db $model) { $otype = strtolower(substr(get_class($model), 6)); $oid = (int) $model->getId(); if ($otype and $oid) { parent::__construct($model->getStorage(), array('object_type' => $otype, 'object_id' => $oid)); } if (!$this->isLoaded()) { $this->otype = $otype; $this->oid = $oid; } }
public function init() { Model_List_Db::setVisibility('visible'); Model_Db::setVisibility('visible'); }
public function __construct() { parent::__construct('t_users', 'localhost_one'); }
public static function setVisibility($value = "visible") { self::$_visibility = $value; }
/** * 查询 * $cache_time = 0不使用缓存 */ public function select($where = array(), $attrs = array(), $cache_time = 0) { $use_cache = $cache_time > 0; $datas = array(); $cacke_key = NULL; if ($use_cache) { ksort($where); ksort($attrs); $cache_key = $this->_conditionToCacheKey($where, $attrs); $datas = $this->_cache->get($cache_key); if (!empty($datas)) { return $datas; } } $datas = parent::select($where, $attrs); if (empty($datas)) { return $datas; } $datas = Helper_Array::changeKey($datas, $this->_primary_id); if ($use_cache) { $this->_cache->set($cache_key, $datas, $cache_time); } return $datas; }
public static function setForceReadOnMaster($bool = TRUE) { Model_Db::$_forceReadOnMaster = $bool; }
public function actionTrashcan($params) { Model_List_Db::setVisibility(''); Model_Db::setVisibility(''); $view = $this->htmlView("list_trashcan"); $trashcan = new Model_Trashcan($this->getStorage()); if ($_POST && isset($_POST['objects'])) { $mode = isset($_POST['restore']) ? 'restore' : (isset($_POST['cleanup']) ? 'cleanup' : ''); if ($mode) { foreach ($_POST['objects'] as $oname => $idlist) { $trashcan->{$mode}($oname, $idlist); } } } $olist = array(); foreach (array('Статьи' => 'Article', 'Разделы' => 'Topic', 'Комментарии' => 'Comment') as $title => $oname) { $list = $trashcan->getList($oname); if (count($list)) { $olist[$title] = $list; } unset($list); } $view->trashcan = $olist; return $view; }