Skip to content

Instantly share code, notes, and snippets.

@simo97
Created August 23, 2016 22:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simo97/10ac58568d68b85b3bd6df45ba0fcb22 to your computer and use it in GitHub Desktop.
Save simo97/10ac58568d68b85b3bd6df45ba0fcb22 to your computer and use it in GitHub Desktop.
<?php
require __DIR__ .'/vendor/autoload.php';
use \JSONDB\Exception as ex;
try{
$test = new \JSONDB\JSONDB();
$test->createServer('adonis2','root','root');
$test->connect('adonis2', 'root', 'root');
$test->createDatabase('bank_2');
$test->setDatabase('bank_2');
//$test->createTable('service', array(
// 'id' => array(
// 'type' => 'int',
// 'auto_increment' =>true,
// 'primary_key' => true
// )
// )
//);
$test->createTable('test2', array(
'id' => array(
'type' => 'int',
'auto_increment' =>true,
'primary_key' => true
)
)
);
$test->createTable('test', array(
'id' => array(
'type' => 'int',
'auto_increment' =>true,
'primary_key' => true
),
'id_test2' => array(
'type' => 'link(test2.id)'
)
)
);
//$test->createTable('utilisateur', array(
// 'id' => array(
// 'type' => 'int',
// 'auto_increment' =>true,
// 'primary_key' => true
// ),
// 'id_service' => array(
// 'type' => 'link(service.id)'
// )
// )
//);
$test->query('test.insert(1).in(id_test2)');
}catch(ex $d){
echo $d->getMessage();
}
@na2axl
Copy link

na2axl commented Aug 24, 2016

<?php

    require __DIR__ .'/vendor/autoload.php';

    $test = new \JSONDB\JSONDB();
    $test->createServer('./test', 'root', '', true);
    $test->connect('./test', 'root', '');
    $test->createDatabase('test_database');
    $test->setDatabase('test_database');
    $test->createTable('test2', array('id' => array('type' => 'int', 'auto_increment' =>true, 'primary_key' => true)));
    $test->createTable('test', array('id' => array('type' => 'int', 'auto_increment' =>true, 'primary_key' => true), 'id_test2' => array('type' => 'link(test2.id)')));
    $test->query('test2.insert(null).and(null).and(null)');
    $test->query('test.insert(1).in(id_test2)');
    $results = $test->query('test.select(*).on(id_test2).link(*)');
    foreach ($results as $result) {
        print_r($result);
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment