![]() |
Update) Why does a simple insert fail? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: Update) Why does a simple insert fail? (/showthread.php?tid=81575) |
Update) Why does a simple insert fail? - yoshi - 03-19-2022 ## overview The `m_certification` table is for all credentials. The `certification` table is managing certification in the school use. Each table relationship is 1:1. The `m_certification` table has school_id for use. using to get school information. But my php code failed for insert. Why does a simple insert fail? https://drive.google.com/file/d/1GCiEKXthXqXUdoIn_i5zz_Wqp1XJ-DaL/view?usp=drivesdk ## detail Now I'm trying to make a record in the `certification` table then I enter the record by hand, it can be inserted correctly. https://drive.google.com/file/d/1ipPO9vQ_4LqPKJv-Xlzaga6fY9Q1imkt/view?usp=drivesdk PHP Code: -- ci4db.certification definition PHP Code: INSERT INTO ci4db.certification PHP Code: public function editPost(): void ## additional report Looking at the stack trace, there is sloppy SQL. Despite being converted from Entity, SQL does not contain foreign key information. This certainly causes a foreign key violation. https://drive.google.com/file/d/1eZQB0Hyj_ByLOhmNYff8HeSGF9z6aUoD/view?usp=drivesdk Maybe Codeigniter shouldn't use foreign keys? RE: Update) Why does a simple insert fail? - iRedds - 03-20-2022 Are all fields specified in CertificationModel::$allowedFields? RE: Why does a simple insert fail? - yoshi - 03-20-2022 (03-20-2022, 05:41 PM)iRedds Wrote: Are all fields specified in CertificationModel::$allowedFields? Thank you as always. I was able to resolve the SQL execution. I thought that foreign keys were not covered by "permitted items". |