Пример #1
0
 /**
  * 重载save方法,为了增加modId
  * @param array $data
  * @return int
  */
 public function save($data = array())
 {
     //默认对经纪人mod 100
     if (isset($this->brokerId)) {
         $this->modId = $this->brokerId % 100;
     } elseif (isset($data['brokerId'])) {
         $this->modId = $data['brokerId'] % 100;
     }
     $temp = array();
     foreach ($this->properties() as $property) {
         if (!is_null($this->{$property})) {
             $temp[$property] = $this->{$property};
         }
     }
     $log = '';
     try {
         if (1 == parent::save($data)) {
             $temp['id'] = $this->id;
             Model_Log_HouseLogNew::doubleWrite(array_merge($temp, $data), $this->splitSuffix);
             return 1;
         }
     } catch (Exception $e) {
         $log = $e->getTraceAsString();
     }
     $logFile = sprintf('/data1/logs/Model_Log_HouseLog-%d.log', $this->splitSuffix);
     @file_put_contents($logFile, sprintf('[%s] %s %s' . PHP_EOL, date('Y-m-d H:i:s'), __CLASS__, json_encode($temp)), FILE_APPEND);
     if ($log != '') {
         @file_put_contents($logFile, sprintf('[%s] %s %s' . PHP_EOL, date('Y-m-d H:i:s'), __CLASS__, $log), FILE_APPEND);
     }
     return 0;
 }