mysql - 如何将其转换为单个字符串值
问题描述
Array ( [0] => Array ( [Max(Exam_Id)] => 6 ) )
public function get_max_exam_id()
{
$query = $this->db->query("SELECT Max(Exam_Id) from exam_tb");
return $query->result_array();
}
解决方案
首先你需要添加别名
$query = $this->db->query("SELECT Max(Exam_Id) as max_exam_id from exam_tb");
尝试使用 row_array() 而不是 result_array()
//return $query->result_array();
$result = $query->row_array();
return $result['max_exam_id'];
并使用别名 $result['max_exam_id'] 访问它。也许可以帮助:)
推荐阅读
- ios - 如何在 iOS Objective-c 中获取应用购买的原始购买日期?
- botframework - 如何将聊天机器人功能与 Microsoft 团队自定义选项卡集成
- docker - 如何处理 flink 管理和 k8s 管理
- ruby-on-rails - 确保在 Rails 上设置 ruby 时出现需要运行时错误
- denodo - 将多个变量转换为日期会导致错误
- java - 如何使用 Java 在 URL 字符串中的位置 X 处将 Int 增加 1?
- javascript - 对数组中的三个项目进行 ng-repeat
- kframework - 什么是级联术语,它们在什么情况下是出乎意料的?
- python - 在 Python 3 中将 Ctrl-D 与 sys.stdin.readlines() 一起使用后,如何避免 input() 出现 EOFError?
- mysql - 递归关系问题