php mysqli数据库面向过程,面向对象实例比较

$value)
        echo "--$value";
    echo "
"; } //释放资源 mysqli_free_result($res); //关闭数据库 mysqli_close($mysqli); ?>

connect_error){
    die("连接失败".$mysqli->connect_error);
}
$mysqli->query("utf8");
//2。操作数据库
$sql="select * from user1";
$res=$mysqli->query($sql);
//3。处理结果
while($row=$res->fetch_row())
{
    foreach($row as $key=>$value)
        echo "--$value";
    echo "
"; } //4。关闭资源 $res->free(); $mysqli->close(); ?>

你可能感兴趣的:(php)