Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The fixtures are meant for adding some data into your tables, so yes, it's all about updating objects with fixture data.</p> <p>You can add this data anyhow you like as long as you don't violate the constraints that you've specified in your schema. In the case of relations, the referenced value(s) must come before the referencing value(s) or otherwise the relation cannot be declared.</p> <p>This is sometimes the case when uploading complex fixture data from a single fixtures file. What I've noticed that to get around it, load one set of fixtures, then remove that file and load another set of fixtures. In other words, even if the relationships exist in a single fixture file correctly, symfony/doctrine seems unable (at least in some cases) to load them all at once. Think in terms of "sets of data" rather than a complete database.</p> <p>I can't think of a case where a fixture file for one table would update another table. If you need this, I'd suggest writing a little data load script using Doctrine models and their methods.</p> <p><strong>UPDATE:</strong></p> <p>Misunderstood the question originally: I dont think fixtures can be used to actually update an existing record. The "append" option is about appending more data to a table that already contains data. I think it's separate because generally fixtures would only be used on tables that have just been built and that you want to test - not to actually perform update operations on existing data. For this, I would suggest writing a separate script.</p> <p><strong>UPDATE:</strong></p> <p>greg0ire: I used this solution, and it works. First, I connect the <code>command.post_command</code> event to my script:</p> <pre><code>$this-&gt;dispatcher-&gt;connect('command.post_command', array('MmcCmsDoctrineDataLoadTaskListener', 'fixCircularReferences')); </code></pre> <p>Then, in my script I check that the task is 'data-load', and make the missing links to close the circle.</p> <pre><code>public static function fixCircularReferences(sfEvent $event) { /* @var $task sfTask */ $task = $event-&gt;getSubject(); if ($task-&gt;getName() == 'data-load') { // make the links here } } </code></pre> <p><strong>WARNING</strong> : Do not attempt to create the circular in the fixtures, but deliberately let one relation empty, otherwise you will encounter strange problems.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload