donglu3184 2009-06-07 09:45
浏览 97
已采纳

php中的fetch做了什么?

I don't understand the concept of the fetch function.

I am doing a tutorial from 'PHP Solutions' book and i am using MySQL Improved to update something in the database.

Here is the code:

if (isset($_GET['article']) && !$_POST) {       

$sql = 'SELECT article_id, title, article
    FROM journal WHERE article_id = ?';

$stmt = $conn->stmt_init();

 if ($stmt->prepare($sql)) {            
    $stmt->bind_param('i', $_GET['article_id']);                    
    $stmt->bind_result($article_id, $title, $article); 

   //execute the query, and fetch the result
   $OK = $stmt->execute(); 
   $stmt->fetch();
 }
}

So what is the fetch actually doing? I thought the execute() function is sending the information to the database and then it returns a true/false value to the $OK variable.

Is fetch() storing something in $stmt? Anybody have any idea what it is doing?

  • 写回答

1条回答 默认 最新

  • dongqi8863 2009-06-07 09:51
    关注

    Hard to anticipate what was before this line in your example, but in general fetch function is for getting current row from result set you receive from database. You can read here

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 孟德尔随机化结果不一致
  • ¥15 深度学习残差模块模型
  • ¥50 怎么判断同步时序逻辑电路和异步时序逻辑电路
  • ¥15 差动电流二次谐波的含量Matlab计算
  • ¥15 Can/caned 总线错误问题,错误显示控制器要发1,结果总线检测到0
  • ¥15 C#如何调用串口数据
  • ¥15 MATLAB与单片机串口通信
  • ¥15 L76k模块的GPS的使用
  • ¥15 请帮我看一看数电项目如何设计
  • ¥23 (标签-bug|关键词-密码错误加密)