2708 search results for Doctrine

... MySQL, but still have not used it extensively), but my guess is that yes, this is probably do to a difference in the databases themselves. In the case of the query builder, usually Doctrine abstracts things away and makes ...
weaverryan
weaverryan
Read Full Comment
... respectivelly: Uncaught PHP Exception Doctrine\DBAL\Exception\NotNullConstraintViolationException: "An exception occurred while executing 'INSERT INTO programmer (nickname, avatar_number, tag_line, power_level, user_id) VALUES (?, ?, ?, ?, ?)' with params ["ObjectOrienter", 5, " ...
Diaconescu
Diaconescu
Read Full Comment
... andWhere on its key property. Here is some info about those types of queries: https://symfonycasts.com/screencast/doctrine-queries/joins Let me know if that helps! Cheers!
weaverryan
weaverryan
Read Full Comment
Hey Ad F.! Ah! I think the problem isn't the paginator, but Doctrine (well really SensioFrameworkExtraBundle) is unable to figure out how to query for your "Advert" entity. My guess is that you have a route that ...
weaverryan
weaverryan
Read Full Comment
... connection. Here is some deep logic that proves this: https://github.com/doctrine/DoctrineBundle/blob/master/DependencyInjection/DoctrineExtension.php#L338-L342 So, the best option I can think of to "enforce" being explicit ...
weaverryan
weaverryan
Read Full Comment
... get all related comments in one query, then it somehow hydrates the relevant post with it's comments. So only 2 queries are needed. Is there a similar way to do this with Doctrine? I'm not sure how I would optimize this manually, since the foreign key ID fields are hidden.
... you can paste directly into MySQL to see the results that Doctrine is getting. If the order is definitely wrong, and you can't find any issues, you can post your code and we can see if we spot any problems :). Cheers!
weaverryan
weaverryan
Read Full Comment
... that this question is out of a course scope, but does anyone one know a reason for existing of owning and inverse side of Doctrine relations? Can we make an equal sides of association (to CRUD entities from both sides without additional actions)?
toporovvv
toporovvv
Read Full Comment
... with you: generated entity code could not check all the schema nuances, especially after several controversial changes. And that's why there was a good practice of removing all the autogenerated code in the entity and recreation it by the doctrine command or IDE.
toporovvv
toporovvv
Read Full Comment
... - is it possible to run doctrine migrations from within the application and not via the terminal? (If not, I'll just put together a script that cycles through all the databases and runs the migrations command)
Amy anuszewski
Amy anuszewski
Read Full Comment
... OneToMany and ManyToOne that technically is the same as ManyToMany in the database, but now we can add extra data (add extra columns on GenusScientist) to this intermediate table with Doctrine. I hope it clear to you now. I'd also recommend to re-watch this video one more time because yeah, it's kinda complex. Cheers!
... totally meant to put this in my original code - sorry! > Note : Maybe not very important , but someone tell me that the composite primary keys are no longuer supported in Doctrine, should I instead add an ID ...
weaverryan
weaverryan
Read Full Comment
// ... lines 1 - 2
namespace App\Command;
use App\Repository\BigFootSightingRepository;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
class UpdateSightingScoresCommand extends Command
{
protected static $defaultName = 'app:update-sighting-scores';
private $bigFootSightingRepository;
private $entityManager;
public function __construct(BigFootSightingRepository $bigFootSightingRepository, EntityManagerInterface $entityManager)
{
$this->bigFootSightingRepository = $bigFootSightingRepository;
$this->entityManager = $entityManager;
parent::__construct();
}
protected function configure()
{
$this
->setDescription('Update the "score" for a sighting')
;
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new SymfonyStyle($input, $output);
$sightings = $this->bigFootSightingRepository->findAll();
$io->progressStart(count($sightings));
foreach ($sightings as $sighting) {
$io->progressAdvance();
$characterCount = 0;
foreach ($sighting->getComments() as $comment) {
$characterCount += strlen($comment->getContent());
}
$score = ceil(min($characterCount / 500, 10));
$sighting->setScore($score);
$this->entityManager->flush();
}
$io->progressFinish();
}
}
See Code Block in Script
76 lines | src/Entity/ApiToken.php
// ... lines 1 - 2
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="App\Repository\ApiTokenRepository")
*/
class ApiToken
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $token;
/**
* @ORM\Column(type="datetime")
*/
private $expiresAt;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\User", inversedBy="apiTokens")
* @ORM\JoinColumn(nullable=false)
*/
private $user;
public function getId(): ?int
{
return $this->id;
}
public function getToken(): ?string
{
return $this->token;
}
public function setToken(string $token): self
{
$this->token = $token;
return $this;
}
public function getExpiresAt(): ?\DateTimeInterface
{
return $this->expiresAt;
}
public function setExpiresAt(\DateTimeInterface $expiresAt): self
{
$this->expiresAt = $expiresAt;
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
}
See Code Block in Script
93 lines | src/Entity/Article.php
// ... lines 1 - 2
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="App\Repository\ArticleRepository")
*/
class Article
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $title;
/**
* @ORM\Column(type="string", length=100)
*/
private $slug;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $content;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $publishedAt;
public function getId()
{
return $this->id;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(string $title): self
{
$this->title = $title;
return $this;
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(string $slug): self
{
$this->slug = $slug;
return $this;
}
public function getContent(): ?string
{
return $this->content;
}
public function setContent(?string $content): self
{
$this->content = $content;
return $this;
}
public function getPublishedAt(): ?\DateTimeInterface
{
return $this->publishedAt;
}
public function setPublishedAt(?\DateTimeInterface $publishedAt): self
{
$this->publishedAt = $publishedAt;
return $this;
}
}
See Code Block in Script
... by_reference to false on that field. The reason is that, on save, Doctrine looks at the Product.tags field to figure out what to do, and that will be updated correctly regardless of the value for by_reference. But if the owning ...
weaverryan
weaverryan
Read Full Comment
... model versus the "Profile" idea is that a user would naturally ONLY be a clinician OR a patient, but never both (because if you use Doctrine inheritance to accomplish this, then each record will have a "discriminator" column ...
weaverryan
weaverryan
Read Full Comment
Custom Validation Callback and Constraints

... some extras, like getter and setter methods): // src/KnpU/QADayBundle/Entity/Event.php namespace KnpU\QADayBundle\Entity; use Doctrine\ORM\Mapping as ORM; /** @ORM\Entity(repositoryClass="KnpU\QADayBundle\Entity ...

11:48:57
... NativeLoader i used my NewNativeLoader. Code looks like this: ``` namespace AppBundle\DataFixtures\ORM; use Doctrine\Bundle\FixturesBundle\Fixture; use Doctrine\Common\Persistence\ObjectManager; class LoadFixtures extends ...
Maciek Kasprzak
Maciek Kasprzak
Read Full Comment
... ($servicio), im adding one of this fron-end sended services,(servicio), that can construct themselves as object of the Servicio class, on a toEntity pattern function. so, i understand that doctrine might be complaining ...
sebastian
sebastian
Read Full Comment