diff --git a/lib/Doctrine/Resource/Client.php b/lib/Doctrine/Resource/Client.php index c2ce7de16..e76fde4cd 100644 --- a/lib/Doctrine/Resource/Client.php +++ b/lib/Doctrine/Resource/Client.php @@ -82,7 +82,7 @@ class Doctrine_Resource_Client extends Doctrine_Resource $import = new Doctrine_Import_Schema(); $schema = $import->buildSchema($path, $this->getConfig()->get('format')); - if (file_exists($classesPath)) { + if (!file_exists($classesPath)) { $build = " $details) { $build .= "class " . $className . " extends Doctrine_Resource_Record { protected \$_model = '".$className."'; public function __construct(\$loadRelations = true) { parent::__construct(\$this->_model, \$loadRelations); } }\n"; diff --git a/lib/Doctrine/Resource/Table.php b/lib/Doctrine/Resource/Table.php index 5d9380e7a..4f4775735 100644 --- a/lib/Doctrine/Resource/Table.php +++ b/lib/Doctrine/Resource/Table.php @@ -48,7 +48,6 @@ class Doctrine_Resource_Table if (isset($schema['relations'][$model]) && $schema['relations'][$model]) { $this->_schema['relations'] = $schema['relations'][$model]; - $this->_schema['schema']['relations'] = $this->_schema['relations']; } } diff --git a/playground/index.php b/playground/index.php index 7f2629661..f594357d3 100644 --- a/playground/index.php +++ b/playground/index.php @@ -16,15 +16,17 @@ if ($action == 'server') { } else { $url = 'http://localhost/~jwage/doctrine_trunk/playground/index.php?action=server'; - $config = array(); + $config = array('format' => 'yml'); // Instantiate a new client $client = Doctrine_Resource_Client::getInstance($url, $config); + /* $query = new Doctrine_Resource_Query(); $users = $query->from('User u, u.Group g')->execute(); print_r($users->toArray(true)); + */ /* $group = new Group(); diff --git a/tests/schema.xml b/tests/schema.xml index 8c1c1cb21..b55374623 100755 --- a/tests/schema.xml +++ b/tests/schema.xml @@ -1,2 +1,2 @@ -accountAccountinteger2011idinteger2147483647entity_idinteger2147483647amount
addressAddressinteger2011id
string200address
EntityAddressaddress_iduser_idmanyidaddress_idmany
albumAlbuminteger2011idinteger2147483647user_idstring20nameidalbum_idmanyuser_ididoneassignmentAssignmentinteger2011idinteger2147483647task_idinteger2147483647resource_idresource_ididonetask_ididonedescriptionDescriptioninteger2011idstring3000descriptionstring32file_md5elementElementinteger2011idstring100nameinteger2147483647parent_idElementidparent_idmanyElementparent_ididoneemailEmailinteger2011id
11string150address
entityEntity11integer20idstring50name1string20loginnamestring16passwordinteger1typeinteger11createdinteger11updatedinteger2147483647email_idemail_ididoneidentity_idmanyidentity_idoneEntityReferenceentity1entity2manyidentity1manyentity_addressEntityAddress1integer2147483647user_id1integer2147483647address_id
address_ididone
user_ididone
entity_referenceEntityReference1integer2147483647entity11integer2147483647entity2entity1idoneentity1idoneentity1idoneerrorErrorstring200messageinteger11code1string32file_md5file_md5file_md5oneentityGroup11integer20idstring50name1string20loginnamestring16passwordinteger1typeinteger11createdinteger11updatedinteger2147483647email_idemail_ididoneidentity_idmanyidentity_idoneEntityReferenceentity1entity2manyGroupusergroup_iduser_idmanyidentity1manyidgroup_idmanygroupuserGroupuserinteger2011idinteger2147483647addedinteger2147483647group_idinteger2147483647user_idgroup_ididoneuser_ididonephonenumberPhonenumberinteger2011idstring20phonenumberinteger2147483647entity_identity_ididoneentity_ididoneentity_ididoneresource_referenceResourceReferenceinteger2011idinteger2147483647type_idinteger2147483647resource_idresource_ididoneresourcetype_ididoneresourceResourceinteger2011idstring100nameAssignmentTaskresource_idtask_idmanyResourceReferenceResourceTyperesource_idtype_idmanyidresource_idmanyidresource_idmanyresource_typeResourceTypeinteger2011idstring100typeResourceReferenceResourceresourcetype_idresource_idmanyidresourcetype_idmanysongSonginteger2011idinteger2147483647album_idstring20genre<type>string</type><length>30</length><name>title</name>album_ididonetaskTaskinteger2011idstring100nameinteger2147483647parent_idAssignmentResourcetask_idresource_idmanyTaskidparent_idmanyidtask_idmanyentityUser11integer20idstring50name1string20loginnamestring16passwordinteger1typeinteger11createdinteger11updatedinteger2147483647email_idemail_ididoneidentity_idmanyidentity_idoneEntityReferenceentity1entity2many
EntityAddressuser_idaddress_idmany
iduser_idmanyiduser_idmanyGroupuseruser_idgroup_idmanyidentity1manyiduser_idmanyiduser_idmany
+accountAccountinteger2011idinteger2147483647entity_idinteger2147483647amount
addressAddressinteger2011id
string200address
EntityAddressaddress_iduser_idmanyidaddress_idmany
albumAlbuminteger2011idinteger2147483647user_idstring20nameidalbum_idmanyuser_ididoneassignmentAssignmentinteger2011idinteger2147483647task_idinteger2147483647resource_idresource_ididonetask_ididonedescriptionDescriptioninteger2011idstring3000descriptionstring32file_md5elementElementinteger2011idstring100nameinteger2147483647parent_idElementidparent_idmanyElementparent_ididoneemailEmailinteger2011id
11string150address
entityEntity11integer20idstring50name1string20loginnamestring16passwordinteger1typeinteger11createdinteger11updatedinteger2147483647email_idemail_ididoneidentity_idmanyidentity_idoneEntityReferenceentity1entity2manyidentity1manyentity_addressEntityAddress1integer2147483647user_id1integer2147483647address_id
address_ididone
user_ididone
entity_referenceEntityReference1integer2147483647entity11integer2147483647entity2entity1idoneentity1idoneentity1idoneerrorErrorstring200messageinteger11code1string32file_md5file_md5file_md5oneentityGroup11integer20idstring50name1string20loginnamestring16passwordinteger1typeinteger11createdinteger11updatedinteger2147483647email_idemail_ididoneidentity_idmanyidentity_idoneEntityReferenceentity1entity2manyGroupusergroup_iduser_idmanyidentity1manyidgroup_idmanygroupuserGroupuserinteger2011idinteger2147483647addedinteger2147483647group_idinteger2147483647user_idgroup_ididoneuser_ididonephonenumberPhonenumberinteger2011idstring20phonenumberinteger2147483647entity_identity_ididoneentity_ididoneentity_ididoneresource_referenceResourceReferenceinteger2011idinteger2147483647type_idinteger2147483647resource_idresource_ididoneresourcetype_ididoneresourceResourceinteger2011idstring100nameAssignmentTaskresource_idtask_idmanyResourceReferenceResourceTyperesource_idtype_idmanyidresource_idmanyidresource_idmanyresource_typeResourceTypeinteger2011idstring100typeResourceReferenceResourceresourcetype_idresource_idmanyidresourcetype_idmanysongSonginteger2011idinteger2147483647album_idstring20genre<type>string</type><length>30</length><name>title</name>album_ididonetaskTaskinteger2011idstring100nameinteger2147483647parent_idAssignmentResourcetask_idresource_idmanyTaskidparent_idmanyidtask_idmanyentityUser11integer20idstring50name1string20loginnamestring16passwordinteger1typeinteger11createdinteger11updatedinteger2147483647email_idemail_ididoneidentity_idmanyidentity_idoneEntityReferenceentity1entity2many
EntityAddressuser_idaddress_idmany
EntityAddressAddressuser_idaddress_idmanyiduser_idmanyiduser_idmanyGroupuseruser_idgroup_idmanyidentity1manyiduser_idmanyiduser_idmany
diff --git a/tests/schema.yml b/tests/schema.yml index 0900824a0..3bd28f62e 100644 --- a/tests/schema.yml +++ b/tests/schema.yml @@ -603,6 +603,12 @@ User: local: user_id foreign: address_id type: many + Addresses: + refClass: EntityAddress + class: Address + local: user_id + foreign: address_id + type: many Album: local: id foreign: user_id