我是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