Can’t add new relationship record (not a permissions issue)
Archived from the Xataface Users forum.
bdaley — Wed Nov 10, 2010 9:37 am
I have two tables for a small poll question app that I’ve written:
poll_questions
poll_choices
The relationship is one-to-many, as in one poll question can have many choices. I *believe* that I have configured the relationship properly. I am able to view AND edit existing poll choices, as they relate to a particular poll question. The problem arises when I attempt to add a new poll choice. After submitting the “add new poll choices record” form, the Xataface app returns the very same form again, only blank and without an error or success message.
Using firebug, I am able to see that all of the fields are being POSTed to Xataface. However, when I view the MySQL queries that are being run, there are no attempts to insert the new record. I am using the following PHP code to view the queries:
- Code: Select all
define('DATAFACE_DEBUG_DB',true);
Please let me know if you need any more information. Much thanks.
shannah — Wed Nov 10, 2010 10:13 am
Hard to comment with limited info. Can you post relevant table defs, and relationships.ini rules.
bdaley — Wed Nov 10, 2010 11:32 am
Thanks, I figured as much. I was just hoping for a quick solution to a common problem. Apparently not the case.
Anywho, here is the DB structure:
- Code: Select all
- `` CREATE TABLE IF NOT EXISTS
poll_choices(
idint(10) unsigned NOT NULL auto_increment,
poll_question_idint(10) unsigned NOT NULL COMMENT ‘FK - Poll Questions’,
choicetinytext NOT NULL COMMENT ‘Choice/Option for poll question’,
votesint(10) unsigned default ‘0’ COMMENT ‘Number of Votes’,
ordertinyint(3) unsigned default ‘1’ COMMENT ‘Order to display’,
PRIMARY KEY (id),
KEYpoll_question_id(poll_question_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT=’Choices/options for the poll questions’ AUTO_INCREMENT=12799 ;
–
– Table structure for tablepoll_questions
–CREATE TABLE IF NOT EXISTS
poll_questions(
idint(11) unsigned NOT NULL auto_increment,
datedate default NULL,
questiontinytext NOT NULL,
answertinytext,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT=’Poll Questions and publish dates’ AUTO_INCREMENT=2828 ;–
– Constraints for dumped tables
––
– Constraints for tablepoll_choices
–
ALTER TABLEpoll_choices
ADD CONSTRAINTpoll_choices_ibfk_1FOREIGN KEY (poll_question_id) REFERENCESpoll_questions(id) ON DELETE CASCADE; ``
Here is my relationships.ini definition for the poll_questions table:
- Code: Select all
[Poll Choices] __sql__ = "select * from poll_choices where poll_question_id='$id'"
bdaley — Mon Nov 15, 2010 12:31 pm
Ah, figured it out. In relationships.ini…
[Poll Choices]
should have been…
[poll_choices]
Can’t believe I missed that. Thanks anyway.