我從數據庫中選擇數據併成功返回數據。我只是不知道如何訪問陣列的元素,如用戶名或名稱等。這是輸出:codeigniter返回對象
Array([0] => stdClass Object([id] => 9 [fullname] =>خاÙ「د اÙ」غاÙ...دي[會員] =>免費[username] => kkkkk [密碼] => 16d7a4fca7442dda3ad93c9a726597e4 [email] => someone @ gmail .com [about] => [city] => riyadh [profilepic] => /home2/sdds/public_html/uploads/Red_velvet_cupcakes_with_roses.jpgRed_velvet_cupcakes_with_roses.jpg [mobile] => [telephone] => [address] => gallery_link] =>))
,這是在模型返回上面的代碼:
public function login()
{
$this->db->select('*');
$this->db->from('members');
$this->db->where('username', $this->input->post('username'));
$this->db->where('password', md5($this->input->post('password')));
$query = $this->db->get();
return $query->result();
}
所以在這裏做什麼?在此先感謝
foreach通過結果喲。 – Rooster 2013-04-04 18:13:44
給了我這個:消息:class stdClass的對象無法轉換爲字符串 – 2013-04-04 18:15:41
'$ query-> result()'返回一個_object_,而不是一個數組。如果你想要一個數組,可以使用'$ query-> result_array()'。這是一個常見的錯誤:) – 2013-04-04 18:29:57