/** * @param $brokerId * @return $this|boolh */ public static function resetBrokerCustomerCount($brokerId) { try { return Model_Mobile_BrokerUserRelationNewNum::data_access()->filter('brokerId', $brokerId)->set_field('num', 0)->update(); } catch (Exception $e) { return false; } }
public function insert_update_num($broker_id) { $broker = Model_Mobile_BrokerUserRelationNewNum::data_access()->filter('brokerId', $broker_id)->find_only(); if (empty($broker)) { $num_temp = Model_Mobile_BrokerUserRelationNewNum::create(array('brokerId' => $broker_id, 'num' => 1)); $num_temp->save(); } else { $today_num_str = file_exists($this->temp_today_file) ? file_get_contents($this->temp_today_file) : ''; $yes_num_str = file_exists($this->temp_yesday_file) ? file_get_contents($this->temp_yesday_file) : ''; $today_num = json_decode($today_num_str, true); $yse_num = json_decode($yes_num_str, true); $broker->num = intval($today_num[$broker_id]) + intval($yse_num[$broker_id]); $broker->save(); } }