From 4275c6656f12cd7ea090de920ba6184f44f0d1cc Mon Sep 17 00:00:00 2001 From: "Jonathan.Wage" Date: Fri, 7 Dec 2007 22:48:28 +0000 Subject: [PATCH] Removed exec() call and updated docs for data fixtures. --- lib/Doctrine.php | 2 +- manual/docs/en/data-fixtures.txt | 130 +++++++++++++------------------ 2 files changed, 53 insertions(+), 79 deletions(-) diff --git a/lib/Doctrine.php b/lib/Doctrine.php index 567fc2922..c592a294e 100644 --- a/lib/Doctrine.php +++ b/lib/Doctrine.php @@ -683,7 +683,7 @@ final class Doctrine $result = $export->exportSchema($yamlPath, 'yml', $directory); - exec('rm -rf ' . $directory); + Doctrine_Lib::removeDirectories($directory); return $result; } diff --git a/manual/docs/en/data-fixtures.txt b/manual/docs/en/data-fixtures.txt index 4825268fd..d8d217802 100644 --- a/manual/docs/en/data-fixtures.txt +++ b/manual/docs/en/data-fixtures.txt @@ -27,9 +27,7 @@ $path = array('data.yml', 'data2.yml', 'more.yml'); // Array of yml file paths $path = array('directory1', 'directory2', 'directory3'); // Array of directories which contain yml files. It will find all files with an extension of .yml // Specify the format of the data you are importing -$format = 'yml'; -$format = 'xml'; -$format = 'csv'; +$format = 'yml'; // xml, yml, json $models = array('User', 'Phonenumber'); // you can optionally specify an array of the models you wish to import the data for, by default it loads data for all the available loaded models and the data that exists @@ -53,84 +51,60 @@ $data->importDummyData($numRecords, $models); You can write your fixtures files manually and load them in to your applications. Below is a sample data.yml fixtures file. You can also split your data fixtures file up in to multiple files. Doctrine will read all fixtures files and parse them, then load all data. -Please see the [doc schema-files :index :name] for the sample models/schema for these example fixtures. +Imagine a schema with the following relationships: + + +Resource hasMany Tag as Tags +Resource hasOne ResourceType as Type +ResourceType hasMany Resource as Resources +Tag hasMany Resource as Resources + --- -Adult: - Adult_1: - name: Parent 1 - Contact: Contact_1 -Car: - Car_1: - name: Chevorlet Trailblazer - Car_2: - name: Chevorlet Blazer - Car_3: - name: Buick -Child: - Child_1: - name: Child 1 - Adult: Adult_1 -Contact: - Contact_1: - name: Jonathan H. Wage - Contact_3: - name: Daniel Adams - Contact_4: - name: Robert Adams -Dog: - Dog_1: - name: Sam - User: User_1 - Dog_2: - name: Dixie - User: User_2 - Dog_3: - name: Chief - User: User_3 -SelfReference: - SelfReference_1: - User1: User_1 - User2: User_2 - name: Self Reference 1 - SelfReference1: SelfReference_2 - SelfReference2: SelfReference_3 - SelfReference_2: - User1: User_2 - User2: User_1 - name: Self Reference 2 - SelfReference1: SelfReference_1 - SelfReference2: SelfReference_1 - SelfReference_3: - User1: User_2 - User2: User_1 - name: Self Reference 3 - SelfReference1: SelfReference_3 - SelfReference2: SelfReference_3 -User: - User_1: - username: jwage - hair_color: light brown - Contact: Contact_1 - User_2: - username: dadams - hair_color: dark brown - Contact: Contact_3 - User_3: - username: radams - hair_color: light brown - Contact: Contact_4 -UserCar: - UserCar_1: - User: User_1 - Car: Car_1 - UserCar_2: - User: User_2 - Car: Car_2 - UserCar_3: - User: User_3 - Car: Car_3 +Resource: + Resource_1: + name: Doctrine Video Tutorial + Type: Video + Tags: [tutorial, doctrine, help] + Resource_2: + name: Doctrine Cheat Sheet + Type: Image + Tags: [tutorial, cheat, help] + +ResourceType: + Video: + name: Video + Image: + name: Image + +Tag: + tutorial: + name: tutorial + doctrine: + name: doctrine + help: + name: help + cheat: + name: cheat + + +You could optionally specify the Resources each tag is related to instead of specifying the Tags a Resource has. + + +Tag: + tutorial: + name: tutorial + Resources: [Resource_1, Resource_2] + doctrine: + name: doctrine + Resources: [Resource_1] + help: + name: help + Resources: [Resource_1, Resource_2] + cheat: + name: cheat + Resources: [Resource_1] Here is how you would write code to load the data from that data.yml file