Page 1 of 1

Can't add new relationship record (not a permissions issue)

PostPosted: Wed Nov 10, 2010 9:37 am
by bdaley
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.

Re: Can't add new relationship record (not a permissions issue)

PostPosted: Wed Nov 10, 2010 10:13 am
by shannah
Hard to comment with limited info. Can you post relevant table defs, and relationships.ini rules.

Re: Can't add new relationship record (not a permissions issue)

PostPosted: Wed Nov 10, 2010 11:32 am
by bdaley
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` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `poll_question_id` int(10) unsigned NOT NULL COMMENT 'FK - Poll Questions',
  `choice` tinytext NOT NULL COMMENT 'Choice/Option for poll question',
  `votes` int(10) unsigned default '0' COMMENT 'Number of Votes',
  `order` tinyint(3) unsigned default '1' COMMENT 'Order to display',
  PRIMARY KEY  (`id`),
  KEY `poll_question_id` (`poll_question_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Choices/options for the poll questions' AUTO_INCREMENT=12799 ;

-- --------------------------------------------------------

--
-- Table structure for table `poll_questions`
--

CREATE TABLE IF NOT EXISTS `poll_questions` (
  `id` int(11) unsigned NOT NULL auto_increment,
  `date` date default NULL,
  `question` tinytext NOT NULL,
  `answer` tinytext,
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Poll Questions and publish dates' AUTO_INCREMENT=2828 ;

--
-- Constraints for dumped tables
--

--
-- Constraints for table `poll_choices`
--
ALTER TABLE `poll_choices`
  ADD CONSTRAINT `poll_choices_ibfk_1` FOREIGN KEY (`poll_question_id`) REFERENCES `poll_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'"

Re: Can't add new relationship record (not a permissions issue)

PostPosted: Mon Nov 15, 2010 12:31 pm
by bdaley
Ah, figured it out. In relationships.ini...

[Poll Choices]

should have been...

[poll_choices]

Can't believe I missed that. Thanks anyway.