PHP code example of zodream / database

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

    

zodream / database example snippets


$query->isEmpty();


$model = new Model();

$model->setRaelation('a', 122222);


empty($model['a'])  // true

$model->relationLoaded('a') // true




$data = [
    'id' => 1,
    'name' => 2
];
$data = Relation::create($data, [
    't' => [
        'query' => GoodsAttributeModel::query(),
        'link' => ['id', 'goods_id'],
        'relation' => [
            'attr' => [
                'query' => AttributeModel::query(),
                'type' => 0,
                'link' => ['attribute_id', 'id'],
            ]
        ]
    ],
]);



$data = [
    'id' => 1,
    'name' => 2
];
$data = Relation::create($data, [
    't' => [
        'query' => GoodsAttributeModel::query(),
        'link' => ['id', 'goods_id'],
        'relation' => [
            [
                'query' => AttributeModel::query(),
                'type' => 0,
                'link' => ['attribute_id', 'id'],
            ]
        ]
    ],
]);