0

選択クエリは、値の代わりに「配列」を返しています。その挿入ステートメントがエラーをスローしているためです。

これは、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;
              }
         }
4

1 に答える 1

0

使用してみてください:

$arr = $id->result()[0];
于 2012-06-01T05:58:35.113 に答える