|
// ... lines 1 - 4
|
|
namespace DoctrineMigrations; |
|
|
|
use Doctrine\DBAL\Schema\Schema; |
|
use Doctrine\Migrations\AbstractMigration; |
|
|
|
|
|
|
|
|
|
final class Version20210907185958 extends AbstractMigration |
|
{ |
|
public function getDescription(): string |
|
{ |
|
return ''; |
|
} |
|
|
|
public function up(Schema $schema): void |
|
{ |
|
|
|
$this->addSql('CREATE TABLE question_tag (question_id INT NOT NULL, tag_id INT NOT NULL, INDEX IDX_339D56FB1E27F6BF (question_id), INDEX IDX_339D56FBBAD26311 (tag_id), PRIMARY KEY(question_id, tag_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); |
|
$this->addSql('ALTER TABLE question_tag ADD CONSTRAINT FK_339D56FB1E27F6BF FOREIGN KEY (question_id) REFERENCES question (id) ON DELETE CASCADE'); |
|
$this->addSql('ALTER TABLE question_tag ADD CONSTRAINT FK_339D56FBBAD26311 FOREIGN KEY (tag_id) REFERENCES tag (id) ON DELETE CASCADE'); |
|
} |
|
|
|
public function down(Schema $schema): void |
|
{ |
|
|
|
$this->addSql('DROP TABLE question_tag'); |
|
} |
|
} |
See Code Block in Script
... output:
andy$ composer require doctrine/doctrine-migrations-bundle
Using version ^1.3 for doctrine/doctrine-migrations-bundle
./composer.json has been updated
Loading composer repositories with package information
Updating ...
... in DQL, you can set a parameter to an array for a WHERE IN statement, and when Doctrine translates this to the SQL string, it properly takes that array and implodes it as expected. But, that won't happen in a filter ...
... /package-versions-deprecated": "1.11.99.5",
"doctrine/doctrine-bundle": "^2.9.1",
"doctrine/doctrine-migrations-bundle": "^3.2",
"doctrine/orm": "^2.15.1",
"knplabs/knp-markdown-bundle ...
WHERE IN
... key thing is that, when you use IN, you will need the parentheses like
normal... but inside of that, instead of a comma-separated list, you'll set an
array. Doctrine will transform that for us.
And now... nice! Once you ...
Hooking up the Scientist Removal JavaScript
... call. Click the little sha, then go to the Doctrine tab. Ooh, look at
this:
DELETE FROM genus_scientist WHERE genus_id = 11 AND user_id = 11
Gosh darn it that's nice. To prove it, refresh: the scientist is gone. ManyToMany?
Yea, it's as simple as adding and removing objects from an array.
Well, ok, it will get a bit harder soon...
Hey Terry!
I can answer this one as well :). Doctrine internally has something called an "identity map". Basically, it keeps track of all of the entities that were either queried for or persisted during this request ...
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiFilter;
use ApiPlatform\Core\Annotation\ApiResource;
use ApiPlatform\Core\Serializer\Filter\PropertyFilter;
use App\Repository\UserRepository;
use Doctrine ...
... ', $communityName)
->orderBy('e.marketDay', 'ASC')
->getQuery();
dd($returnQueryResultByCommunityQueryOnly);
`
I get this dql syntax not 'real' sql, I need to get SQL language:
`
Doctrine\ORM\Query {#9149 ...
Hey Alexander,
Very rough approximation - it will be started releasing after "Doctrine & the Database" course, probably on the next week. We also want to start releasing ReactJS course very soon, so these two courses on the way to be released.
Cheers! ...
... will only have a single genus.
Does doctrine default to a specific note?
Is there some way to specify which note you want to use?
Hey Kevin,
Yeah, sorry about delays. But I have good news for you! We're working on this tutorial right now with our awesome co-author, and we're going to start releasing this course after Doctrine one. Thanks for your patience!
Cheers! ...
I was just wondering if I could use a Doctrine Entity Listener for the "HasPasswordLIstener" instead of the EventSubscriber. It seems useless that this is called for every entity while the Entity Listener is called only for the User Entity, which is what we want anyway. ...
Hi Ryan,
When I run composer install, it says I have 34 problems. Most of the problems is wrong PHP version. How can I fix this?
`doctrine/common v2.8.1 requires php ~7.1 -> your PHP version (7.0.10) does not satisfy that requirement.`
Best regards,
Dennis ...
... is a special flag that tells the container that this service should be registered as a Doctrine listener
Cheers!
Hey weaverryan, sorry for taking so long to get back. The main issue im having is that I want to use an in memory sqlite db for testing. I need to figure out how I can run my doctrine migrations as part of the tests. ...
Hey notronwest
There is another way to do that. You can change the default repository class binded to all your entities in your "doctrine.yaml" configuration file, something like this:
```
doctrine:
orm ...
Hey jarnstad ,
Ah, unfortunately, not yet... see our roadmap for upcoming screencasts here: https://knpuniversity.com/courses?status=upcoming&sort=popular#all . We're working on Doctrine tutorial, then probably will be ReactJs one, and only then we will switch to the Fixtures.
Cheers! ...
help please, i have this error:
Attempted to load class "User" from namespace "UserBundle\Entity".
Did you forget a "use" statement for e.g. "Symfony\Component\Security\Core\User\User", "Symfony\Bridge\Doctrine\Tests\Fixtures\User", "FOS\UserBundle\Model\User", "FOS\RestBundle\Tests\Fixtures\User" or "AppBundle\Entity\User"? ...
Hey Roman R.
Can you tell me what's actually your problem?
If you need to create multiple relationships to the same entity is totally possible. This example may help you getting an idea of how to do it: http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/working-with-associations.html
Cheers! ...
2726
Doctrine
Filter Results