NuvolaBase is your graph database on the cloud. You can use different languages with different
APIs. Choose the best one for your use case.
NuvolaBase is based on OrientDB Graph
Database. For any additional information please consult the OrientDB Documentation.
$real_destination_host = "http[s]://[user]:[password]@[host]";
example:
$real_destination_host = "http://phpguru:mygurupass@dashboard.nuvolabase.com";
If you don't know what to put here fill free to send an email to info@nuvolabase.com.
var database = new ODatabase('http://www.imaphpgu.ru/orientdb_proxy.php/');
databaseInfo = database.open();
queryResult = database.query('select from Address where city.country.name = \'Italy\'');
if (queryResult["result"].length == 0){
commandResult = database.executeCommand('insert into Address (street,type) values (\'Via test 1\',\'Tipo test\')');
} else {
commandResult = database.executeCommand('update Address set street = \'Via test 1\' where city.country.name = \'Italy\'');
}
database.close();
To get started with OrientDB and NuvolaBase we have prepared a "Ready to use" project that contains
all
the basic "CRUD" operations.
You can use these examples to start in developing your application.
The project contains executable classes (each one represents an operation) that uses a test database on NuvolaBase:
and then select Maven->Existing Maven Projects
.


and then select Import Project from external Model.
and then the project java-examples
.
Now press the button "Next" and then "Finish"

If you want to use OrientDB with a php application you can choice two different library:
Just a quick full immersion to get your feet wet with PHP and OrientDB.
Here we are creating a record:
$db = new OrientDB(string $host, int $port[, int $connectTimeout]);
$connected = $db->connect('root', 'passwd');
$config = $db->DBOpen('demo', 'writer', 'writer');
$record = new OrientDBRecord();
$record->data->name = 'John';
$recordPos = $db->recordCreate(1, $record);
$db->DBClose();
You can obviously get back the previous record:
$db = new OrientDB(string $host, int $port[, int $connectTimeout]);
$connected = $db->connect('root', 'passwd');
$config = $db->DBOpen('demo', 'writer', 'writer');
$cluster_id="1";
$cluster_position="1";
$record = $db->recordLoad($cluster_id .":". $cluster_position, '*:-1');
var_dump($db->cachedRecords);
$db->DBClose();
Well, well, well... so you come here and pretend to use a document/object database on the cloud from your applications written in C, isn't it?
We are absolutely sure (if you code in C you can surely confirm this) that viewing the source code is more direct and
productive that reading stuff like that, so, let's go to the code!
oh = o_new(); rc = o_prepare_connection(oh, ORIENT_PROTO_BINARY, "yourhost.nuvolabase.com", "2424"); rc = o_prepare_user(oh, ORIENT_USER, "youruser", "verysecure_userpwd_123"); rc = o_prepare_user(oh, ORIENT_ADMIN, "youradmin", "verysecure_adminpwd_123"); oc = o_connect(oh, &tv, 0); rc = o_bin_dbopen(oh, oc, &tv, 0, "yourverypersonaldatabaseonthecloud"); odoc = o_bin_recordload(oh, oc, &tv, 0, cluster_id, cluster_position, "*:-1"); rc = o_bin_dbclose(oh, oc, &tv, 0); o_close(oh, oc); o_free(oh);
Ok. The first is self explained, we are setting up library internal buffers.
The o_prepare_connection() library call means that you want to prepare the library to open a connection to a given host/port
with the orientdb binary protocol. No real connection will be made here.
The o_prepare_user() function will setup the library to use the given user/password for operations on orientdb. Administrative
tasks on the DB that make use of the CONNECT binary method can be performed by administrators. You can specify which administrative account
will be used by the library passing the "ORIENT_ADMIN" attribute. For normal operations you can use the "ORIENT_USER" attribute instead.
This way you can specify which DB user to use for normal and administrative tasks, letting the library to do all the work for you,
for free.
With o_connect() you will create the real connection to the specified host, on the specified port, with the specified protocol
(only the binary protocol is supported by now, but we are working on REST api as well).
Once successfully connected you can interact with the DB in the cloud, for example opening the DB first.
You can do it using the o_bin_dbopen() call. You could also use multiple opened DBs in parallel using diffenent
o_connect() returned objects.
After the DB is opened, if your access credentials are OK, you can for example retrieve an object from the DB with o_bin_recordload(),
then close the database with o_bin_dbclose(), close the connection with o_close() and free things with o_free().
As you know well, the C language does not have the concept of "objects",
and all the OOP stuff cannot be done natively in C.
So, this also means that it shouldn't be possible to access the simple or complex structured objects saved into (nuvolabase.com) OrientDB...
we are talking about integers, shorts, longs, floats, strings, binary, collections (arrays), maps (hash tables), structured
embedded documents (objects inside other objects) and more... Well, this is simply not true!
With NuvolaBase you can access all that stuff from your C code without too much effort.
You can, for example, iterate on the returned object fields:
...
odoc = o_bin_recordload(oh, oc, &tv, 0, cluster_id, cluster_position, "*:-1");
printf("Fields cycle...\n");
ODOC_ITERATE(odoc, field) {
printf("Field name: %s\n", odoc_get_field_name(field));
printf("Field type: %i\n", odoc_get_field_type(field));
}
printf("END of fields cycle.\n\n");
ODOC_FREE_DOCUMENT(odoc);
...
Get a object field by its name, (obtaining real native C data!!):
short shorty;
int inty;
...
odoc = o_bin_recordload(oh, oc, &tv, 0, cluster_id, cluster_position, "*:-1");
// get shorty
field = odoc_get_field_byname(odoc, "shorty");
shorty = odoc_get_short(field);
printf("Field value: %i\n", shorty);
// get inty
field = odoc_get_field_byname(odoc, "inty");
inty = odoc_get_short(field);
printf("Field value: %i\n", inty);
ODOC_FREE_DOCUMENT(odoc);
...
Or simply get some info about a field by its name, for example the field type (short, int, string, etc):
...
odoc = o_bin_recordload(oh, oc, &tv, 0, cluster_id, cluster_position, "*:-1");
// get shorty
field = odoc_get_field_byname(odoc, "shorty");
printf("Field type: %i\n", odoc_get_field_type(field));
ODOC_FREE_DOCUMENT(odoc);
...
We are working hard to create the complete library API and odocument handling API documentation set.
Ahh!!! The library to use is called "liborient" (LGPLv3):
https://github.com/dam2k/liborient
Come back soon.