2709 search results for Doctrine

... single andWhere() if I need to be more clear about how I want it to work. We talk a little bit about that here: https://symfonycasts.com/screencast/doctrine-queries/and-where-or-where#codeblock-0e8ea207d8 Happy new year to you too!
weaverryan
weaverryan
Read Full Comment
... files property on your entity yep ! I added validation constraint in the entity and it's now working. At least there is doctrine exception no more. Don't bother about the HTML5 (unless you know why) since there is form validation it's good enough. ...
... ]: Syntax error: 7 ERROR: syntax error at or near "user" LINE 1: DELETE FROM user` If anyone else has this problem, it's easy to change the table name for the entity using annotations. Check out https://stackoverflow.com/questions/34532785/rename-table-name-with-doctrine-migrations.
... : ``` * @Gedmo\SoftDeleteable(fieldName="deletedAt") ``` The entity was not "really" deleted, but apparently i asked Doctrine to think it is... My bad, i totally forgot about that annotation. Thank you for your investigations :) Keep up the good and fun work guys ! Cheers.
Julien Quintiao
Julien Quintiao
Read Full Comment
Hey Dominik, First of all, because this screencast is not about StofDoctrineExtenstion but about Doctrine relations. StofDoctrineExtenstion has many useful behaviors we didn't use here, but that's because we just don't ...
I added the namespace but still receive the same error as Daniel (also Daniels solution doesn't work for me). However, I renamed my "Article" class to "Drops" (as "Drop" wasn't allowed with doctrine), so might this be ...
Christian S.
Christian S.
Read Full Comment
... doctrine query - In my tiredness I made the mistake of querying it on a property that the entity did not have (username). So for anyone else that's the kind of message you'll get back when your query is not returning anything. Silly me.
You may find interesting this library then https://github.com/doctrine/migrations What I like to do is to auto-generate migrations by running `bin/console doctrine:migration:diff` Usually I only create one migration ...
MolloKhan
MolloKhan
Read Full Comment
... of course uploading media. I saw most of them in Stof Doctrine Extensions. However, you guys making everything easier then it really is :) Another topic but is there AJAX based alternative to knp-paginator-bundle? Thanks for all your help.
178 lines | src/Entity/Question.php
// ... lines 1 - 6
use Doctrine\Common\Collections\Collection;
// ... lines 8 - 14
class Question
{
// ... lines 17 - 147
/**
* @return Collection|Answer[]
*/
public function getAnswers(): Collection
{
return $this->answers;
}
public function addAnswer(Answer $answer): self
{
if (!$this->answers->contains($answer)) {
$this->answers[] = $answer;
$answer->setQuestion($this);
}
return $this;
}
public function removeAnswer(Answer $answer): self
{
if ($this->answers->removeElement($answer)) {
// set the owning side to null (unless already changed)
if ($answer->getQuestion() === $this) {
$answer->setQuestion(null);
}
}
return $this;
}
}
See Code Block in Script
54 lines | app/AppKernel.php
// ... lines 1 - 5
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
new Symfony\Bundle\TwigBundle\TwigBundle(),
new Symfony\Bundle\MonologBundle\MonologBundle(),
new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
// ... lines 18 - 20
new AppBundle\AppBundle(),
);
if (in_array($this->getEnvironment(), array('dev', 'test'), true)) {
$bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle();
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
$bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle();
$bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle();
}
return $bundles;
}
// ... lines 33 - 52
}
See Code Block in Script
202 lines | src/Entity/Article.php
// ... lines 1 - 5
use Doctrine\Common\Collections\Collection;
// ... lines 7 - 13
class Article
{
// ... lines 16 - 170
/**
* @return Collection|Comment[]
*/
public function getComments(): Collection
{
return $this->comments;
}
public function addComment(Comment $comment): self
{
if (!$this->comments->contains($comment)) {
$this->comments[] = $comment;
$comment->setArticle($this);
}
return $this;
}
public function removeComment(Comment $comment): self
{
if ($this->comments->contains($comment)) {
$this->comments->removeElement($comment);
// set the owning side to null (unless already changed)
if ($comment->getArticle() === $this) {
$comment->setArticle(null);
}
}
return $this;
}
}
See Code Block in Script
58 lines | src/Entity/Comment.php
// ... lines 1 - 2
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="App\Repository\CommentRepository")
*/
class Comment
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $authorName;
/**
* @ORM\Column(type="text")
*/
private $content;
public function getId()
{
return $this->id;
}
public function getAuthorName(): ?string
{
return $this->authorName;
}
public function setAuthorName(string $authorName): self
{
$this->authorName = $authorName;
return $this;
}
public function getContent(): ?string
{
return $this->content;
}
public function setContent(string $content): self
{
$this->content = $content;
return $this;
}
}
See Code Block in Script
47 lines | src/AppBundle/Entity/Security.php
// ... lines 1 - 2
namespace AppBundle\Entity;
// ... line 4
use Doctrine\ORM\Mapping as ORM;
// ... line 6
/**
* @ORM\Entity
* @ORM\Table(name="securities")
*/
class Security
{
/**
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string")
*/
private $name;
/**
* @ORM\Column(type="boolean")
*/
private $isActive;
/**
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\Enclosure", inversedBy="securities")
*/
private $enclosure;
public function __construct(string $name, bool $isActive, Enclosure $enclosure)
{
$this->name = $name;
$this->isActive = $isActive;
$this->enclosure = $enclosure;
}
public function getIsActive(): bool
{
return $this->isActive;
}
}
See Code Block in Script
95 lines | src/AppBundle/Entity/Subscription.php
// ... lines 1 - 4
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @ORM\Table(name="subscription")
*/
class Subscription
{
/**
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\OneToOne(targetEntity="User", inversedBy="subscription")
* @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
*/
private $user;
/**
* @ORM\Column(type="string")
*/
private $stripeSubscriptionId;
/**
* @ORM\Column(type="string")
*/
private $stripePlanId;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $endsAt;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $billingPeriodEndsAt;
// ... lines 45 - 93
}
See Code Block in Script
101 lines | src/Entity/User.php
// ... lines 1 - 2
namespace App\Entity;
use App\Repository\UserRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;
#[ORM\Entity(repositoryClass: UserRepository::class)]
#[ORM\Table(name: '`user`')]
class User implements UserInterface, PasswordAuthenticatedUserInterface
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 180, unique: true)]
private ?string $email = null;
#[ORM\Column]
private array $roles = [];
/**
* @var string The hashed password
*/
#[ORM\Column]
private ?string $password = null;
// ... lines 30 - 99
}
See Code Block in Script
... the user"-logic in the same place if you know what I mean. Yep, setting createdAt via the constructor is super easy...but it only works for createdAt... so has limited usefulness. > One way would be to use stof/doctrine ...
weaverryan
weaverryan
Read Full Comment
App Test Setup

... rules around who can publish an item under different conditions. Then we'll do everything custom: add completely custom fields, completely custom API resources that aren't backed by Doctrine, custom filters and we'll even ...

7:44
Timeline Go Behind-the-Scenes with your Code

... explanatory. Depending on how well you know Doctrine, this might be obvious... or not. This metric refers to whenever one or more entities are hydrated into an object. Notice the count is 3. For this metric, it's not that ...

7:15
Wall Time Exclusive Time Other Wonders

... :createEntity function... whatever that is. If you use Doctrine, you might know what this is - but let's pretend we have no idea. Before we dive further into the root cause behind this slow function, the other way to ...

7:47