Mysqli-将结果绑定到数组

Mysqli-将结果绑定到数组,第1张

Mysqli-将结果绑定数组

最终,这段代码可以正常工作了!

  <?php     $host = 'localhost';     $user = 'root';     $pass = '1234';     $data = 'test';    $mysqli = new mysqli($host, $user, $pass, $data);          if (mysqli_connect_errno()) {         printf("Connect failed: %sn", mysqli_connect_error());         exit();     }    if ($stmt = $mysqli->prepare("SELECt * FROM sample WHERe t2 LIKE ?")) {         $tt2 = '%';        $stmt->bind_param("s", $tt2);         $stmt->execute();        $meta = $stmt->result_metadata();         while ($field = $meta->fetch_field())         {  $params[] = &$row[$field->name];         }        call_user_func_array(array($stmt, 'bind_result'), $params);        while ($stmt->fetch()) {  foreach($row as $key => $val)  {      $c[$key] = $val;  }  $result[] = $c;         }        $stmt->close();     }     $mysqli->close();     print_r($result);     ?>


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5113247.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-17
下一篇 2022-11-17

发表评论

登录后才能评论

评论列表(0条)

保存