在线编辑器的实现,与存储过程再续(select into ,游标,错误处理)

<form action="disp.php" method="post">

<?php

引用FCKeditor.php这个文件,基本的类和数据结构都在这里

include ("fckeditor/fckeditor.php");

创建FCKeditor对象的实例。myFCKeditor即提交后,接收数据页面_POST['myFCKeditor']使用

$FCKeditor = new FCKeditor("content");

FCKeditor所在的位置,这里它的位置就是'FCKeditor'文件夹

$FCKeditor ->BasePath='./fckeditor/';

工具按钮设置

$FCKeditor ->ToolbarSet="Default";

设置它的宽度

$FCKeditor ->Width='500px';

设置它的高度

$FCKeditor ->Height='300px';

生成

$FCKeditor ->Create();

?>

<input type="submit"value="提交">

</form>


1、修改配置文件解决文件上传问题

fckeditor\editor\filemanager\connectors\php\config.php

   1)修改第30行:$Config['Enabled']= true ; 

     2) $Config['UserFilesPath'] =‘/项目名/UserFiles/';


打开editor/filemanager/connectors/php目录下commands.php,找到FileUpload函数,在

  $sExtension =substr($sFileName, ( strrpos($sFileName, '.') + 1 ) ) ;

  $sExtension =strtolower($sExtension ) ;

   后加上一句:

   $sFileName =time().".".$sExtension;

   把文件名重新命名(rename),以取得的毫秒数作为文件名使用


第二种:在线编辑器的使用ewebediter

1、eWebeditor的使用

在form中加入内容:

<formaction="result.php" method="post">

<inputtype="hidden" name="content1" value="">   必须要写一个隐藏表单 name的名字与id的名字相同

<iframeid="eWebEditor1"src="./editor/ewebeditor.htm?id=content1&style=standard600&skin=office2003"frameborder="0" scrolling="no" width="600"height="350"></iframe>

<inputtype="submit" value="提交" />

</form>

Src 主要是指定编辑器文件所在的目录文件






游标:指针

1、  select。。。into

注意:into 关键字后的变量要求先声明;

      只能出现在存储过程和触发器,不能单独使用;

      字段(数量、类型)要和变量一致;

      只能针对一行;

      返回标量值;

 

练习1:针对db1中的tb1;

      把一个字段的内容保存到变量,显示该变量;

Delimiter //

Createprocedure p1(out a char(20))

    Begin

           Select 字段 into a from 表名;

    End//

Delimiter ;

     搜索的结果集为多条,移动指针

     步骤:

           创建游标;declare 游标名 cursor(关键字) for  sql语句

           select  ….   From  ….  Where …;------不能有into关键字

           打开游标;open  游标

           获取记录;fetch 游标 into 参数

           关闭游标; close 游标

        注意:声明完成后并不执行;

        open  游标名称;

        fetch  游标名称 into  变量;

        close  游标名称;

      练习2:针对练习1

              流程控制语句 while

  循环次数无法确定, 异常提示

       用异常错误作为循环的结束条件(在不知道有多少个字段的时候用)

Delimiter //

       CreateProcedure p1(out p int)

       Begin

              Declarea Boolean default true  //声明变量a作为结束的条件

              Declare c cursor for select ziduan from biao1;  //声明游标

             Declare exit(continue) handle for not foundset a=false;  //声明一个错误的信息exit表示执行完退出程序,continue表示继续向下执行

       Openc;

       Whilea do

       Fetch c into para1;

       Endwhile;

       Closec;

       End//

Delimiter //

 

注意:1)callp1(@x); 要用@;

2)最后的@x返回的是最后一个值,前面的值会被覆盖

 

 

 

异常代码:

SQLSTATE代码

Error 1022  XXXXXXXXXXX

Error 1048

Error 1052

Error 1062

 

内置异常描述

   Declare exit      handler  for SQLSTATE 信息执行的动作;

   Declare continue  handler  for SQLSTATE 信息执行的动作;

注意:

1、  执行顺序(声明位置无要求,建议在开头,当错误出现的时候被执行,如果

是exit类型的将终止整个存储过程的执行;如果是continue类型的则从错误

出现的位置继续)






  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值