2708 search results for Doctrine

... will cause extra queries to be made, but this can avoid that with the strategy shown here: https://knpuniversity.com/screencast/doctrine-queries/joins-reduce-queries 3) Make multiple queries - query for the User object, and then its applications, etc. Always a good fallback option if things get tricky. Cheers!
weaverryan
weaverryan
Read Full Comment
... what exactly relations do you need by explaining each possible relations. Btw, we're talking about this command here: https://knpuniversity.com/screencast/doctrine-relations/many-to-many I hope this helps! Cheers!
101 lines | src/Entity/User.php
// ... lines 1 - 2
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\UserInterface;
/**
* @ORM\Entity(repositoryClass="App\Repository\UserRepository")
*/
class User implements UserInterface
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=180, unique=true)
*/
private $email;
/**
* @ORM\Column(type="json")
*/
private $roles = [];
public function getId(): ?int
{
return $this->id;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): self
{
$this->email = $email;
return $this;
}
/**
* A visual identifier that represents this user.
*
* @see UserInterface
*/
public function getUsername(): string
{
return (string) $this->email;
}
/**
* @see UserInterface
*/
public function getRoles(): array
{
$roles = $this->roles;
// guarantee every user at least has ROLE_USER
$roles[] = 'ROLE_USER';
return array_unique($roles);
}
public function setRoles(array $roles): self
{
$this->roles = $roles;
return $this;
}
/**
* @see UserInterface
*/
public function getPassword()
{
// not needed for apps that do not check user passwords
}
/**
* @see UserInterface
*/
public function getSalt()
{
// not needed for apps that do not check user passwords
}
/**
* @see UserInterface
*/
public function eraseCredentials()
{
// If you store any temporary, sensitive data on the user, clear it here
// $this->plainPassword = null;
}
}
See Code Block in Script
Trying to update operation with many to many: I have two entites PromoCode Entity ``` namespace App\Entity; use App\Repository\PromoCodeRepository; use Doctrine\Common\Collections\ArrayCollection; use Doctrine ...
Dhrubajyoti D.
Dhrubajyoti D.
Read Full Comment
... for the same song twice, then i will have some redundancy in my database, which i am aiming to avoid. So my approach will be the following: Extending the "join tables". As I don't see by now that doctrine gives me the ...
... installs, 0 updates, 0 removals - Installing symfony/flex (v1.12.2): Extracting archive - Installing doctrine/lexer (1.2.1): Extracting archive - Installing psr/container (1.0.0): Extracting archive - Installing ...
Antonio P.
Antonio P.
Read Full Comment
... good, I'd like to keep all the "setting things not writable by the user"-logic in the same place if you know what I mean. One way would be to use stof/doctrine-extensions-bundle, but I don't like this bundle very much ...
Tobias I.
Tobias I.
Read Full Comment
... object *before* it was modified by the request). And (B) you will probably need a custom Doctrine extension (https://api-platform.com/docs/core/extensions/#custom-doctrine-orm-extension) so that you can also *filter* the ...
weaverryan
weaverryan
Read Full Comment
Hey Olivier Mellinger! Sorry for the slow reply - nice to chat with you! > I come across an "issue" or may be I don't understand one mechanism: how does Doctrine know what items from your collection are new or updates ...
weaverryan
weaverryan
Read Full Comment
... \ApiSubresource; use Doctrine\ORM\Mapping as ORM; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; /** * @ApiResource() * @UniqueEntity(fields={"maxId"}) * * @ORM\Table(name="relation") * @ORM\Entity() */ class ...
Blog
2023 A Year in Tutorials Open Source

... Days Watched Symfony 538 ApiPlatform 239 Symfony Fundamentals 185 Symfony & Doctrine 155 EasyAdminBundle ...

... findAny() method, a method not found warning Make sense of course, because getRepository() method has "@return \Doctrine\Common\Persistence\ObjectRepository" where there're no any findAny() method, this method is from custom ...
... services In this case, when Doctrine creates your cache service, it makes it private. And, there's not actually any way to change that... but that's ok! What you need to *change* is how you *fetch* the service. Instead of ...
weaverryan
weaverryan
Read Full Comment
... ``` namespace App\Security; use App\Entity\Member; use App\Form\LoginForm; use Doctrine\Common\Persistence\ObjectManager; use Symfony\Component\Form\FormFactoryInterface; use Symfony\Component\HttpFoundation\Request; use ...
Louis-Marie Matthews
Louis-Marie Matthews
Read Full Comment
... even those little syntactic advantages have drawbacks, see Doctrine shortcuts etc. With the new approach, now we need to explain why the application code/resources "work" differently from bundles. We need to explain ...
meandmymonkey
meandmymonkey
Read Full Comment
... do a simple, normal query through Doctrine for just the PsMessage entities that match these ids. It's a nice way to get most of the performance benefit of a raw SQL query in a complex situation, but still get back ...
weaverryan
weaverryan
Read Full Comment
... tool that you should use. However, for better or worse, Doctrine won't help you with your views - it has almost nothing built into it for working with them. That's not a problem - it just means that you will need to do ...
weaverryan
weaverryan
Read Full Comment
... "bound" to the entity-class (this is the job of doctrine), I simply can pass the other form to the first one like in my ArtistFormType... In the builder I simply can do the following: ->add('address', AddressFormType::class ...
Yo Max! Yea, amazingly, under many (but not all) situations, Doctrine DOES turn notice the renaming and turn it into a CHANGE query. That's pretty cool :). So, you're 100% right about doctrine:migrations:diff and ...
weaverryan
weaverryan
Read Full Comment
... are several valid ways to do that) 2) Install your composer vendors ``` composer install --optimize-autoloader ``` (the extra flag here is a small performance boost) 3) Clear your cache and maybe execute doctrine ...
weaverryan
weaverryan
Read Full Comment