Doctrine Project

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What’s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
Doctrine 1
  • Doctrine 1
  • DC-642

import/export Array

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Open Open
  • Priority: Minor Minor
  • Resolution: Unresolved
  • Affects Version/s: 1.2.2
  • Fix Version/s: None
  • Component/s: Record
  • Labels:
    None

Description

Retreive an object "A" and some related object from the database.
Export it into an array.
Create an other instance of "A" and import array from the previous exported array.
Just save the new instance.

Doctrine re-create the object into DB. If you have some integrity constraint like primary key, you will see an SQL error.

In the following example with "video" and "tags", Doctrine want to re-create the video and tag objects.
The reason is that the exported array doesn't include the "_identifier" key.

In my mind, the problem show and other problem, that we are force to use the "identifier" or assignIdentifier on the Model domain object to work with an existing object.
Doctrine know the Primary key of all the model domain objects. Why Doctrine doesn't use the assignIdentifier when the user change the PK of the Model domain object... In this case, assignIdentifier could be into a private scope.

$oVideo = Doctrine_Query::create ()
->select ("video., tags.")
->from ("Model_Video video")
->leftJoin ("video.tags tags")
->where ("video.id_show = 500")
->fetchOne ();
$oVideoArray = $oVideo->toArray();
$oVideo->save ();

$oVideoBis = new Model_Video ();
$oVideoBis->fromArray($oVideoArray, true);
$oVideoArrayBis = $oVideo->toArray();
$oVideoBis->save ();

Activity

  • All
  • Comments
  • History
  • Activity
  • Source
There are no comments yet on this issue.

People

  • Assignee:
    Jonathan H. Wage
    Reporter:
    Thomas Tourlourat - Armetiz
Vote (0)
Watch (0)

Dates

  • Created:
    22/Apr/10 8:04 AM
    Updated:
    22/Apr/10 8:04 AM
  • Atlassian JIRA (v5.2.7#850-sha1:b2af0c8)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Doctrine Project. Try JIRA - bug tracking software for your team.