PHP code example of doctrineum / integer
1. Go to this page and download the library: Download doctrineum/integer 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/ */
doctrineum / integer example snippets
use Doctrine\ORM\Mapping as ORM;
use Doctrineum\Integer\IntegerEnum;
/**
* @ORM\Entity()
*/
class Journey
{
/**
* @var int
* @ORM\Id() @ORM\GeneratedValue(strategy="AUTO") @ORM\Column(type="integer")
*/
private $id;
/**
* @var IntegerEnum
* @ORM\Column(type="integer_enum")
*/
private $distanceInKm;
public function __construct(IntegerEnum $distanceInKm)
{
$this->distanceInKm = $distanceInKm;
}
/**
* @return IntegerEnum
*/
public function getDistanceInKm()
{
return $this->distanceInKm;
}
}
$toSun = new Journey(IntegerEnum::getEnum(152100000));
/** @var \Doctrine\ORM\EntityManager $entityManager */
$entityManager->persist($toSun);
$entityManager->flush();
$entityManager->clear();
/** @var Journey[] $StarTracks */
$StarTracks = $entityManager->createQuery(
"SELECT j FROM Journey j WHERE j.distanceInKm >= 1000000"
)->getResult();
var_dump($StarTracks[0]->getDistanceInKm()->getValue()); // 152100000;
use Doctrineum\Integer\IntegerEnumType;
IntegerEnumType::registerSelf();