PHP code example of riccardonar / doctrine-intrange
1. Go to this page and download the library: Download riccardonar/doctrine-intrange 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/ */
riccardonar / doctrine-intrange example snippets
use Doctrine\DBAL\Types\Type;
use riccardonar\Doctrine\DBAL\Types\IntRangeType;
Type::addType(
IntRangeType::INTRANGE,
'riccardonar\\Doctrine\\DBAL\\Types\\IntRangeType'
);
/**
* @Entity()
* @Table(name="jobs")
*/
class Job
{
/**
* @Column(type="integer")
* @GeneratedValue(strategy="AUTO")
* @Id()
*/
private $id;
/**
* @Column(type="intrange")
*/
private $range;
/**
* @return \riccardonar\IntRange
*/
public function getRange()
{
return $this->range;
}
/**
* @param \riccardonar\IntRange $range
*/
public function setRange(array $range)
{
$this->range = $range;
}
}
$annualJob = new Job();
$annualJob->setRange(new \riccardonar\IntRange(1, 6));
$entityManager->persist($annualJob);
$entityManager->flush();
$entityManager->clear();
$jobs = $entityManager->createQuery(
"SELECT j FROM Jobs j"
)->getResult();
echo $jobs[0]->getRange()->getStartInt(); // 1
echo $jobs[0]->getRange()->getEndInt(); // 6