PHP code example of cybrox / crunchdb

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

    

cybrox / crunchdb example snippets


// Search for rows with the type `user` **OR** `admin
...->select(['type', '==', 'user'],['type', '==', 'admin'])->...

// Search for rows with the type `user` **AND** the `name` 'cybrox' 
...->select(['type', '==', 'user'],['name', '==', 'cybrox', 'and'])->...

// Sort by number descending and then by name descending.
...->sort(['type', SORT_DESC], ['name', SORT_DESC])->...

// Update type and name of a resource.
...->update(['type','admin'],['name','cybrox'])->...



  use cybrox\crunchdb\crunchDB as crunchDB;
  $cdb = new crunchDB('./db/');

  $cdb->version();
  $cdb->table('cookies')->exists();
  $cdb->table('cookies')->create();
  $cdb->table('cakes')->create();
  $cdb->table('cakes')->alter('cheese');
  $cdb->tables();
  $cdb->table('cookies')->count();
  $cdb->table('cookies')->insert(array("type" => "chocolate", "is" => "nice"));
  $cdb->table('cookies')->insert(array("type" => "banana", "is" => "nice"));
  $cdb->table('cookies')->insert(array("type" => "strawberry", "is" => "ok"));
  $cdb->table('cookies')->raw();
  $cdb->table('cookies')->select('*')->fetch();
  $cdb->table('cookies')->select('*')->count();
  $cdb->table('cookies')->select(['type', '==', 'chocolate'])->fetch();
  $cdb->table('cookies')->select(['type', '==', 'chocolate'],['type', '==', 'banana', 'or'])->fetch();
  $cdb->table('cookies')->select(['type', '==', 'chocolate'],['type', '==', 'banana', 'and'])->count();
  $cdb->table('cookies')->select('*')->sort(['type'])->fetch();
  $cdb->table('cookies')->select(['type', '==', 'strawberry'])->delete();
  $cdb->table('cookies')->select(['type', '==', 'banana'])->update(['type', 'chocolate']);
  $cdb->table('cookies')->select('*')->fetch();