Update child table.

3 views
Skip to first unread message

rnrstar

unread,
Aug 27, 2010, 8:12:20 PM8/27/10
to RISE
I have three tables, IncommingTexts, Notes, and Users. I have a 1 to
0..n relation from IncommingTexts to Notes and a 1 to 0...n relation
from Users to Notes.

I'm trying to create a new note record using the php db methods
generated by RISE. My call looks something like:

$notesObj = new spDBINotes($ConnectionResource);
$notesObj->NewNotes($UsersID, $IncommingTextsID, $txtNote, $datAdded);

I get the following error:

Fatal error: Uncaught exception 'Exception' with message 'INSERT INTO
"t_sp_u_Notes"("c_u_txtNote", "c_u_datAdded", "c_r_IncommingTexts",
"c_r_Users") VALUES (?, ?, ?, ?): Cannot add or update a child row: a
foreign key constraint fails ("southpoint/t_sp_u_Notes", CONSTRAINT
"fk_sp_u_Notes_r_IncommingTexts" FOREIGN KEY ("c_r_IncommingTexts")
REFERENCES "t_sp_u_IncommingTexts" ("c_id"))' in /home/leaddomain/
public_html/southpoint/sp.DB.INotes.php:26 Stack trace: #0 /home/
leaddomain/public_html/southpoint/saveNewNote.php(56): spDBINotes-
>NewNotes('1', '2', 'test', '2010-08-27 17:5...') #1 {main} thrown in /
home/leaddomain/public_html/southpoint/sp.DB.INotes.php on line 26

Line 25-26 is...

if(!$mysqli_stmt->execute())
throw new Exception($sql_stmt.': '.$mysqli_stmt->error);

Using MyPHPAdmin I'm able to manually insert a row into the Notes
table without problem.

Any ideas?

Thanks in advance.

HOlsen

unread,
Aug 29, 2010, 2:51:12 PM8/29/10
to RISE
The error message indicates that there is no IncomingTexts in the
database with primary key (c_id) = 2.

Best regards,
RISE to Bloome Software

rnrstar

unread,
Aug 30, 2010, 3:04:14 AM8/30/10
to RISE
There is a record in IncommingTexts that has a c_id = 2. As I pointed
out I can add a new record to INotes using MyPHPAdmin's SQL query
which tells me that the problem is not in the way the database is
configured or because of a missing parent record.

HOlsen

unread,
Aug 31, 2010, 4:36:22 AM8/31/10
to RISE
You have discovered a pretty serious bug. We will fix it immediately.
I will let you know when there is a new version of the code generator
available.

Best regards,
RISE to Bloome Software

> > > Thanks in advance.- Hide quoted text -
>
> - Show quoted text -

HOlsen

unread,
Aug 31, 2010, 12:12:04 PM8/31/10
to RISE
A new version of the code generator is now available. Execute the PHP
for MySQL code generaor from the start menu and select Check for
updated in the help menu.

Best regards,
RISE to Bloome Software


> > - Show quoted text -- Hide quoted text -

rnrstar

unread,
Aug 31, 2010, 8:35:29 PM8/31/10
to RISE
That did it. Thank you so much for your prompt response.
Reply all
Reply to author
Forward
0 new messages