示例#1
0
 public function save()
 {
     $db = Zend_Registry::get('db');
     $config = Zend_Registry::get('config');
     $mapper = new SxModule_Sheets_Type_Mapper();
     $typeData = $mapper->toArray($this, 'item');
     $typeTsl = $mapper->toArray($this, 'tsl');
     if ($this->getId() == 0) {
         $db->insert('SheetsType', $typeData);
         $type_id = $db->lastInsertId();
         foreach ($config->system->language as $lng => $slng) {
             $typeTsl['lng'] = $lng;
             $typeTsl['type_id'] = $type_id;
             $db->insert('SheetsTypeTsl', $typeTsl);
         }
     } else {
         $type_id = $this->getId();
         $db->update('SheetsType', $typeData, 'type_id = ' . $type_id);
         $db->update('SheetsTypeTsl', $typeTsl, 'type_id = ' . $type_id . ' AND lng = \'' . $this->getLng() . '\'');
     }
     return $this;
 }