extension=php_pdo.dll
extension=php_pdo_mysql.dll
DROP TABLE IF EXISTS `test`; CREATE TABLE `test` ( `id` int(10) NOT NULL DEFAULT '0', `user` char(20) DEFAULT NULL, PRIMARY KEY (`id`), KEY `idx_age` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
<?php
header("content-type:text/html;charset=utf-8");
$dsn="mysql:dbname=test;host=localhost";
$db_user='root';
$db_pass='admin123';
try{
$pdo=new PDO($dsn,$db_user,$db_pass);
}catch(PDOException $e){
echo '数据库连接失败'.$e->getMessage();
}
//新增
$sql="insert into test (id,user) values (1,'phpthinking')";
$res=$pdo->exec($sql);
echo '影响行数:'.$res;
//修改
$sql="update test set user='phpthinking' where id=1";
$res=$pdo->exec($sql);
echo '影响行数:'.$res;
//查询
$sql="select * from test";
$res=$pdo->query($sql);
foreach($res as $row){
echo $row['user'].'<br/>';
}
//删除
$sql="delete from test where id=1";
$res=$pdo->exec($sql);
echo '影响行数:'.$res;
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有