コード例 #1
0
 /**
  * Updates the info row.
  *
  * @param InfoModel $info
  *
  * @return bool
  */
 public function saveInfo(InfoModel $info)
 {
     if ($info->validate()) {
         $attributes = $info->getAttributes(null, true);
         if ($this->isInstalled()) {
             craft()->db->createCommand()->update('info', $attributes);
         } else {
             craft()->db->createCommand()->insert('info', $attributes);
             // Set the new id
             $info->id = craft()->db->getLastInsertID();
         }
         // Use this as the new cached InfoModel
         $this->_info = $info;
         return true;
     } else {
         return false;
     }
 }