Hi Guys,
hope someone can help me. I’m having a weird problem. I’m doing the following.
PHP script executes the following code 4 times with different $data
if ($this->EE->api_channel_entries->submit_new_entry(3, $data) === FALSE) {
show_error('An Error Occurred Creating the Entry');
} else {
print "<H1>RECORD ENTERED</H1>";
}The 4 entries are created. In the $data there is a field to create a relationship. The value in this field is the entry_id for the target record.
After the script has run 4 entries are created with the correct value’s in place. Only the relationships aren’t created properly. Only the last record entered has a functional relationship. The others display…
{REL[459][actie_voertuig]c02lhNRPREL}
{REL[460][actie_voertuig]c02lhNRPREL}
{REL[461][actie_voertuig]c02lhNRPREL}The weird thing is that the database table exp_relationships is only one records larger but that the REL_ID field (that auto_increments) is 4 value’s larger.
It almost looks like that the relationships with the first the records got destroyed.
Does anybody have a clue what’s going on here? PLEASEEE?????
Hi Bas,
What version of EE are you using? There used to be a bug in the API:
Calling submit_new_entry multiple times to create entries with relationships fails to make relation
I added the line:
$this->EE->api_channel_entries->entry_id = 0;to the loop which fixed it for me.
Andrew
Hi Andrew,
thanks that seemed to solve the problem. I thought i had updated this installation to latest but now i see i’m running an older version.
And that goes to show that when having EE problems the first thing you have to check that your installation is up to date.
With kind regard, Bas van Ginkel
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.