Sorry, your model is still unclear to me:
- could you tell in plain English what you want to accomplish: what is
*a* Module*s*? What do the attributes of *a* Module*s* entity mean:
$module, $status and $modulesConfig? I suspect you are working with a
modules-table, and should therfore define a Module (singular) entity, not
Modules...
- maybe you have the table structure to make it a bit more clear
- how do you call the entities? The PHP in your script.
On Friday, 7 February 2014 21:35:03 UTC+1, Parsifal wrote:
>
> Herman,
> Here is the info you asked me this morning, correcting uppercase
> things etc. it returns expected data the only odd thing is that
> print("blah") in constructor is not working so the this is not called
> but still works! any idea?
>
> <?php
> // Modules.php
> namespace Entities;
> use Doctrine\ORM\Mapping\ClassMetadata;
> use Doctrine\ORM\Mapping\ClassMetadataInfo;
> use Doctrine\Common\Collections\ArrayCollection;
> class Modules {
> private $module;
> private $status;
> private $modulesConfig;
> public function __construct() {
> $this->modulesConfig = new ArrayCollection();
> print("a");
> var_dump($this->modulesConfig);
> }
> public static function loadMetadata(ClassMetadata $metadata) {
> // here goes $metadata->mapField array I did generate with CLI
> // coloumns in this table: module, status
> // join coloumns with that other table: module=>module
> $metadata->mapOneToMany(array( 'fieldName' => 'modulesConfig',
> 'targetEntity' => 'Entities\\ModulesConfig',
> 'mappedBy' => 'modules',
> 'joinColumns' => array( 0 => array(
> 'name' => 'module',
>
> 'referencedColumnName' => 'module',
>
> 'nullable' => true,
>
> 'columnDefinition' => NULL,
> ), )
>
> ));
> }
> }
> ==
> <?php
> // ModulesConfig.php
> namespace Entities;
> use Doctrine\ORM\Mapping\ClassMetadata;
> use Doctrine\ORM\Mapping\ClassMetadataInfo;
> class ModulesConfig {
> private $id;
> private $module;
> private $variable;
> private $value;
> private $modules;
> public static function loadMetadata(ClassMetadata $metadata) {
> // here goes $metadata->mapField array I did generate with CLI
> // coloumn in this table: id, module, variable, value
> // join coloumns with that other table: module=>module
>
> $metadata->mapManyToOne(array( 'fieldName' => 'modules',
> 'targetEntity' => 'Entities\\Modules',
> 'inversedBy' => 'modulesConfig',
> 'joinColumns' => array( 0 => array(
> 'name' => 'module',
>
> 'referencedColumnName' => 'module',
>
> 'nullable' => true,
>
> 'columnDefinition' => NULL,
> ), )
>
> ));
> }
> }
>
>
>
>
> On Fri, Feb 7, 2014 at 1:38 PM, Herman Peeren
> <[email protected]<javascript:>>
> wrote:
> > No idea what you are doing wrong without the code of the 2 entities plus
> the
> > calling code, query etc.
> >
> > On Friday, 7 February 2014 10:34:08 UTC+1, Parsifal wrote:
> >>
> >> In two cases below you described, the first case is the one I actually
> >> want to. And actually it is working fine with expected result. The only
> odd
> >> thing is that print("blah") in constructor doesn't print so I assume
> the
> >> constructor is not working however I am still getting correct result!
> Second
> >> odd thing is that only getArrayResult returns something for this but I
> get
> >> error for getResult. Let's look at second problem later but first let's
> >> check why constructor is not working however I am still getting correct
> >> result?! Any idea?
> >>
> >> 1) In a Module-entity you can have multiple ModuleConfig-entities and
> >> every ModuleConfig-entity only has 1 Module. In this case you'll have a
> >> $moduleConfigs collection in a Module on which a OneToMany-relationship
> is
> >> defined. In a ModuleConfig you then have a $module defined with a
> ManyToOne
> >> relation.
> >> 2) Or: in a Module-entity you can only have 1 ModuleConfig-entity, but
> a
> >> ModuleConfig-entity can be associated with multiple Module-entities.
> In
> >> that case you'll have a $moduleConfig propery in a Module on which a
> >> ManyToOne-relationship is defined. In a ModuleConfig you then have a
> >> $modules collection defined with a OneToMany relation.
> >
> > --
> > You received this message because you are subscribed to the Google
> Groups
> > "doctrine-user" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> an
> > email to [email protected] <javascript:>.
> > To post to this group, send email to
> > [email protected]<javascript:>.
>
> > Visit this group at http://groups.google.com/group/doctrine-user.
> > For more options, visit https://groups.google.com/groups/opt_out.
>
--
You received this message because you are subscribed to the Google Groups
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/groups/opt_out.