Persisting to the Database
We have a beautiful entity class and, thanks to the migrations that we just
executed, we have a corresponding question table in the database. Time to
insert some data!
One of the key philosophies of Doctrine is that it ...
Auto-set the Owner Entity Listener
... good thing. Hmm. Don't worry, I'll tell you which one I would use and why.
Our options include an API Platform event listener - a topic we haven't talked
about yet - an API Platform data persister or a Doctrine event ...
Users Need Passwords plainPassword
... text password, encrypt it through the
bcrypt algorithm and store that on the password property.
How? The best way is to set the plain-text password on the User and encode it automatically
via a Doctrine listener when it ...
Fetching with DQL the QueryBuilder find
... terminal. Remember that SQL query to select
all starships? Run it again:
symfony console doctrine:query:sql 'select * from starship'
That's raw SQL but Doctrine ORM has its own ...
Creating an Entity Class
Doctrine is an ORM, or object relational mapper. A fancy term for a pretty cool
idea. It means that each table in the database will have a corresponding class
in our code. So if we want to create an article table, it ...
Optimizing with Cache
... the provision started - use playbook.yml and add -l aws to only provision
the aws host:
Use beefpass for the password.
There's one other way we can boost performance. Open app/config/config_prod.yml:
See those Doctrine ...
Starship Entity
We have a database and can connect to it but... it doesn't have any tables!
The Doctrine ORM uses PHP classes to represent tables in the database, like if you
need a table for products, you create a Product class ...
Inserting new Objects
... on that object, and tell Doctrine to save it:
Doctrine wants you to stop thinking about queries, and instead think about objects.
Right now... name is the only real field we have. And it's a private property, so
we ...
Query across a JOIN and Love it
What about a JOIN query with Doctrine? Well, they're really cool.
Here's our last challenge. Go to /genus. Right now, this list is ordered by the
speciesCount property. Instead, I want to order by which genus has the ...
ManyToMany Relationship
... ManyToOne, we just need an annotation that tells
Doctrine what type of association this is and what entity it relates to:
// src/Yoda/EventBundle/Entity/Event.php
// ...
/**
@ORM\ManyToMany(targetEntity="Yoda\UserBundle ...
Starting in Symfony2 Course 2 2.4
Over the next hour, we're going to take you through some of the most difficult areas of Symfony learning all about security, forms, and parts of Doctrine. We'll also see testing and learn more about how Symfony's ...
Joining Across a Relationship The N 1 Problem
... time
we render an answer, we also render that answer's question text. The moment we do
that, Doctrine makes a second query from the question table to get that answer's
question data: so in this case WHERE id = 463. Then ...
Fetching Relations
... object. Remember: by this point, Doctrine has already used
the slug in the URL to query for the Question object.
The important thing here is that, when we call findBy(), we don't
say 'question_id' => $question... or ...
Saving Entities
Put on your publishing hat, because it's time to write some thoughtful space articles
and insert some rows into our article table! And, good news! This is probably one
of the easiest things to do in Doctrine.
Let's ...
Adding Property Types to Entities
A new feature snuck into Doctrine a while back, and it's super cool. Doctrine can
now guess some configuration about a property via its type. We'll start with
the relationship properties. But first, I want to make sure ...
Entity Class
Doctrine is an ORM: an object relational mapper. That's a fancy way of saying
that, for each table in the database, we will have a corresponding class in PHP.
And for each column on that table, there will be a property ...
Upgrading to Symfony 5.0
... We've done it! We fixed all the deprecations in our app... except for the
doctrine/persistence stuff, which we don't need to worry about because we're
not upgrading that library. That means... we are ready for Symfony5 ...
Lean and Mean Dev with PhpStorm for Symfony
... them)!
Tricks for annotations, Doctrine, forms, Twig and more
Refactoring
Live Templates
Fast navigation
Symfony service integration
.... (and always) well-intentioned jokes.
2729
Doctrine
Filter Results