PHP code example of rey / orm

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

    

rey / orm example snippets

 php
 php
use Rey\Orm\Repository\BaseRepository;
use CIBlockElement;

class NewsRepository extends BaseRepository
{
    public function getAllNews()
    {
        $r = CIBlockElement::getList(array(), array('IBLOCK_ID' => $this->getMetadata()->get('iblock_id')));

        return $r;
    }
}
 php
$config = new Rey\Orm\Configuration();

$config->setCacheDir(__DIR__ . '/cache/orm');
$config->setRepositoryClass('News', 'NewsRepository');

$em = new Rey\Orm\EntityManager($config);

$newsRepository = $em->getRepository('News');
$newsList = $newsRepository->getAllNews();

while($newsItem = $newsList->Fetch()) {
    echo $newsItem['Title'] . '</ br>';
}