用php来对MySQL存储过程进行调用

WBOY
풀어 주다: 2016-06-07 16:13:31
원래의
825명이 탐색했습니다.

以下的文章主要介绍的是如何用php来对MySQL存储过程进行调用,我前几天在一个可信度特别好的网站看见关于php来对MySQL存储过程进行调用的资料,觉得挺好,就拿出来供大家分享。 498)this.width=498;' onmousewheel = 'javascript:return big(this)' alt="php

以下的文章主要介绍的是如何用php来对MySQL存储过程进行调用,我前几天在一个可信度特别好的网站看见关于php来对MySQL存储过程进行调用的资料,觉得挺好,就拿出来供大家分享。
 

php调用MySQL存储过程

<ol class="dp-xml">
<li class="alt"><span><span>nbsp;html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"</span><span class="tag">></span><span> </span></span></li>
<li><span class="tag"><span class="tag-name">html</span><span> </span><span class="attribute">xmlns</span><span>=</span><span class="attribute-value">"http://www.w3.org/1999/xhtml"</span><span class="tag">></span><span> </span></span></li>
<li class="alt"><span class="tag"><span class="tag-name">head</span><span class="tag">></span><span> </span></span></li>
<li><span class="tag"><span class="tag-name">meta</span><span> </span><span class="attribute">http-equiv</span><span>=</span><span class="attribute-value">"Content-Type"</span><span> </span><span class="attribute">content</span><span>=</span><span class="attribute-value">"text/html; charset=gb2312"</span><span> </span><span class="tag">/></span><span> </span></span></li>
<li class="alt"><span class="tag"><span class="tag-name">title</span><span class="tag">></span><span>无标题文档</span><span class="tag"></span><span class="tag-name">title</span><span class="tag">></span><span> </span></span></li>
<li>
<span class="tag"></span><span class="tag-name">head</span><span class="tag">></span><span> </span>
</li>
<li class="alt"><span class="tag"><span class="tag-name">body</span><span class="tag">></span><span> </span></span></li>
<li><span class="tag"><span class="tag-name">table</span><span> </span><span class="attribute">align</span><span>=</span><span class="attribute-value">"center"</span><span> </span><span class="attribute">border</span><span>=</span><span class="attribute-value">1</span><span class="tag">></span><span> </span></span></li>
<li class="alt"><span class="tag"><span class="tag-name">caption</span><span class="tag">></span><span class="tag"><span class="tag-name">h3</span><span class="tag">></span><span>用户管理</span><span class="tag"></span><span class="tag-name">h3</span><span class="tag">></span><span class="tag"></span><span class="tag-name">caption</span><span class="tag">></span><span> </span></span></span></li>
<li><span class="tag"><span class="tag-name">tr</span><span> </span><span class="tag">></span><span> </span></span></li>
<li class="alt"><span class="tag"><span class="tag-name">td</span><span> </span><span class="attribute">align</span><span>=</span><span class="attribute-value">"center"</span><span> </span><span class="attribute">colspan</span><span>=</span><span class="attribute-value">"7"</span><span class="tag">></span><span> </span></span></li>
<li><span class="tag"><span class="tag-name">a</span><span> </span><span class="attribute">href</span><span>=</span><span class="attribute-value">"adduser.html"</span><span class="tag">></span><span>添加记录</span><span class="tag"></span><span class="tag-name">a</span><span class="tag">></span><span> </span></span></li>
<li class="alt">
<span class="tag"></span><span class="tag-name">td</span><span class="tag">></span><span> </span>
</li>
<li>
<span class="tag"></span><span class="tag-name">tr</span><span class="tag">></span><span> </span>
</li>
<li class="alt"><span class="tag"><span class="tag-name">tr</span><span class="tag">></span><span> </span></span></li>
<li><span class="tag"><span class="tag-name">td</span><span> </span><span class="attribute">align</span><span>=</span><span class="attribute-value">"center"</span><span class="tag">></span><span class="tag"><span class="tag-name">font</span><span> </span><span class="attribute">style</span><span>=</span><span class="attribute-value">"FONT-WEIGHT: bold; FONT-SIZE: 12px; FONT-FAMILY: 黑体"</span><span class="tag">></span><span>姓名</span><span class="tag"></span><span class="tag-name">font</span><span class="tag">></span><span class="tag"></span><span class="tag-name">td</span><span class="tag">></span><span> </span></span></span></li>
<li class="alt"><span class="tag"><span class="tag-name">td</span><span> </span><span class="attribute">align</span><span>=</span><span class="attribute-value">"center"</span><span class="tag">></span><span class="tag"><span class="tag-name">font</span><span> </span><span class="attribute">style</span><span>=</span><span class="attribute-value">"FONT-WEIGHT: bold; FONT-SIZE: 12px; FONT-FAMILY: 黑体"</span><span class="tag">></span><span>性别</span><span class="tag"></span><span class="tag-name">font</span><span class="tag">></span><span class="tag"></span><span class="tag-name">td</span><span class="tag">></span><span> </span></span></span></li>
<li><span class="tag"><span class="tag-name">td</span><span> </span><span class="attribute">align</span><span>=</span><span class="attribute-value">"center"</span><span class="tag">></span><span class="tag"><span class="tag-name">font</span><span> </span><span class="attribute">style</span><span>=</span><span class="attribute-value">"FONT-WEIGHT: bold; FONT-SIZE: 12px; FONT-FAMILY: 黑体"</span><span class="tag">></span><span>年龄</span><span class="tag"></span><span class="tag-name">font</span><span class="tag">></span><span class="tag"></span><span class="tag-name">td</span><span class="tag">></span><span> </span></span></span></li>
<li class="alt"><span class="tag"><span class="tag-name">td</span><span> </span><span class="attribute">align</span><span>=</span><span class="attribute-value">"center"</span><span class="tag">></span><span class="tag"><span class="tag-name">font</span><span> </span><span class="attribute">style</span><span>=</span><span class="attribute-value">"FONT-WEIGHT: bold; FONT-SIZE: 12px; FONT-FAMILY: 黑体"</span><span class="tag">></span><span>电话</span><span class="tag"></span><span class="tag-name">font</span><span class="tag">></span><span class="tag"></span><span class="tag-name">td</span><span class="tag">></span><span> </span></span></span></li>
<li><span class="tag"><span class="tag-name">td</span><span> </span><span class="attribute">align</span><span>=</span><span class="attribute-value">"center"</span><span class="tag">></span><span class="tag"><span class="tag-name">font</span><span> </span><span class="attribute">style</span><span>=</span><span class="attribute-value">"FONT-WEIGHT: bold; FONT-SIZE: 12px; FONT-FAMILY: 黑体"</span><span class="tag">></span><span>地址</span><span class="tag"></span><span class="tag-name">font</span><span class="tag">></span><span class="tag"></span><span class="tag-name">td</span><span class="tag">></span><span> </span></span></span></li>
<li class="alt"><span class="tag"><span class="tag-name">td</span><span> </span><span class="attribute">align</span><span>=</span><span class="attribute-value">"center"</span><span> </span><span class="attribute">colspan</span><span>=</span><span class="attribute-value">"2"</span><span class="tag">></span><span class="tag"><span class="tag-name">font</span><span> </span><span class="attribute">style</span><span>=</span><span class="attribute-value">"FONT-WEIGHT: bold; FONT-SIZE: 12px; FONT-FAMILY: 黑体"</span><span class="tag">></span><span>编辑</span><span class="tag"></span><span class="tag-name">font</span><span class="tag">></span><span class="tag"></span><span class="tag-name">td</span><span class="tag">></span><span> </span></span></span></li>
<li>
<span class="tag"></span><span class="tag-name">tr</span><span class="tag">></span><span> </span>
</li>
<li class="alt">
<span class="tag"></span><span class="tag-name">php</span><span> </span>
</li>
</ol>
로그인 후 복사

通知服务器客户端可以处理由多语句或者MySQL存储过程执行生成的多结果集。当打开CLIENT_MULTI_STATEMENTS时,这个标志自动的被打开。可以在本表后查看更多关于该标志位的信息。)

<ol class="dp-xml">
<li class="alt"><span><span>define('CLIENT_MULTI_RESULTS', 131072);  </span></span></li>
<li>
<span>$</span><span class="attribute">link</span><span> = </span><span class="attribute-value">mysql_connect</span><span>("localhost", "root", "123",1,CLIENT_MULTI_RESULTS) or die("数据库连接失败: ".mysql_error());  </span>
</li>
<li class="alt">
<span>$</span><span class="attribute">query</span><span>=</span><span class="attribute-value">mysql_query</span><span>("call bbs.p_alluserinfo()") or die("Query failed:" .mysql_error());  </span>
</li>
<li><span> </span></li>
<li class="alt">
<span>if(mysql_num_rows($query)</span><span class="tag">></span><span>0)  </span>
</li>
<li><span>{  </span></li>
<li class="alt">
<span>$</span><span class="attribute">info</span><span>=</span><span class="attribute-value">mysql_fetch_array</span><span>($query);  </span>
</li>
<li><span>do  </span></li>
<li class="alt"><span>{  </span></li>
<li>
<span>echo "</span><span class="tag"><span class="tag-name">tr</span><span class="tag">></span><span>";  </span></span>
</li>
<li class="alt">
<span>echo "</span><span class="tag"><span class="tag-name">td</span><span class="tag">></span><span>$info[user_Name]</span><span class="tag"></span><span class="tag-name">td</span><span class="tag">></span><span>";  </span></span>
</li>
<li>
<span>echo "</span><span class="tag"><span class="tag-name">td</span><span class="tag">></span><span>$info[user_Sex]</span><span class="tag"></span><span class="tag-name">td</span><span class="tag">></span><span>";  </span></span>
</li>
<li class="alt">
<span>echo "</span><span class="tag"><span class="tag-name">td</span><span class="tag">></span><span>$info[user_Age]</span><span class="tag"></span><span class="tag-name">td</span><span class="tag">></span><span>";  </span></span>
</li>
<li>
<span>echo "</span><span class="tag"><span class="tag-name">td</span><span class="tag">></span><span>$info[user_Tel]</span><span class="tag"></span><span class="tag-name">td</span><span class="tag">></span><span>";  </span></span>
</li>
<li class="alt">
<span>echo "</span><span class="tag"><span class="tag-name">td</span><span class="tag">></span><span>$info[user_Adderss]</span><span class="tag"></span><span class="tag-name">td</span><span class="tag">></span><span>";  </span></span>
</li>
<li>
<span>echo "</span><span class="tag"><span class="tag-name">td</span><span class="tag">></span><span class="tag"><span class="tag-name">a</span><span> </span><span class="attribute">href</span><span>=</span><span class="attribute-value">'uduser.php?uid=$info[user_ID]'</span><span class="tag">></span><span>更新</span><span class="tag"></span><span class="tag-name">a</span><span class="tag">></span><span class="tag"></span><span class="tag-name">td</span><span class="tag">></span><span>";  </span></span></span>
</li>
<li class="alt">
<span>echo "</span><span class="tag"><span class="tag-name">td</span><span class="tag">></span><span class="tag"><span class="tag-name">a</span><span> </span><span class="attribute">href</span><span>=</span><span class="attribute-value">'deluser.php?uid=$info[user_ID]'</span><span class="tag">></span><span>删除</span><span class="tag"></span><span class="tag-name">a</span><span class="tag">></span><span class="tag"></span><span class="tag-name">td</span><span class="tag">></span><span>";  </span></span></span>
</li>
<li>
<span>echo "</span><span class="tag"></span><span class="tag-name">tr</span><span class="tag">></span><span>";  </span>
</li>
<li class="alt">
<span>}while($</span><span class="attribute">info</span><span>=</span><span class="attribute-value">mysql_fetch_array</span><span>($query));  </span>
</li>
<li>
<span>echo "</span><span class="tag"></span><span class="tag-name">table</span><span class="tag">></span><span>";  </span>
</li>
<li class="alt"><span>}  </span></li>
<li><span>else  </span></li>
<li class="alt"><span>{  </span></li>
<li>
<span>echo "</span><span class="tag"><span class="tag-name">tr</span><span class="tag">></span><span>没有记录</span><span class="tag"></span><span class="tag-name">tr</span><span class="tag">></span><span class="tag"></span><span class="tag-name">table</span><span class="tag">></span><span>";  </span></span>
</li>
<li class="alt"><span>}  </span></li>
<li>
<span class="tag">?></span><span> </span>
</li>
<li class="alt">
<span class="tag"></span><span class="tag-name">table</span><span class="tag">></span><span> </span>
</li>
<li>
<span class="tag"></span><span class="tag-name">body</span><span class="tag">></span><span> </span>
</li>
<li class="alt">
<span class="tag"></span><span class="tag-name">html</span><span class="tag">></span><span> </span>
</li>
</ol>
로그인 후 복사

以上的相关内容就是对如何用php来对MySQL存储过程进行调用的介绍,望你能有所收获。


원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿