第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

試圖獲取非對象的屬性“join_id”

試圖獲取非對象的屬性“join_id”

PHP
冉冉說 2023-03-04 18:13:22
請告訴我如何解決這個問題,我從我的 PHP CodeIgniter API 得到錯誤錯誤嘗試獲取非對象的屬性“join_id”詢問Select * from join_chat where(user_1 = '24' and user_2 = '26') or(user_1 = '26' and user_2 = '24')result of query+---------+--------+--------+| join_id | user_1 | user_2 |+---------+--------+--------+|      20 | 26     | 24     |+---------+--------+--------+1 row in set (0.01 sec)從結果中,您可以看到連接 ID 返回為 20,但我收到錯誤Trying to get property 'join_id' of non-object請參閱下面的控制器方法 public function get_join_user()    {        $this->load->library('form_validation');        $this->form_validation->set_rules('post_user_id', 'post_user_id', 'trim|required');        $this->form_validation->set_rules('login_user_id', 'login_user_id', 'trim|required');        if ($this->form_validation->run() == false) {            $data["responce"] = false;            $data["error"] = 'field is required';        } else {            $this->load->model("common_model");            $q = $this->db->query("Select * from join_chat where                      (user_1 = '".$this->input->post("login_user_id")."' and user_2 = '".$this->input->post("post_user_id")."') or                      (user_1 = '".$this->input->post("post_user_id")."' and user_2 = '".$this->input->post("login_user_id")."')");            //$row = $q->row();            $row = $q->result();            if (count($row) > 0) {                $data["responce"] = true;                //*****error causing line below***                $data["data"] = $row->join_id;            } 導致錯誤的行$data["data"] = $row->join_id;
查看完整描述

1 回答

?
慕容3067478

TA貢獻1773條經(jīng)驗 獲得超3個贊

再次@Mlike Eps,現(xiàn)在您已經(jīng)將代碼從更改$q->row();$row = $q->result();引用:prev_question?,F(xiàn)在它是一個對象數(shù)組,因此您必須相應地獲取數(shù)據(jù)。

$data["data"]?=?$row[0]->join_id;?//because,?now?array[0]?contains?the?previous?information.

如果萬一它有多個數(shù)組,請使用它foreach()來檢索數(shù)據(jù)。希望對你有幫助。:)


查看完整回答
反對 回復 2023-03-04
  • 1 回答
  • 0 關注
  • 135 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號