cleantalk/btree_database

CleanTalk binary tree database package.

Installs: 11

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 3

Forks: 0

Open Issues: 0

Type:cleantalk-apbct-lib

1.2.3 2023-08-29 09:45 UTC

This package is auto-updated.

Last update: 2024-04-07 11:33:39 UTC


README

Install

composer require cleantalk/btree_database

Using

Connect database to your project:

<?php

use Cleantalk\Common\BtreeDatabase\FileDB;

//require initialization and autoloader
require_once 'vendor/autoload.php';

$db_location = __DIR__ . '/data';

// Example array contains networks
$data = array(
    'network'     => '2130706433',
    'mask'        => '4294967295',
    'status'      => 1,
    'is_personal' => 0,
);


try {
    // Instantiate the DB main controller
    $file_db = new FileDB('fw_nets', $db_location);

    // Prepare and insert data using fluid interface
    $insert = $file_db->prepareData(array($data))->insert();

    // Perform request using fluid interface
    $db_results = $file_db
        ->setWhere( array( 'network' => array('2130706433'), ) )
        ->setLimit( 0, 20 )
        ->select( 'network', 'mask', 'status', 'is_personal' );
        
    //Use ->delete to delete database
    //$file_db->delete();
} catch (\Exception $e) {
    print $e->getMessage();
}

var_dump($db_results);