18-7
                        上課範例:include/onUpdate.php
                    
                
                                
<?php
//若模組的資料結構需更新,那麼可以用此機制(先檢查,後執行):
function xoops_module_update_tad_note(&$module, $old_version) {
  global $xoopsDB;
  if(chk_chk1()) go_update1();
  return true;
}
function chk_chk1(){
  global $xoopsDB;
  $sql="select count(`pic`) from ".$xoopsDB->prefix("tad_note_cate");
  $result=$xoopsDB->query($sql);
  if(empty($result)) return true;
  return false;
}
function go_update1(){
  global $xoopsDB;
  $sql="ALTER TABLE ".$xoopsDB->prefix("tad_note_cate")." ADD `pic` varchar(255) NOT NULL  default ''";
  $xoopsDB->queryF($sql) or redirect_header(XOOPS_URL."/modules/system/admin.php?fct=modulesadmin",30,  mysql_error());
}
?>