dtwxmn8741 2016-11-26 03:40
浏览 20

如果结果为空,如何获取字段名称? [PHP-笨]

I was able to take the field name from the table using array_keys() but if the query results are empty, array_keys() can not be used.

query results

is there any other way that I can take the name of the field even if the result is empty?

query result empty

Query i used:

SELECT m.nama_user, m.nama_login, m.email, m.tgl_expired, m.password_web, gu.ucode_grp, gu.nama_grp_user
FROM tb_m_user m
LEFT OUTER JOIN tb_m_grp_user gu
ON m.ucode_grp=gu.ucode_grp
WHERE id_user=10
  • 写回答

3条回答 默认 最新

  • dongxiaoying5882 2016-11-26 03:48
    关注

    In Codeigniter you can use...

    $field_names = $this->db->list_fields('name_of_your_table');
    

    name_of_your_table is the name of the Database Table you want the field list from.

    $field_names will be an array with the field names

    For more Details, Refer to https://www.codeigniter.com/userguide3/database/db_driver_reference.html?highlight=field%20names#CI_DB_driver::list_fields

    评论

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?