选择查询返回一个“数组”而不是一个值。因为该插入语句引发错误。
这是我的保存方法,我在其中获取 id 的值并在插入语句中使用该 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;
}
}