以前应用thinkphp工作时的一些工作总结,以前是写在自己的个人网站上,后来由于个人原因,网站没有了,把资料转到博客上面来
1.Volist的双重嵌套:
$admincolumn=M('admincolumn');
$parent=$admincolumn->where('parent=0')->findAll();
foreach($parent as $n => $val )
{
$parent[$n]['voo']=$admincolumn->where('parent='.$val['id'])->findAll();
}
$plist=$this->assign('plist',$parent);
<volist name="list" id="vo">
<volist name="vo['voo']" id="voo">
{$sub.name}
</volist>
</volist>
2.在thinkphp模板中应用php代码
<php>
foreach( $rights as $val)
{
if($val==$vo['id']){ echo "checked='checked'" ;}
}
</php>
3.对于数组的操作多数用到foreach()这个函数
4.全选与取消的JS代码
function selectAllChkboxs(){
var getChkboxs=document.getElementsByName("id[]");
var getchkbox=document.getElementById("ChkAll");
if(getChkboxs.length==0) return;
getchkbox.value=(getchkbox.value=="全选")? "取消":"全选"
for(var i=0;i<getChkboxs.length;i++)
getChkboxs[i].checked=!getChkboxs[i].checked;
}
5.删除时显示提示框的操作
<a href="__URL__/deletegroup/id/{$vo.id}" οnclick="return confirm('确定要删除吗?')">删除</a>
6. implode --- 将数组的元素连结起来成为字符串
explode --- 切开字符串
$plist=$stolist->where("id in ({$rights})")->findAll();
in
字符串操作
$rights
=explode(
"|"
,
$groupone
[
'rights'
]);
$rights
=implode(
','
,
$rights
);
7.if –else
与三目运算的转换
$right.=($count==$n)?$val:$val.'|';
onClick="vo{$vo['id']}.style.display=(vo{$vo['id']}.style.display=='block')?'none':'block';"
8.ThinkPHP
中表单的提交是通过令牌
__hash__
来提交的一定要把
__hash__
也要提交过来,
$data=$_POST;
就可以把它提交过来,表单自动验证时通过
create
来触发
$m=$admingroup->create($data);
if(false ===$m)
{
$this->error($admingroup->getError());
}
不能写
if(false===$admingroup->create($data))
,不然会出意外的错误或验证不成功。
9.
得到
URL
后面的内容
substr(__ACTION__,strlen(__APP__),strlen(__ACTION__));
substr($_SERVER['REQUEST_URI'],strlen(__APP__),strlen($_SERVER['REQUEST_URI']))
10.
权限的操作可以做一个基类让别人都继承就可以了,用函数可以用返回值的
true
或
false
来判断其的值。
11.
递归函数读取数据库的循环值,
说明:递归函数一定要有返回值才行。如果条件不满足就没有返回值,过程想象;
/*
*
读出所有的
parent
路径
* **/
public function parentname1($parent)
{
$sauthor=D("Storageauthor");
$clist=$sauthor->where("id=$parent")->find();
$cstr.='<--'.$clist['saname'];
if (intval($clist['parent'])>0)
{
$cstr.=$this->parentname($clist['parent']);
}
return $cstr;
}
12. 模板
1. http://www.865171.cn/
2. http://www.tuluo.com/
13.在Thinkphp中看不出问题而有问题时一定要清空缓存,再看看。
14.url的路径编码:$url=urlencode('http://'.$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"]);
15.thinkphp中函数应用的俩种方式
{$vo['content']|msubstr=0,18,'utf-8'}
<if condition="strlen($vo['title']) gt 20 "> ... </if>
16.aswing做flash应用程序的框架
papervision3d是用来做flash3D效果的应用
VizualPV3D 是用来可视化pv3D效果的应用
17.Amfphp( flex 与PHP通信)
http://www.riafan.com/article/flex/flex-builder-2-amfphp.html.html
18
ImageMagick
软件简介
:
ImageMagick 是一个免费的创建、编辑、合成图片的软件。它可以读取、转换、写入多种格式的图片。图片切割、颜色替换、各种效果的应用,图片的旋转、组合,文本,直线,多边形,椭圆,曲线,附加到图片伸展旋转。 ImageMagick 是免费软件:全部源码开放,可以自由使用,复制,修改,发布。它遵守 GPL 许可协议:可自行下载安装
ImageMagick 是一个免费的创建、编辑、合成图片的软件。它可以读取、转换、写入多种格式的图片。图片切割、颜色替换、各种效果的应用,图片的旋转、组合,文本,直线,多边形,椭圆,曲线,附加到图片伸展旋转。 ImageMagick 是免费软件:全部源码开放,可以自由使用,复制,修改,发布。它遵守 GPL 许可协议:可自行下载安装
可以做web图片处理的工具
19.thinkphp编码:header("Content-Type:text/html; charset=utf-8");
20. jQuery 心跳包 定时向服务器发送消息适应聊天器的应用
21.网页日历控件官方网站:http://www.my97.net/dp/index.asp