Last active
November 21, 2018 16:54
-
-
Save ConConovaloff/56275468a88064ee4d5f8d31d221cc00 to your computer and use it in GitHub Desktop.
symfony pallet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=== поиск по нескольким значениям === | |
findOneBy([ | |
'some' => 'one', | |
'another' => 'two', | |
]); | |
== raw sql == | |
// получаем все алиасы, у которых product brand выставлен в parsing == 1 | |
$idList = $this->getEntityManager()->getConnection() | |
->executeQuery(' | |
SELECT pba.id | |
FROM product_brand_alias pba | |
JOIN product_brand pb on pba.product_brand_id = pb.id | |
WHERE pb.parsing = 1') | |
->fetchAll(); | |
$pbaList = $this->getEntityManager() | |
->getRepository(ProductBrandAlias::class) | |
->findBy(['id' => array_column($idList, 'id')]); | |
// raw удаление | |
$this->getEntityManager() | |
->getConnection() | |
->query('DELETE FROM product_brand_alias'); | |
// raw обновление | |
$this->getEntityManager() | |
->getConnection() | |
->exec('UPDATE qr_product | |
SET brand_id = ' . $newParent->getId() . ' | |
WHERE brand_id = ' . $productBrand->getId()); | |
=== Связи === | |
== OneToOne == | |
<?php | |
/** @Entity */ | |
class Customer | |
{ | |
// ... | |
/** | |
* One Customer has One Cart. | |
* @OneToOne(targetEntity="Cart", mappedBy="customer") | |
*/ | |
private $cart; | |
// ... | |
} | |
/** @Entity */ | |
class Cart | |
{ | |
// ... | |
/** | |
* One Cart has One Customer. | |
* @OneToOne(targetEntity="Customer", inversedBy="cart") | |
* @JoinColumn(name="customer_id", referencedColumnName="id") | |
*/ | |
private $customer; | |
// ... | |
} | |
== manyToMany == | |
== oneToMany == |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
== delete entity | |
$em->remove($guest); | |
$em->flush(); | |
== render | |
return $this->render('AppBundle::some.html.php'); | |
// src/AppBundle/Resources/views/some.html.php | |
return $this->render('AppBundle:Admin:Tools/linkProductBrand.html.php'); | |
// src/AppBundle/Resources/views/Admin/Tools/linkProductBrand.html.php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
== запрещаем роуты == | |
public function configureRoutes(RouteCollection $collection) | |
{ | |
$collection->remove('batch'); | |
$collection->remove('create'); | |
$collection->remove('delete'); | |
$collection->remove('export'); | |
$collection->remove('edit'); | |
} | |
== Типы == | |
=== выбор в строку === | |
->add('newType', 'choice', [ | |
'choices' => ['alias' => 'alias', 'brand' => 'brand'], | |
'required' => false, | |
'label' => 'Тип после переноса', | |
]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment