PHP code example of graefe / doctrine-extensions

1. Go to this page and download the library: Download graefe/doctrine-extensions 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/ */

    

graefe / doctrine-extensions example snippets


// Register custom type during boot-strap.
\Doctrine\DBAL\Types\Type::addType('unixtime', '\Graefe\Doctrine\Type\UnixTimeType');

...

/**
 * @ORM\Column(name="created", type="unixtime", nullable=false)
 */
private $created;

// Define type.
class ShopModeType extends \Graefe\Doctrine\Type\MySqlEnumType
{
    protected function getValues() { return array('b2b','b2c'); }
    public function getName() { return 'shopmode'; }
}

...

// Register type during boot-strap.
\Doctrine\DBAL\Types\Type::addType('shopmode', 'ShopModeType');

...

/**
 * @ORM\Column(name="mode", type="shopmode", nullable=false)
 */
private $mode;

// Register function.
$em->getConfiguration()->addCustomNumericFunction('RAND', '\\Graefe\\Doctrine\\Functions\\Rand');

...

$qb->select('d')
    ->addSelect('RAND() AS randval')
    ->from('Dummy', 'd')
    ->orderBy('randval')
    ->setMaxResults(1);