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
<?php | |
namespace App\DQL; | |
use Doctrine\ORM\Query\AST\Functions\FunctionNode; | |
use Doctrine\ORM\Query\AST\Literal; | |
use Doctrine\ORM\Query\AST\OrderByClause; | |
use Doctrine\ORM\Query\AST\PathExpression; | |
use Doctrine\ORM\Query\Lexer; | |
use Doctrine\ORM\Query\Parser; |
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
# For example, you store dates in the type `timestamp with timezone`: | |
2019-08-04 11:13:17+00 | |
# This query generates randomly microseconds for a date: | |
UPDATE <table> SET <field> = TO_TIMESTAMP(replace(to_char(<field>, 'YYYY-MM-DD HH24:MI:SS.SS%m%OF'), '%m%', (floor(random()*(10000-1+1))+1)::text), 'YYYY-MM-DD HH24:MI:SS.US') |
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
$reference = $em->getPartialReference('MyApp\Domain\User', 1); |
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
<?php $q = $em->createQuery("select partial u.{id,name} from MyApp\Domain\User u"); |
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
$item = $em->getReference('MyProject\Model\Item', $itemId); | |
$cart->addItem($item); |
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
Collection#contains($entity) | |
Collection#containsKey($key) (доступно начиная с Doctrine 2.5) | |
Collection#count() | |
Collection#get($key) (доступно начиная с Doctrine 2.4) | |
Collection#slice($offset, $length = null) |
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 testIdentityMapRepositoryFindBy() | |
{ | |
$repository = $this->entityManager->getRepository('Person'); | |
$objectA = $repository->findOneBy(array('name' => 'Benjamin')); | |
$objectB = $repository->findOneBy(array('name' => 'Benjamin')); | |
$this->assertSame($objectA, $objectB); | |
} |
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 testIdentityMap() | |
{ | |
$objectA = $this->entityManager->find('EntityName', 1); | |
$objectB = $this->entityManager->find('EntityName', 1); | |
$this->assertSame($objectA, $objectB) | |
} |