Doctrine2 Findby Relationship Object Triggers String Conversion Error

Doctrine2 findBy relationship object triggers string conversion error

Query by relationship is allowed, but you have to pass the Identifier in there. Query by object is not yet supported and will only make it into 2.1.

<?php
// $em instanceof EntityManager, $user instanceof Models\User
$comments = $em->getRepository('Models\Comment')
->findBy(array('user' => $user->getId(), 'public' => true));

Doctrine2 and database-side triggers for denormalized fields

If I understand the question you want to be able to add a new product to a category, persist it then have Category.productCount update itself from the database? You can use

$entityManager->refresh($category);

To reload an entity from the database. I have not done it myself but I would expect that you could use the life cycle functionality to automate this.

But I do kind of wonder if it might not be better to just increment the counter locally without persisting it to the database. Let your trigger do the database operation but, within the request, update the count locally.

Symfony3 - Unrecognized field exception when I want to pull entries based on the value of a Many-to-One relation property

You are missing some ORM definition for $loginid and because of that there is no column loginid in your events table.

I assume you want to have OneToMany or ManyToMany association to ...\Entity\Logins, so you have to define that association according to this: http://doctrine-orm.readthedocs.org/projects/doctrine-orm/en/latest/reference/association-mapping.html

SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for type integer, Doctrine parameter conversion

Dont know how and why but in my twig file that rendering the function :

<p class="media-body pb-3 mb-0  small lh-125 border-bottom border-gray">
<strong class="text-gray-dark">Autheur : </strong>
<a href="{{ path('theme_created_by', {'lastname': theme.user.lastname}) }}">
{{ theme.user.lastname }}
</a>
<br/>
<a href="{{ path( 'theme_show', {'id' : theme.id} ) }}">
<strong>{{ theme.name }}</strong><br/>
</a>

i replace that path line with :

<a href="{{ path('theme_created_by', {'username': theme.user.username}) }}">
{{ theme.user.lastname }}
</a>

changed the paramaters passed in my route too : with username @Route("/themes/by/{username}", name="theme_created_by")
now it works..



Related Topics



Leave a reply



Submit