时间:2021-07-01 10:21:17 帮助过:37人阅读
一.PDO 增删改查
连接 $pdo= New PDO (‘mysql:host=localhost;dbname=houtaiablyycnbak‘,‘root‘,‘Aa122‘ );
接下来增删改查
$sql = "select * from patient_13 where age between 20 and 30 && sex =‘女‘ order by age desc"; $sq="insert into patient_13(age,name,sex) Values(33,‘张小姐酒‘,‘女‘)"; $sql="delete from patient_13 where name=‘彭昌雲‘"; $sql="update patient_13 set name = ‘李值‘where name=‘李亚飞‘";
执行语句
$a=$pdo->exec($sql);
查询语句
$smt = $pdo -> query($sql); $arr = $smt -> fetchAll(pdo::FETCH_ASSOC); foreach ($arr as $arrs) { echo ‘<tr>‘; echo "<td>{$arrs[‘age‘]} </td>"; echo "<td>{$arrs[‘name‘]}</td>"; echo "<td>{$arrs[‘sex‘] }</td>"; echo "<br>"; echo "</tr>"; }
php 总结(10) PDO 连接数据库 预处理
标签:预处理 roo pdo bsp amp fetch esc new out