小编Red*_*iCo的帖子

在结果数组中是否使用列(PK)作为索引的"mysqli_fetch_all"?

目前我有一些效果:

<?php

  // ...More Code

  $result = mysqli_query($mysqli, "SELECT * FROM stock_types");
  if(!$result || mysqli_num_rows($result) < 1) die('error');
  $stock_types = mysqli_fetch_all($result, MYSQLI_ASSOC);
  mysqli_free_result($result);
  die(print_r($stock_types,true));

  // More Code...

?>
Run Code Online (Sandbox Code Playgroud)

会输出一些效果:

Array (
  [0] => Array (
    [type_id] => 1
    [type_name] => In Stock
    [type_visible] => 1
    [type_locked] => 0
  )
  [1] => Array (
    [type_id] => 2
    [type_name] => Out of Stock
    [type_visible] => 1
    [type_locked] => 1
  )
  [2] => Array (
    [type_id] => 3
    [type_name] => Offline
    [type_visible] => …
Run Code Online (Sandbox Code Playgroud)

php arrays mysqli

5
推荐指数
1
解决办法
1713
查看次数

标签 统计

arrays ×1

mysqli ×1

php ×1