PHP code example of doctrineum / float

1. Go to this page and download the library: Download doctrineum/float 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 / float example snippets




use Doctrine\ORM\Mapping as ORM;
use Doctrineum\Float\FloatEnum;

/**
 * @ORM\Entity()
 */
class Person
{
    /**
     * @var int
     * @ORM\Id() @ORM\GeneratedValue(strategy="AUTO") @ORM\Column(type="integer")
     */
    private $id;

    /**
     * @var FloatEnum
     * @ORM\Column(type="float_enum")
     */
    private $height;
    
    public function __construct(FloatEnum $height)
    {
        $this->height = $height;
    }

    /**
     * @return FloatEnum
     */
    public function getHeight()
    {
        return $this->height;
    }
}

$tallMan = new Person(FloatEnum::getEnum(197.45));

/** @var \Doctrine\ORM\EntityManager $entityManager */
$entityManager->persist($tallMan);
$entityManager->flush();
$entityManager->clear();

/** @var Person[] $persons */
$canSitOnFrontSeat = $entityManager->createQuery(
    "SELECT p FROM Person p WHERE p.height >= 140"
)->getResult();

var_dump($canSitOnFrontSeat[0]->getHeight()->getValue()); // 197.45;



use Doctrineum\Float\FloatEnumType;

FloatEnumType::registerSelf();