日本亚洲欧美日韩中文字幕_精品欧美一区二区三区久久久_久久av高潮av无码av_成在人线av无码免费_亚洲中文字幕无码久久精品1

返學(xué)費網(wǎng) > 培訓(xùn)機構(gòu) > 天津東大遠航教育中心

4008508622

全國統(tǒng)一學(xué)習(xí)專線 8:30-21:00

PHP+Access連接方法(類實現(xiàn))
<?php
//adodb.php
class ADODB_ACCESS
{
var $Uid;
var $Pwd;
var $DataBase;
var $DataPath;
var $PathName;
var $DB_Address;
var $DSN;
var $Conn;

function AdodbConnection()
{
//連接用戶名
$this->Uid = NULL;
//連接密碼
$this->Pwd = NULL;
//數(shù)據(jù)庫文件
$this->DataBase = "Test.mdb";
//數(shù)據(jù)庫所在目錄
$this->DataPath = "DataBase";
//得到當(dāng)前目錄
$this->PathName = str_replace('\\','\\',dirname(__FILE__));
//得到數(shù)據(jù)庫目錄
$this->DB_Address = $this->PathName."\\".$this->DataPath."\\".$this->DataBase;
//ADODB Access標(biāo)準(zhǔn)連接語句
$this->DSN = "Driver={<strong = true;isShowAds2 = true;KeyGate_ads.Move(this,"","%u6700%u65B0Microsoft%u4FE1%u606F%uFF0C%u514D%u8D39%u6CE8%u518C%u7ACB%u5373%u83B7%u53D6%u6700%u65B0%u5FAE%u8F6F%u6280%u672F%u8D44%u8BAF%21","10257","Microsoft","Microsoft","https%3A//profile.microsoft.com/RegSysProfileCenter/subscriptionwizard.aspx%3Fwizid%3D2f387746-8112-4657-9d8d-64779dde7ad5%26lcid%3D2052", event)" style="border-top-width: 0px; font-weight: normal; border-left-width: 0px; border-bottom-width: 0px; cursor: hand; color: #0000ff; border-right-width: 0px; text-decoration: underline" http://s8.17luntan.com/ClickPortal/WebClick.aspx?id=10257&k=Microsoft&siteid=10VwUHAlNYBAcGUARSAFVUB1lSAwQGBlQBWFYKVQMPBQI&url=http%3A//www.cmd123.com/read.php%3Ftid%3D2561&gourl=https%3A//profile.microsoft.com/RegSysProfileCenter/subscriptionwizard.aspx%3Fwizid%3D2f387746-8112-4657-9d8d-64779dde7ad5%26lcid%3D2052&parm=4683B6703B87F582B45C68B34A14202E0658C3A4FFB06EB5&alliedsiteid=22");" = false;isShowAds2 = false">Microsoft Access Driver (*.mdb)};Dbq=".$this->DB_Address.";Uid=".$this->Uid.";Pwd=;".$this->Pwd."";
//創(chuàng)建COM的實例
$this->Conn = new COM("ADODB.Connection") or die("Can't Connection DataBase Of Access !");
//打開數(shù)據(jù)庫
$this->Conn->Open($this->DSN);
}

function AdodbClose()
{
$this->Conn->Close();
$this->Conn->Release();
$this->Conn = NULL;
}
}
?>

//class.php
<?php

include_once("ADODB.PHP");

class ExecuteSQL extends ADODB_ACCESS
{
//$StrSQL : 數(shù)據(jù)庫查詢字符串
//$PageSize : 每頁顯示記錄數(shù)
//$PageNo : 為$_GET["PageNo"]
function SelectLimit($StrSQL,$PageSize,$PageNo)
{
//連接ACCESS
$this->AdodbConnection();
$Result = $this->Conn->Execute($StrSQL);
$ResultNum = $this->Conn->Execute($StrSQL);
$FieldsNum = $Result->Fields->Count();
//得到總記錄
$Total = 0;
while(!$ResultNum->EOF)
{
$Total++;
$ResultNum->MoveNext();
}
//定義循環(huán)
$k = 0;
//定義頁數(shù)
if(($Total%$PageSize)==0)
$MaxPage = (int)($Total/$PageSize);
else
$MaxPage = (int)($Total/$PageSize)+1;
if(empty($PageNo)) $PageNo = 1;
if($PageNo < 1) $PageNo = 1;
if($PageNo > $MaxPage) $PageNo = $MaxPage;
//定義每頁開始記錄數(shù)
$StartPos = ($PageNo-1)*$PageSize;
$EndPos = $PageSize*$PageNo+1;
print("共有".$MaxPage."頁".",".$Total."條記錄,第".$PageNo."頁,每頁顯示".$PageSize."條<br><br>");
//循環(huán)
while (!$Result->EOF)
{
//這里實現(xiàn)分頁
//思路為:得到所有記錄,但只打印當(dāng)前頁碼的記錄。
//PHP+ACCESS分頁的方法很多,自己想想。
//我這個方法很笨,提示一種方法:
//
//將$StrSQL查詢字符串改寫,SelectLimit($StrSQL,$PageSize,$StartPage)可成為獨立的函數(shù)
//例:$StrSQL="select * from cars order by id desc limit $StartPage,$PageSize"(MySQL)
// $StrSQL="select * from cars order by id desc where id>$StartPage and id<$EndPos"(Access)
//
//E-Mail:
//OICQ : 3076622
//
if($k>=($StartPos) && $k<($EndPos)){
for ($i=0; $i < $FieldsNum; $i++)
{
echo $Result->Fields[$i]->value." ";
}
echo "<br>";
}
$k++;
$Result->MoveNext();
}

//分頁,自己改.
echo "<a href=\"?PageNo=1\"><< First</a> ";
$PageNo = $PageNo-1;
echo "<a href=\"?PageNo=".$PageNo."\">< Provious</a> ";
$PageNo = $PageNo+1;
echo "<a href=\"?PageNo=".$PageNo."\">Next ></a> ";
echo "<a href=\"?PageNo=".$MaxPage."\">Last >></a>";
//關(guān)閉連接
$this->AdodbClose();
}
}
?>
//default.php

<?
include_once ('CLASS.PHP');

$a = new ExecuteSQL;
$a->SelectLimit("Select * From Cars","20",$PageNo);
?>
/*
說明:
COM+CLASS實現(xiàn)連接,并實現(xiàn)了翻頁功能
*/

溫馨提示:為不影響您的學(xué)業(yè),來校區(qū)前請先電話咨詢,方便我校安排相關(guān)的專業(yè)老師為您解答
  • 熱門課程
  • 作者最新文章
  • 在線報名
申請試聽課程

只要一個電話
我們免費為您回電

姓名不能為空
手機號格式錯誤