php连接Access数据库的三种方法

 

http://bbs.csdn.net/topics/290009483

php.ini中加上extension=php_com_dotnet.dll
因为php5.4以后就不内嵌com了。

 

 

http://zhidao.baidu.com/link?url=tNEiPJAkqO8BFzqbe_FzvvFB6TpR-Go8IXMBjXK6NNNFz6JiALa6sCTWFb3aG_cf2QwbbbXOxemVayd4j8vp3K

 

 

提供已知的几种连接方式:

1.
$conn = new com("ADODB.Connection");
$connstr = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" . realpath("test.mdb");
$conn->Open($connstr);

2.
$conn=new com("ADODB.connection");
$connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=".realpath("test.mdb");
$conn->open($connstr);

3.
$connection = odbc_connect("Driver={Microsoft Access Driver (*.mdb)};Dbq=$mdbFilename", $user, $password);

在ThinkPhp的controller中由于存在命名空间,所以要使用“$conn = new \com("ADODB.Connection");” 

 

http://zhidao.baidu.com/question/383674258.html?qbl=relate_question_1&word=php%20mdb

$rs=new com('adodb.recordset');
$rs->Open('SELECT * FROM 数据表名',$conn,1,1);

$rs->PageSize=50;
$page=1;
if(!empty($_GET['page'])){
$page=$_GET['page'];
if($page<1)$page=1;
if($page>$rs->PageCount)$page=$rs->PageCount;
}
$rs->AbsolutePage=$page;

echo '';
foreach( $rs->Fields as $name){
echo '';
}
echo '';
for(;!$rs->EOF;$rs->MoveNext()){
echo '';
foreach( $rs->Fields as $name){
echo '';
}
echo '';
if($rs->AbsolutePosition>=$rs->AbsolutePage*$rs->PageSize)break;
}
echo '';
for($i=0;$i<$rs->PageCount;$i++){
echo ' '.($i+1).' ';
}

你可能感兴趣的:(web)

'.$name->Name.'
'.$name.'