doushao1948 2015-05-23 19:02
浏览 312
已采纳

我需要保留mysqli_query()和mysqli_close()吗?

Do I still need to use mysqli_query($connection, $results); and mysqli_close($connection); ?

$sql = $connection->prepare("INSERT INTO pawnshop ".
    "(Pawnshop_Name, Street, Barangay, City, DTI_Permit_No, Mayor_Permit_No, Firstname, Middlename, Lastname, Contact_Number, Email_Address, Password) ".
    "VALUES ".
    "(?,?,?,?,?,?,?,?,?,?,?,?)");
    $sql->bind_param("ssssiissssss", $pawnshopName, $street, $barangay, $city, $dtiPermitNo, $mayorPermitNo, $firstName, $lastName, $middleName, $contactNumber, $email, $password);
    $sql->execute();
    $results = $sql->get_results();   
    mysqli_query($connection, $results);// Do I still need this?
    mysqli_close($connection); //Do I still need this
  • 写回答

2条回答 默认 最新

  • duanchen7401 2015-05-23 19:41
    关注

    this much part of the code is enough for you to finish querying database.

    $sql = $connection->prepare("INSERT INTO pawnshop ".
        "(Pawnshop_Name, Street, Barangay, City, DTI_Permit_No, Mayor_Permit_No, Firstname, Middlename, Lastname, Contact_Number, Email_Address, Password) ".
        "VALUES ".
        "(?,?,?,?,?,?,?,?,?,?,?,?)");
        $sql->bind_param("ssssiissssss", $pawnshopName, $street, $barangay, $city, $dtiPermitNo, $mayorPermitNo, $firstName, $lastName, $middleName, $contactNumber, $email, $password);
        $sql->execute();
        $results = $sql->get_results(); 
    

    I see that you are mixing both OOP and Procedural Programming methods together by using mysqli_close($connection), it is not a good practice even though you can do it. Instead use method in $connection object like $connection->close();

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)
编辑
预览

报告相同问题?

悬赏问题

  • ¥15 ArcGIS Pro时空模式挖掘工具
  • ¥15 获取到海康hls的视频地址是http协议导致无法正常播放
  • ¥15 seL4如何实现从终端输入数据
  • ¥15 方波信号时频特征分析/信号调制与解调过程分析/利用DFT分析信号频谱
  • ¥20 两台硬件相同的琴设备一个是高阶版,怎么扒到初阶版
  • ¥30 matlab求解周期与坐标
  • ¥15 MATLAB图片转灰度格式问题
  • ¥15 把h5作品链接复制到自己的账号里
  • ¥15 ensp抓包实验配置
  • ¥15 强化学习算法、MRO
手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部