dongshi6528 2017-10-13 20:13
浏览 21
已采纳

使用codeigniter从数据库返回两行

This query works as I want but only returns one value.

public function get_doctor_name($doctor_id)  {
  $result = $this->db->query("SELECT first_name, last_name from doctors where id= $municipio_id")->row_array();
  return $result['first_name'];
}

How to return the last_name as I did for first_name in the same query?

  • 写回答

2条回答 默认 最新

  • duanhuan6336 2017-10-13 20:15
    关注

    Your query is actually correct.

    However, you can use return $result->result_array(); to get an array of all fields, first_name, last_name etc.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?