PHP?????????PDO
???????????? ???????[ 2014/10/30 10:34:33 ] ????????????? PHP
?????????????????
????????phpinfo.php??????????????????????????????????????????????mySql???????????
??????c?????php.ini???????????????mySql???????????????????????
?????????????
<?php
//?????????
$dsn="mysql:dbname=test;host=127.0.0.1";//???????
$user="root";//username
$password="715632";//????
try{
$pdoConn=new PDO($dsn??$user??$password);
echo "???????????";
}catch(PDOException $e){
echo "????????????".$e->getMessage();
exit;
}
?????????
<?php
//?????????
$dsn="mysql:dbname=test;host=127.0.0.1";//???????
$user="root";//username
$password="715632";//????
try{
$pdoConn=new PDO($dsn??$user??$password);
echo "???????????"."<br/>";
}catch(PDOException $e){
echo "????????????".$e->getMessage();
exit;
}
try{
//???????
/*$sql="insert into contacts(name??telno??email) values(???????)";
$ptmt=$pdoConn->prepare($sql);
$name="liujun";
$telno="347535420";
$email="liujun@qq.com";
$ptmt->bindParam(1??$name);
$ptmt->bindParam(2??$telno);
$ptmt->bindParam(3??$email);
$result=$ptmt->execute();
echo "?????????".$result;
*/
//???????
$sql="select * from contacts";
$ptmt=$pdoConn->prepare($sql);
$result=$ptmt->execute();
if($result==1){//???н????
while($list=$ptmt->fetch()){
echo $list['name']."-----".$list['telno']."----".$list['email']."<br/>";
}
}
}catch(PDOExcepton $e){
echo "???????????";
exit;
}
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11