Php 消息:类stdClass的对象无法在codeigniter中转换为字符串
当我运行下面的代码时Php 消息:类stdClass的对象无法在codeigniter中转换为字符串,php,mysql,database,codeigniter,Php,Mysql,Database,Codeigniter,当我运行下面的代码时 $data = array( 'name' => $this->input->post('name'), 'recipe' => $this->input->post('recipe'), 'category_id' => $category_id, 'recipe_elements' => $t
$data = array(
'name' => $this->input->post('name'),
'recipe' => $this->input->post('recipe'),
'category_id' => $category_id,
'recipe_elements' => $this->input->post('recipe_elements'),
'country' => $this->input->post('country'),
'video' => $this->input->post('video'),
'img' => $img_name,
'vote' => $this->input->post('oy')
);
$this->db->insert('recipes',$data);
我得到这个错误
遇到一个PHP错误
严重程度:4096消息:类stdClass的对象无法转换为字符串 文件名:mysql/mysql_driver.php 电话号码:552 错误号码:1064 您的SQL语法有错误;查看与您的MySQL服务器版本对应的手册,以了解要使用的正确语法
我已经尝试更改输入值,但仍然得到相同的错误。任何帮助都将不胜感激。如何解决此问题?您正在尝试将
对象
转换为字符串
。请确保$category\u id
和$img\u name
不是对象
看看这里,这可能对你有帮助
您可以使用sse:$this->db->last_query()返回上次运行的查询(查询字符串,而不是结果)。从这里您可以很容易地看到您的查询字符串,这也有助于您查找实际错误。感谢您的回复。似乎我在定义$category\u id变量时犯了一个错误。