/** * 设置缓存,公共的字典缓存是大家共享的,比如:老人类型,,私有的缓存是各自单独存放,比如职工信息 * 再调用字典表的时候一定要注意,不要调用到getListFields方法,否则如果两个Model相互 valChange 引用,则会导致镶嵌引用,死循环。 * */ protected function setCacheDictTableData() { //dump($this->getModelInfo("dictType"));exit; if ($this->getModelInfo("dictType") == "mySelf") { $userId = intval(session(C("USER_AUTH_KEY"))); } else { $userId = 0; } $dictConfig = $this->getModelInfo("dictTable"); // dump($dictConfig);exit; if (!empty($dictConfig)) { if (is_array($dictConfig)) { $dictConfig = implode(",", $dictConfig); } //兼容老格式 //dump(implode(",",$dictConfig));die; if (sizeof(explode(",", $dictConfig)) < 2) { $dictConfig = $this->getPk() . "," . $dictConfig; } //使用主键作为key //---------------------------- //dump($dictConfig);exit; //'role_id,name' $tV = $this->field($dictConfig)->select(); // echo $this->getLastSql();die; // dump($tV);exit; if ($tV) { //dump($tV);exit; $this->cacheDictDatas = DxFunction::arrayToArray($tV); } return F('_fields/' . $this->name . "_" . $userId . "_dict", $this->cacheDictDatas); } return 0; }