1、在直接操作了数据库字段更新后,由于某些变量是被缓存的,所以页面上不会当即展示最新的数据,如需立即展示可更新缓存,比如要更新用户组相关的数据,可在代码中加入
loadcache('usergroups');
2、把形如 2012-12-03 17:40:00 这样格式的时间转化为Unix时间戳
strtotime($_GET['dateline']);
把时间戳转化为格式化日期
$l['dateline'] = dgmdate($l['dateline']); $date = dgmdate($_G[timestamp],'u');
301跳转
showmessage('301跳转', 'yoururl', array(), array('header' => true));
3、把一个php数组转字符串
$biuuu = array('b','i','u','u','u'); print_r(implode('',$biuuu));
4、字符串编码转换
$keywordGbk = iconv( "UTF-8", "gbk" , $keyword);
5、添加关联链接(这个功能太强大了)
if(!$_G['setting']['relatedlinkstatus']) { $_G['relatedlinks'] = get_related_link('article'); } else { $content['content'] = parse_related_link($content['content'], 'article'); }
6、加载ucenter功能
loaducenter();
7、cookies的使用
//设置cookies dsetcookie($var, $value = '', $life = 0, $prefix = 1, $httponly = false); //获取cookies getcookie($key);
8、常用的SQL语句
$thread = DB::fetch_first("SELECT qxzy,pcdm FROM ".DB::table('zytb_360')." WHERE 1 AND tid = '$tid' ");
$list = array(); $query = DB::query("SELECT id,yxmc,desc1,yxdh,sscs,pxf,gjdm FROM ".DB::table('zytb_quanguo_xkx_2012')." WHERE 1 "); while($l = DB::fetch($query)){ $list[] = $l; }
//总数获取 $count = DB::result_first("SELECT count(id) FROM ".DB::table('tebale1')." WHERE 1 ");
DB::query("INSERT INTO ".DB::table('zytb_order')." (orderid, payment, money, uid, status, createdateline,completedateline,goodid,type) VALUES ('$orderid','$payment','$money','$_G[uid]', '$status', '$_G[timestamp]', '','$tid','$type')"); $id = DB::insert_id();
DB::query("UPDATE ".DB::table('zytb_360')." SET realname = '$realname', school = '$school', gender = '$gender', kldm = '$kldm', pcdm = '$pcdm', zfs = '$zfs', dateline = '".TIMESTAMP."' WHERE tid = '$tid' ");
DB::delete('zs_meng_report', array('id' => $id,'type' => $type));//删除
//post if(submitcheck('submit')) { $message = cutstr(dhtmlspecialchars(stripslashes($_POST['message'])), 150, ''); //截取150个字节的内容 DB::query("INSERT INTO ".DB::table('mood_wall')." (uid, username, dateline, message) VALUES ('$_G[uid]', '$_G[username]', '".TIMESTAMP."', '".daddslashes($message)."')"); showmessage('发表成功。', 'mood.php?mod=list'); } //{FORMHASH}
9、include
require libfile('post/albumphoto', 'include'); //对应的路径为:/source/include/post/post_albumphoto.php
10、memcache的使用
$allow = memory('check');//看memcache是否可用 if($allow == 'memcache'){ $str = memory('get', 'abc'); if(empty($str)){ //some codes //写入 $ret = memory('set', 'abc', $aa, $ttl);//$ttl 默认为0,可设置最长的失效时间为30天,即2592000秒 }else{ $xxx = $str;//直接取来用 } } //其它操作方法 memory('rm', 'abc');//删除