2013年3月29日 星期五

XOOPS與getdate()關係

範例

#---------------------------------------------------------------------
$time=xoops_getUserTimestamp(time()); # xoops 使用者時間 

1364583916
#---------------------------------------------------------------------
$today  = getdate($time );  # 格式化日期(xoops 使用者時間) 顯示畫面 
 
Array ( 
[seconds] => 16 
[minutes] => 5 
[hours] => 19 
[mday] => 29 
[wday] => 5 
[mon] => 3 
[year] => 2013 
[yday] => 87 
[weekday] => Friday 
[month] => March 
[0] => 1364583916 ) 
#---------------------------------------------------------------------

$today1 = getdate(); # 格式化日期(主機時間)

Array ( 
[seconds] => 16 
[minutes] => 5 
[hours] => 11 
[mday] => 29 
[wday] => 5 
[mon] => 3 
[year] => 2013 
[yday] => 87 
[weekday] => Friday 
[month] => March 
[0] => 1364555116 ) 

#---------------------------------------------------------------------
$today2 = getdate(userTimeToServerTime($time)); 
# 格式化日期(將xoops 使用者時間,還原成主機時間) 儲存進資料庫

Array ( 
[seconds] => 16 
[minutes] => 5 
[hours] => 11 
[mday] => 29 
[wday] => 5 
[mon] => 3 
[year] => 2013 
[yday] => 87 
[weekday] => Friday 
[month] => March 
[0] => 1364555116 ) 
#---------------------------------------------------------------------

 

2013年3月13日 星期三

取得選定群組的會員名單

取得選定群組的會員名單
foreach ($groups  as $k => $group){
    if($k==0){
      $condition.=" where a.`groupid`='{$group}'";    
    }else{
      $condition.=" or a.`groupid`='{$group}'";
    }
}
$sql = "select a.`uid`,b.`name`,b.`uname`,c.`unit_sn`,d.`name` as group_name,e.`title` from ".$xoopsDB->prefix("groups_users_link")." as a left join ".$xoopsDB->prefix("users")." as b on a.`uid`=b.`uid` left join ".$xoopsDB->prefix("ugm_apply_users")." as c on a.`uid`=c.`uid`  left join ".$xoopsDB->prefix("groups")." as d on a.`groupid`=d.`groupid`  left join ".$xoopsDB->prefix("ugm_apply_unit")." as e on c.`unit_sn`=e.`sn`  {$condition} group by a.`uid` order by a.`uid`";

SQL可以透過關鍵字「distinct」將查詢的資料不重覆顯示

SQL可以透過關鍵字「distinct」將查詢的資料不重覆顯示
select distinct 欄位名 from 表名 where 查詢準則
備註:distinct 必須與 where 子句聯合使用,否則輸出的資料不會有變化
範例:
SELECT DISTINCT a.uid,b.name,b.uname
FROM  `x4df_groups_users_link` as a left join `x4df_users` as b on a.uid=b.uid
WHERE a.groupid =2
OR a.groupid =3

2013年3月10日 星期日

test

//識別名稱(給程式用的)
$modversion['config'][1]['name'] = 'show_num';
//顯示標題
$modversion['config'][1]['title'] = '_MI_NOTE_SHOW_NUM';
//偏好設定的說明
$modversion['config'][1]['description'] = '_MI_NOTE_SHOW_NUM_DSC';
//偏好設定的輸入欄位類型
$modversion['config'][1]['formtype'] = 'select';
//偏好設定的輸入值型態
$modversion['config'][1]['valuetype'] = 'int';
//偏好設定的選項設定
$modversion['config'][1]['options'] = array(5=>5,10=>10,15=>15);
//偏好設定的預設值。
$modversion['config'][1]['default'] = 10;