douqiao4450 2017-02-07 17:51
浏览 21
已采纳

PHP Web服务mySQL查询 - 一般说明

Wanting to get some clarity for the below code, I have made comments next to each line and question marks where I am need some assistance please

$sql = 'SELECT * FROM users';                    // Select all data

$query = $this -> conn -> prepare($sql);         // Connects to server and executes select all query
$query -> execute(array(':email' => $email));    // ????
$data = $query -> fetchObject();                 // Stores the results on the executed query in $data??
  • 写回答

3条回答 默认 最新

  • dtwvr26066 2017-02-07 18:05
    关注

    $email substitutes your ':email' with $email variable.

    See examples here

    In your case, since you don't have any parameter marker, you can directly execute the query without any parameter binding.

    $sql = 'SELECT * FROM users';                   
    $query = $this -> conn -> prepare($sql);         
    $query -> execute();   
    $data = $query -> fetchObject();                
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)
编辑
预览

报告相同问题?

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

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

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

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

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

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

客服 返回
顶部