How do I ensure I caught all errors from MySQLi::multi_query?

前端 未结 3 947
清酒与你
清酒与你 2020-12-03 15:11

The docs for multi_query say:

Returns FALSE if the first statement failed. To retrieve subsequent errors from other statements you have to call mysqli

3条回答
  •  难免孤独
    2020-12-03 15:18

    Despite the code example in the docs, perhaps the better method would be something like this:

    if ($mysqli->multi_query(...)) {
      do {
        // fetch results
    
        if (!$mysqli->more_results()) {
          break;
        }
        if (!$mysqli->next_result()) {
          // report error
          break;
        }
      } while (true);
    }
    

提交回复
热议问题