PHP code example of kosmosafive / bitrix-db

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

    

kosmosafive / bitrix-db example snippets


$vendorAutoload = dirname(__DIR__) . '/local/vendor/autoload.php';
if (file_exists($vendorAutoload)) {
               'className' => '\\Kosmosafive\\Bitrix\\DB\\MysqliConnection',
// ...

SampleTable::getMap();

public static function getIndexConfigurationCollection(): ConfigurationCollection
{
    return new ConfigurationCollection(static::class)
        ->add(['ENTITY_TYPE'])
        ->add(['ENTITY_TYPE', 'SECTION_ID']);
}

$entity = SampleTable::getEntity();
$entity->createAdditionalIndexes();

$entity = SampleTable::getEntity();
$entity->createForeignKeys();

$entity = SampleTable::getEntity();
$entity->dropForeignKeys();

public static function getConstraintCollection(): ConstraintCollection
{
    return new ConstraintCollection()
        ->add(new Unique('user_entity', 'USER_ID', 'ENTITY_ID'));
}

$entity = SampleTable::getEntity();
$entity->createConstraints();

new Chech(
    'price',
    'PRICE > 0'
);

new Unique(
    'user_entity',
    'USER_ID',
    'ENTITY_ID'
);

public static function getMap(): array
{
    $map = [...];
    
    static::addTableMapping($map);

    return $map;
}

use Ramsey\Uuid\Uuid;

$uuid = Uuid::fromString($value)->getBytes();

SampleTable::query()
    ->where('ID', $uuid);