Home  >  Article  >  Backend Development  >  pdo connection access database code_PHP tutorial

pdo connection access database code_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:04:471079browse

pdo connection access database tutorial code
//php tutorial.ini needs to be opened:
//extension=php_pdo.dll
//extension=php_pdo_odbc.dll
//The database is acc.mdb, to prevent malicious downloads, change it to acc.php

try{
$db = new pdo("odbc:driver={microsoft access driver (*.mdb)};dbq=".getcwd()."acc.php",'aaa','123456'); //getcwd() The function is to get the current path
//echo "connectedn";

date_default_timezone_set('asia/shanghai'); //Beijing time
$v="Test".date("y-m-d h:i:s")."Added content";
$db->exec("insert into table1(topic) values('$v')");//Insert
//echo $db->lastinsertid(); //Not supported
$rs=$db->query("select * from table1"); //Select
while($row=$rs->fetch()){
echo $row[id]."-".$row[topic]."
";
};

} catch (exception $e) {
//echo "failed:".$e->getmessage();
}

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/630841.htmlTechArticlepdo connection access database tutorial code //php tutorial.ini needs to be opened: //extension=php_pdo.dll // extension=php_pdo_odbc.dll //The database is acc.mdb. To prevent malicious downloads, change it to acc.php t...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn