簡體   English   中英

獲取mysql表中單元格的值

[英]Get the value of a cell in mysql table

我正在使用CodeIgniter編寫幾行簡單的代碼,以從mysql表中獲取價值。

我嘗試過的

$interview_id=45
$category_raw = $this->db->query("select category from interview where interview_id='$interview_id'");
$category = $category_raw->first_row(); 

但是由於某種原因,$ category顯示為“ array()”,而我實際上想在其中獲取值。

關於如何進行的任何建議?

非常感謝,

您可以像

   $category = $category_raw->first_row()->category; 

因為first_row()總是返回值作為對象

文件資料

嘗試

$interview_id=45;
$category_raw = $this->db->query("select category from interview where interview_id=$interview_id");
$category = $category_raw->first_row()->category; 

或有活動記錄

$interview_id=45;
$this->db->select("category");
$this->db->where("interview_id",$interview_id);
$category_raw = $this->db->get("interview");
$category = $category_raw->first_row()->category; 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM