select query返回一个'array'而不是value.Because因为insert语句引发了错误。
这是我的保存方法,我获取id的值并在insert语句中使用该id
function save()
{
if(isset( $_POST['description']) && isset( $_POST['age']) && isset( $_POST['country']) && isset( $_POST['state'])) {
$descrip = $_POST['description'];
$ag = $_POST['age'];
$country = $_POST['country'];
$state= $_POST['state'];
}
$id = $this->db->query("SELECT table_tbldescription.Id FROM table_tbldescription Left join table_tblpricetype1 as a on a.Id=table_tbldescription.Id where table_tbldescription.Description = '". $descrip. "'");
$arr = $id->result();
//$arra = $sql->result();
if(!empty($arr)) {
$sql = $this->db->query("Insert into table_tblpricetype1 (Id,age,country ,state) VALUES( '". $arr. "' ,'". $age. "' , '". $country. "','". $state. "')");
}
else{
return false;
}
}
答案 0 :(得分:0)
尝试使用:
$arr = $id->result()[0];