I need to move all playa relationships to EE relationships.

What is the best way to do this? I have not been able to find anything online explaining a process or how to approach this.

All I know is I don't want to just change the field type.

  • 1
    Do you have any Playa relationships which were made inside of Matrix fields? – Derek Hogue Apr 24 '14 at 12:10
  • @DerekHogue No, the Playa relationships are separate. – zizther Apr 24 '14 at 17:08

It's a pretty simple operation, since they are stored very similarly.

First, backup your database. Then, run this code in a PHP-enabled template:


$playa = ee()->db->query("SELECT * FROM exp_playa_relationships");
foreach($playa->result_array() as $rel)
    $data = array(
        'parent_id' => $rel['parent_entry_id'],
        'child_id' => $rel['child_entry_id'],
        'field_id' => $rel['parent_field_id'],
        'order' => $rel['rel_order']
        ee()->db->insert_string('exp_relationships', $data)


Then, change your Playa fields to Relationships fields. Done.

| improve this answer | |
  • Much simpler than I would have thought. Thanks @DerekHogue – zizther Apr 25 '14 at 20:21
  • Thanks from me also @derek-hogue for this simple solution! Question: Does this also work for EE3? – BNetz Jul 17 '16 at 10:57
  • 1
    Yup, it should. – Derek Hogue Jul 18 '16 at 0:54
  • I just tried it with an EE2-install, and it works perfectly - thanks again! – BNetz Jul 18 '16 at 21:03
  • 1
    This PHP script worked perfectly with EE 2.11.9. Had a channel with a Playa channel field associated with a Zoo Visitor member. The channel had about 2,500 entries. After using this PHP script, loading a single channel entry on the EE admin panel went from being 50 seconds to 2 seconds. – Caleb Faruki Nov 13 '17 at 2:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.