亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

php db類庫(kù)進(jìn)行數(shù)據(jù)庫(kù)操作

 更新時(shí)間:2009年03月19日 01:23:46   作者:  
前提是必須安裝db類庫(kù)包

復(fù)制代碼 代碼如下:

<?php
require_once "DB.php"; //包含類庫(kù)文件
$conn = DB::connect("mysql://root:1981427@localhost/test"); //連接數(shù)據(jù)庫(kù)
if (!DB::isError($conn)) { //判斷是否連接成功
print "數(shù)據(jù)庫(kù)連接成功";
}
else
{
echo "數(shù)據(jù)庫(kù)連接失敗!";
}
?>

復(fù)制代碼 代碼如下:

<?php
require_once "DB.php";
$conn = DB::connect("mysql://root:1981427@localhost/test"); //調(diào)用connect連接數(shù)據(jù)庫(kù)
if (DB::isError($conn)) //如果連接出錯(cuò)則報(bào)錯(cuò)
{
print "數(shù)據(jù)庫(kù)連接失敗";
}
$rs = $conn->query("select id,username, password from tablename1"); //執(zhí)行SQL語(yǔ)句
if (DB::isError($rs)) //判斷是否執(zhí)行成功
{
print "數(shù)據(jù)查詢失敗";
}
while ($rs->fetchInto($rows)) //循環(huán)輸出查詢結(jié)果
{
print "編號(hào)號(hào):$rows[0]<BR>";
print "姓名:$rows[1]<BR>";
print "密碼:$rows[2]<BR>";
print "<HR>";
}
?>

復(fù)制代碼 代碼如下:

<?php
require_once "DB.php";
$conn = DB::connect("mysql://root:1981427@localhost/test"); //調(diào)用connect連接數(shù)據(jù)庫(kù)
if (DB::isError($conn)) //如果連接出錯(cuò)則報(bào)錯(cuò)
{
print "數(shù)據(jù)庫(kù)連接失敗";
}
//執(zhí)行SQL語(yǔ)句,從第0條開(kāi)始返回1條記錄
$rs = $conn->limitQuery("select id,username, password from tablename1",2,5); //查詢出記錄集中第三個(gè)到第六個(gè)數(shù)據(jù)
if (DB::isError($rs)) //如果查詢出錯(cuò)則報(bào)錯(cuò)
{
print "數(shù)據(jù)查詢失敗";
}
while ($rs->fetchInto($rows)) //循環(huán)輸出查詢結(jié)果
{
print "編號(hào):$rows[0]<BR>";
print "姓名:$rows[1]<BR>";
print "密碼:$rows[2]<BR>";
print "<HR>";
}
?>

復(fù)制代碼 代碼如下:

<?php
require_once "DB.php";
$conn = DB::connect("mysql://root:1981427@localhost/test"); //連接數(shù)據(jù)庫(kù)
if (DB::isError($conn))
{
print "數(shù)據(jù)庫(kù)連接失敗";
}
//使用prepare函數(shù)準(zhǔn)備SQL語(yǔ)句
$rs = $conn->prepare("update tablename1 set password = 'Susan' where id = '1'");
if (DB::isError($rs))
{
print "數(shù)據(jù)更新失敗";
}
else
{
$conn->execute($rs); //執(zhí)行SQL語(yǔ)句更新數(shù)據(jù)庫(kù)
print "數(shù)據(jù)更新成功";
}
?>

相關(guān)文章

最新評(píng)論