最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

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

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

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

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

<?php
require_once "DB.php";
$conn = DB::connect("mysql://root:1981427@localhost/test"); //調(diào)用connect連接數(shù)據(jù)庫
if (DB::isError($conn)) //如果連接出錯則報錯
{
print "數(shù)據(jù)庫連接失敗";
}
$rs = $conn->query("select id,username, password from tablename1"); //執(zhí)行SQL語句
if (DB::isError($rs)) //判斷是否執(zhí)行成功
{
print "數(shù)據(jù)查詢失敗";
}
while ($rs->fetchInto($rows)) //循環(huán)輸出查詢結(jié)果
{
print "編號號:$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ù)庫
if (DB::isError($conn)) //如果連接出錯則報錯
{
print "數(shù)據(jù)庫連接失敗";
}
//執(zhí)行SQL語句,從第0條開始返回1條記錄
$rs = $conn->limitQuery("select id,username, password from tablename1",2,5); //查詢出記錄集中第三個到第六個數(shù)據(jù)
if (DB::isError($rs)) //如果查詢出錯則報錯
{
print "數(shù)據(jù)查詢失敗";
}
while ($rs->fetchInto($rows)) //循環(huán)輸出查詢結(jié)果
{
print "編號:$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ù)庫
if (DB::isError($conn))
{
print "數(shù)據(jù)庫連接失敗";
}
//使用prepare函數(shù)準備SQL語句
$rs = $conn->prepare("update tablename1 set password = 'Susan' where id = '1'");
if (DB::isError($rs))
{
print "數(shù)據(jù)更新失敗";
}
else
{
$conn->execute($rs); //執(zhí)行SQL語句更新數(shù)據(jù)庫
print "數(shù)據(jù)更新成功";
}
?>

相關(guān)文章

最新評論

万安县| 广安市| 开原市| 四川省| 苍南县| 宝清县| 深水埗区| 鸡东县| 藁城市| 航空| 扎赉特旗| 铁力市| 永平县| 平果县| 扶余县| 彩票| 博兴县| 方山县| 射洪县| 霍林郭勒市| 榆社县| 竹山县| 汕尾市| 芜湖市| 旺苍县| 墨竹工卡县| 香格里拉县| 临漳县| 东平县| 青岛市| 武汉市| 兴国县| 比如县| 谢通门县| 兰溪市| 肇州县| 启东市| 巴林右旗| 法库县| 合阳县| 宁陵县|