1
我使用的是CodeIgniter,當使用results()
方法從表中提取所有行時,我無法使where()
選擇方法起作用。CodeIgniter模型無法返回特定記錄
這裏是我的模型:
public function get_all_entries($id)
{
// Select row to be fetched
$this->db->where('id', $id);
$this->db->get('users');
// Execute the find query with provided data
$query = $this->db->get('users');
// Return an object with all the data
return $query->result();
}
它應該返回所有匹配的users
表$id
的說法,但相反,它只是取表中的所有記錄,包括那些沒有按行與提供的$id
參數不匹配。
我在做什麼錯在這裏?我試過row()
方法,雖然它與where()
一起使用,但它只返回一行,所以它不適合我的情況。
我試過了,但是還有一個問題(如果ID是在表零與否),導致我覺得這也不是辦法,現在我固定的問題,解決你提到的作品,謝謝。 –
很高興它的工作。 –
您能否提出問題upvote?真的很感激。 –