README
What is ReyOrm?
The experimental version ORM for Bitrix., (*1)
, (*2)
Installation
via composer:, (*3)
$ php composer.phar require rey/orm dev-master
in your code add:, (*4)
``` php
require_once DIR . '/vendor/autoload.php';, (*5)
Example
------------
Examples of work with ReyOrm (alfa version):
Сode class repository for news:
``` 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;
}
}
User repository can structure business logic in classes., (*6)
``` php
$config = new Rey\Orm\Configuration();, (*7)
$config->setCacheDir(DIR . '/cache/orm');
$config->setRepositoryClass('News', 'NewsRepository');, (*8)
$em = new Rey\Orm\EntityManager($config);, (*9)
$newsRepository = $em->getRepository('News');
$newsList = $newsRepository->getAllNews();, (*10)
while($newsItem = $newsList->Fetch()) {
echo $newsItem['Title'] . '</ br>';
}
```, (*11)
When calling $em->getRepository('News') will be searched for the information block code News.
If you have not set user repository for an News entity is returned instance Rey\Orm\Repository\BaseRepository., (*12)
Run tests
You can run the unit tests with the following command:, (*13)
$ cd path/to/rey/orm/
$ composer.phar install
$ phpunit