php - codeigniter 获取最近查询的 postgres 字段类型
问题描述
我正在使用带有codeigniter的php。我喜欢在我的 postgres 数据库上运行 sql 查询,我不仅对结果感兴趣,而且对字段类型也感兴趣。
有php函数:pg_field_type (resource $result, int $field_number)
那应该返回我需要的信息,但我想知道是否有办法将它与 codeigniter db 类一起使用?
版本
postgres:9.4 代码点火器:3.1.10
例子
$res = $this->db->query("select * from foobar);
返回我这样的结果对象:
CI_DB_postgre_result Object
(
[conn_id] => Resource id #2
[result_id] => Resource id #5
[result_array] => Array
(
)
[result_object] => Array
(
)
[custom_result_object] => Array
(
)
[current_row] => 0
[num_rows] =>
[row_data] =>
)
Resource id #5 将是我的资源,但如何访问它?
最好的,
d。
解决方案
$res = $this->db->query("select * from foobar);
$data = $res->result();
print_r( $data ) // will print all the rows
//return $data // will return data to the controller
推荐阅读
- firebase - 如何访问我们 Firestore 集合的 google 注册用户的 uid?
- web-scraping - 从电源查询中的链接解压缩 Gz 文件
- html - 如何在输入标签类型中设置最大长度为数字?
- php - WooCommerce 数据库查询:从 thumbnail_id 获取产品类别图像路径+名称
- gitlab - 如何将值传递给来自文件的 gitlab 管道变量
- vba - 当我运行 VBA 脚本从 Outlook 中的特定 MAPI 文件夹批量打印 PDF 时,出现不一致的“找不到文件”错误
- c++ - 添加超过 30 天到 1900-01-01
- java - 使用 java 更新到 DCTM 时出现版本不匹配错误
- javascript - 无法读取未定义 Angular 8 的属性实例
- javascript - D3.js 捆绑/组节点 n 次