易截截图软件、单文件、免安装、纯绿色、仅160KB

PHP与MYSQL的存储过程

实例一:无参的存储过程
$conn = mysql_connect('localhost','root','root') or die ("数据连接错误!!!");
mysql_select_db('test',$conn);
$sql = "
create procedure myproce()
begin
INSERT INTO user (id, username, sex) VALUES (NULL, 's', '0');
end;
";
mysql_query($sql);//创建一个myproce的存储过程
$sql = "call test.myproce();";
mysql_query($sql);//调用myproce的存储过程,则数据库中将增加一条新记录。
实例二:传入参数的存储过程
$sql = "
create procedure myproce2(in score int)
begin
if score >= 60 then
select 'pass';
else
select 'no';
end if;
end;
";
mysql_query($sql);//创建一个myproce2的存储过程
$sql = "call test.myproce2(70);";
mysql_query($sql);//调用myproce2的存储过程,看不到效果,可以在cmd下看到结果。
实例三:传出参数的存储过程
$sql = "
create procedure myproce3(out score int)
begin
set score=100;
end;
";
mysql_query($sql);//创建一个myproce3的存储过程
$sql = "call test.myproce3(@score);";
mysql_query($sql);//调用myproce3的存储过程
$result = mysql_query('select @score;');
$array = mysql_fetch_array($result);
echo '<pre>';print_r($array);
实例四:传出参数的inout存储过程
$sql = "
create procedure myproce4(inout sexflag int)
begin
SELECT * from user WHERE sex = sexflag;
end;
";
mysql_query($sql);//创建一个myproce4的存储过程
$sql = "set @sexflag = 1";
mysql_query($sql);//设置性别参数为1
$sql = "call test.myproce4(@sexflag);";
mysql_query($sql);//调用myproce4的存储过程,在cmd下面看效果
实例五:使用变量的存储过程
$sql = "
create procedure myproce5(in a int,in b int)
begin
declare s int default 0;
set s=a+b;
select s;
end;
";
mysql_query($sql);//创建一个myproce5的存储过程
$sql = "call test.myproce5(4,6);";
mysql_query($sql);//调用myproce5的存储过程,在cmd下面看效果
实例六:case语法
$sql = "
create procedure myproce6(in score int)
begin
case score
when 60 then select '及格';
when 80 then select '及良好';
when 100 then select '优秀';
else select '未知分数';
end case;
end;
";
mysql_query($sql);//创建


相关文档:

XP下Apache php mysql phpmyAdmin的安装与配置

初学php,需要搭建其开发环境。由于版本更替等原因,网上的方法几乎一人一个样,让人无所适从。昨天花了一晚上时间才在XP下配置好,现将其整理出来,希望能对别人有用。(2007-11-21)
 
一、 下载软件。
1. 下载apache_2.0.55-win32-x86-no_ssl.msi,右键用迅雷点击此处下载(直接点击不行)。
2. 下载php-5 ......

apache 和php 安装配置

先安装apache http server   一路next;
再安装php,注意选择 Apache 2.2.x Module;
安装结束以后,还需要修改 Apache 的配置文件。文件路径为
C:\Program Files\Apache
Software Foundation\Apache2.2\conf\httpd.conf。
用 Notepad 打开
httpd.conf,在文件最后有以 #BEGIN PHP INSTALLER EDITS - RE ......

PHP与ASP.NET比较的浅析 南三方


 
PHP与ASP.NET比较的各个方面是什么呢?PHP与ASP.NET比较的必要性是什么呢?那么本文就给你一个答案。
PHP与ASP.NET比较的前言,不管你是不是已经选择了PHP,根据它在如下表格中在价格、速度、效率、安全性、平台支持性和开源与否上的表现,我们都能判断出它的强项是远胜于弱点的。唯一不足的是缺少面向对象的支 ......

php程序提速原理分析 南三方

缓冲层级别的优化
xCache是把 PHP 操作码缓存到内存中的 PHP 扩展中,XCache 将避免代价高昂且不必要的花费来重新编译相同的 PHP 代码去交付一个页面,这一点上和Accelerator有点相似,我一直认为他们的机理是一样的,不过xCahce是开源产品[opensource].
Zend Accelerator 站在解析和执行的中间,当页面第一次被请求时,Z ......

用 SWIG 构建 PHP 扩展 南三方

作者:Martin Streicher, 软件开发人员, Pixel, Byte, and Comma
尽管编写一个 PHP 扩展并不是很困难,而 SWIG 的确进一步简化了这项任务,这主要是因为它自动化了结合 PHP 与 C 或 C++ 所需的工作。若给定对一个函数的描绘 — 函数的名称及其形参 — SWIG 就会生成一个包装程序来将 PHP 与低层代码连接起来。 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号