PHP code example of nepada / birth-number-doctrine

1. Go to this page and download the library: Download nepada/birth-number-doctrine library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

nepada / birth-number-doctrine example snippets


\Doctrine\DBAL\Types\Type::addType(
    \Nepada\BirthNumberDoctrine\BirthNumberType::NAME,
    \Nepada\BirthNumberDoctrine\BirthNumberType::class
);

use Doctrine\ORM\Mapping\Column;
use Doctrine\ORM\Mapping\Entity;
use Nepada\BirthNumber\BirthNumber;

#[Entity]
class Person
{

    #[Column(type: BirthNumber::class, nullable: false)]
    private BirthNumber $birthNumber;

    public function getBirthNumber(): BirthNumber
    {
        return $this->birthNumber;
    }

}

$result = $repository->createQueryBuilder('foo')
    ->select('foo')
    ->where('foo.birthNumber = :birthNumber')
     // the parameter value is automatically normalized to '0001010009'
    ->setParameter('birthNumber', '000101 / 0009', BirthNumberType::NAME)
    ->getQuery()
    ->getResult();