我是CodeIgniter的新手,我試過閱讀CI的文檔,但仍然無法解決我的問題,也許有人在這裏可以幫助解決我的問題。這裏是我的代碼:錯誤:CI_DB_mysql_result類的對象無法轉換爲字符串
在我的控制器
class Registration extends CI_Controller{
function __construct(){
parent::__construct();
$this->load->model('registration_model','rmod');
}
function ambil() {
$gender = $this->input->post('kelamin');
$tinggi = $this->input->post('height');
$berat = $this->input->post('weight');
$weight = $this->rmod->ambilBeratPria($tinggi);
echo $weight;
}
在我的模型
function ambilBeratPria($tinggi) {
$this->db->select('berat')->from('pria')->where('tinggi',$tinggi);
$query = $this->db->get();
return $query;
}
我想我的模型查詢的結果,但我得到這樣的錯誤:
Message: Object of class CI_DB_mysql_result could not be converted to string
也許這裏有人可以幫助解決我的問題? 謝謝。
感謝您的回答^^ 我試過這種方式。返回不是查詢的結果,但只是一個「數組」文本出來時,我跑的代碼... 也許我錯了控制器代碼? – 2013-04-10 17:02:12
請看我編輯的答案。 – 2013-04-10 17:05:48
當我嘗試,我有這樣的錯誤「試圖獲得非對象的屬性」 也許我的代碼仍然是錯誤的? ^^ – 2013-04-10 17:15:38