Is it possible to combine mysqli prepared statement with multiple inserts?

后端 未结 1 1869
暗喜
暗喜 2021-01-14 18:56

I am well-versed in the old php mysql extension.

I am working on my first script that uses the mysqli extension.

I am going to be inserting a large number of

相关标签:
1条回答
  • 2021-01-14 19:46
    $stmt = $mysqli->stmt_init();
    
    if($stmt->prepare("INSERT INTO `activity` (`id`, `name`, `type`) VALUES (?, ?, ?)"))
    {
       $stmt->bind_param('iss', $_id, $_name, $_type);
       for($i=0;$i<$limit;$i++)
       {
          $_id = $id[$i];
          $_name = $name[$i];
          $_type = $type[$i];
          $stmt->execute();
       }
    
    }
    

    should do it for you!

    0 讨论(0)
提交回复
热议问题