public static final function getCachedFields($tbl_pkval, $fields = '*') { $tbl = static::TBL; $tbl_pk = static::TBL_PK; $cache_rs = null; if (strlen($tbl) && strlen($tbl_pk)) { $field = $fields == '*' ? 'all' : $fields; $cache_ky = "{$tbl}_{$tbl_pkval}_{$field}"; $cache_rs = CacheHandler::get($cache_ky); if ($cache_rs == null) { $cache_rs = self::findFirst(array('columns' => $fields, 'conditions' => "{$tbl_pk} = ?1", 'bind' => array(1 => $tbl_pkval))); CacheHandler::create($cache_ky, $cache_rs); } } return $cache_rs; }
public function me($params) { //removing white spaces if any $params = array_map('trim', $params); if (isset($params['pzt_member_id'])) { $member_obj = EntityMember::findFirst($params['pzt_member_id']); if (is_object($member_obj) && property_exists($member_obj, 'pzt_member_id')) { return $member_obj; } } else { if (isset($params['app_token']) && strlen($params['app_token']) > 0 && isset($params['member_token']) && strlen($params['member_token']) > 0) { $cache_key = $params['app_token'] . ":" . $params['member_token']; $cached_result = CacheHandler::get($cache_key); if ($cached_result != null) { return $cached_result; } else { $app_token_obj = EntitySysAppToken::findFirst(array('columns' => '*', 'conditions' => 'app_token = ?1 AND status = 1', 'bind' => array(1 => $params['app_token']))); if (is_object($app_token_obj)) { $pzt_sys_app_id = $app_token_obj->PztSysApp->pzt_sys_app_id; $member_token_obj = EntityMemberToken::findFirst(array('columns' => '*', 'conditions' => 'member_token = ?1 AND pzt_sys_app_id = ?2 AND status = 1', 'bind' => array(1 => $params['member_token'], 2 => $pzt_sys_app_id))); if (is_object($member_token_obj)) { CacheHandler::create($cache_key, $member_token_obj->PztMember); return $member_token_obj->PztMember; } } } } } return null; }