php调用mysql存储过程返回结果集
分类:博客热点

最近开发一个项目,用到这个,记一下:

<?php// display error is On for us to be notified if there's something wrongini_set ('display_errors','On');error_威尼斯正规官网,reporting ( E_ALL );// Config, change this variables$dbServer ="localhost";$dbUser ="帐号";$dbPass ="密码";$dbName = $_GET['dbName'];// Set a connection for our database$link = mysql_connect ( $dbServer, $dbUser, $dbPass ) ordie("unable to connect to msql server: ". mysql_error () );// Select our databasemysql_select_db ( $dbName, $link ) ordie("unable to select database 'db': ". mysql_error () );$result = mysql_query ("show tables");if(! $result) {die('query failed: ');}// Use while loop to convert all tables to MyISAMwhile($row = mysql_fetch_array ( $result )) {// Command Reference: ALTER TABLE tableName ENGINE=MyISAMecho"ALTER TABLE ". $row [0] ." ENGINE=MyISAM; ".'<br/>';mysql_query ("ALTER TABLE ". $row [0] ." ENGINE=MyISAM; ");}?>调用页面<?php// display error is On for us to be notified if there's something wrongini_set ('display_errors','On');error_reporting ( E_ALL );// Config, change this variables$dbServer ="localhost";$dbUser ="帐号";$dbPass ="密码";// Set a connection for our database$link = mysql_connect ( $dbServer, $dbUser, $dbPass ) ordie("unable to connect to msql server: ". mysql_error () );$result = mysql_query ("show databases;");if(! $result) {die('query failed: ');}// Use while loop to convert all tables to MyISAMwhile($row = mysql_fetch_array ( $result )) {echo'<a href="innodb2myisam.php?dbName='.$row[0].'">'.$row[0].'<a/><br/>';}?>

关键就是两点

[PHP]代码

1 define('CLIENT_MULTI_RESULTS',131072);23$link=mysql_connect("127.0.0.1","root","",1,CLIENT_MULTI_RESULTS)ordie("Couldnotconnect:".mysql_error());下面就可以正常使用了,以下是例子程序。

<?php
// display error is On for us to be notified if there's something wrong
ini_set ( 'display_errors', 'On' );
error_reporting ( E_ALL );
// Config, change this variables
$dbServer = "localhost";
$dbUser = "帐号";
$dbPass = "密码";
$dbName = $_GET['dbName'];
// Set a connection for our database
$link = mysql_connect ( $dbServer, $dbUser, $dbPass ) or die ( "unable to connect to msql server: " . mysql_error () );
// Select our database
mysql_select_db ( $dbName, $link ) or die ( "unable to select database 'db': " . mysql_error () );
$result = mysql_query ( "show tables" );
if (! $result) {
die ( 'query failed: ' );
}
// Use while loop to convert all tables to MyISAM
while ( $row = mysql_fetch_array ( $result ) ) {
// Command Reference: ALTER TABLE tableName ENGINE=MyISAM
echo "ALTER TABLE " . $row [0] . " ENGINE=MyISAM; ".'<br/>';
mysql_query ( "ALTER TABLE " . $row [0] . " ENGINE=MyISAM; " );
}
?>

调用页面

<?php
// display error is On for us to be notified if there's something wrong
ini_set ( 'display_errors', 'On' );
error_reporting ( E_ALL );
// Config, change this variables
$dbServer = "localhost";
$dbUser = "帐号";
$dbPass = "密码";
// Set a connection for our database
$link = mysql_connect ( $dbServer, $dbUser, $dbPass ) or die ( "unable to connect to msql server: " . mysql_error () );
$result = mysql_query ( "show databases;" );
if (! $result) {
die ( 'query failed: ' );
}
// Use while loop to convert all tables to MyISAM
while ( $row = mysql_fetch_array ( $result ) ) {
echo '<a href="innodb2myisam.php?dbName='.$row[0].'">'.$row[0].'<a/><br/>';
}
?>

1?php2define('CLIENT_MULTI_RESULTS',131072);34$link=mysql_connect("127.0.0.1","root","",1,CLIENT_MULTI_RESULTS)ordie("Couldnotconnect:".mysql_error());5mysql_select_db("vs")ordie("Couldnotselectdatabase");6?78 ?php9$result=mysql_query("callget_news_from_class_id(2)")ordie("Queryfailed:".mysql_error());10while($row=mysql_fetch_array($result,MYSQL_ASSOC))11{12$line='trtdatarget=_blankhref=''.$row["url"].'''.$row["title"].'('.$row["page_time"].')'.'/a/td/tr';14echo$line;15printf("n");1617}18mysql_free_result($result);19 ?2021?php22mysql_close($link);23?<

本文由威尼斯在线注册平台发布于博客热点,转载请注明出处:php调用mysql存储过程返回结果集

上一篇:多态等等卡塔尔国高端OOP (使用 PHP,直至 PHP5.6 中加进的新特色 下一篇:没有了
猜你喜欢
热门排行
精彩图文