Maison > base de données > tutoriel mysql > le corps du texte

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

WBOY
Libérer: 2016-06-07 16:13:31
original
826 Les gens l'ont consulté

以下的文章主要介绍的是如何用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>
Copier après la connexion

通知服务器客户端可以处理由多语句或者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>
Copier après la connexion

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


Étiquettes associées:
source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal