php 查询语句获取数据,数据库有好多表现形式,如何拿出自己需要的数据

$raceSQL ='select id, race_name,race_code,content from je_race ';
$pdoStatement = $db->query ($raceSQL);
$Races = json_encode ( $pdoStatement->fetchAll());
print $Races;

responseText"[{"id":"4","0":"4","race_name":"renl","1":"renl","race_code":"s","2":"s","content":"","3":""]"

如何去掉不需要的表现形式

$Races = json_encode ( $pdoStatement->fetchAll(PDO::FETCH_ASSOC));

responseText"[{"id":"4","race_name":"renl","race_code":"s","content":""},{"id":"5","race_name":"2321","race_code":"d","content":""}]"

 

json_encode:php 内把数据转换为json字符串

相关文章:

  • 2021-11-14
  • 2021-08-06
  • 2022-12-23
  • 2022-01-28
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-02
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案