PHP面试之手写PDO连接数据库获取表数据

<?php
//POD连接数据库

try{
	$pdo = new PDO("mysql:host=127.0.0.1;port=3306;dbname=ecshop",'root','root');
	$pdo->exec("set names utf8");
}catch(PDOException $e){
	die("Error!:".$e->getMessage()."</br>");
}

$res = $pdo->query("select * from brand");
$data = $res->fetchall(PDO::FETCH_ASSOC);
echo "<pre>";
print_r($data);
发布了40 篇原创文章 · 获赞 0 · 访问量 699

猜你喜欢

转载自blog.csdn.net/weixin_39218464/article/details/103675490