We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

When posting 4 entries via API only the last relationship is 'remembered'

Development and Programming

Bas van Ginkel's avatar
Bas van Ginkel
9 posts
15 years ago
Bas van Ginkel's avatar Bas van Ginkel

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?????

       
Ingmar's avatar
Ingmar
29,245 posts
15 years ago
Ingmar's avatar Ingmar

Moving to “Development and Programming”, thanks.

       
Andrew Weaver's avatar
Andrew Weaver
206 posts
15 years ago
Andrew Weaver's avatar Andrew Weaver

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

       
Bas van Ginkel's avatar
Bas van Ginkel
9 posts
15 years ago
Bas van Ginkel's avatar Bas van Ginkel

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

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.