以下のSQLコードをテストして正常に使用し、データベースにデータを入力しました。
INSERT INTO hraps (id, firstname, lastname, gender, year_of_1st_rappel, count_offset_proficiency, count_offset_operational, spotter) values(111111, 'World', 'Hello', 'Male', '2007', '1', '2', '0')
今、私はそれを次のようにPHPに統合しようとしています:
$query = "INSERT INTO hraps (firstname, lastname, gender, year_of_1st_rappel, count_offset_proficiency, count_offset_operational, spotter) "
."values('".$this->firstname."','".$this->lastname."','".$this->gender."','".$this->year_of_1st_rappel."',".$this->count_offset_proficiency.",".$this->count_offset_operational.",".$this->spotter.") returning id into :id";
$dbid = "";
$binds = array();
$binds[] = array("name" => ":id", "value" => &$dbid, "length" => 128);
//echo $query;
$result = mydb::cxn()->query($query, $binds);
$this->id = $dbid;
しかし、何も挿入されず、エラーは発生しません。唯一の違いは、これではidを$ dbidとして定義しており、クエリの「値」セクションにハードコーディングする前に定義していることです。
誰かがこのコードがうまく機能しない理由を指摘できますか?ありがとうございました。