PHP code example of bdus-db / bdus-api-php-client
1. Go to this page and download the library: Download bdus-db/bdus-api-php-client 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/ */
bdus-db / bdus-api-php-client example snippets
BdusApiPhpClient\BdusApiPhpClient;
dusApiPhpClient\BdusApiPhpClient;
$api = new BdusApiPhpClient('https://bdus.cloud/db/api/', 'ghazni');
$api->getApiVersion();
[
'version' => '4.0.0-alpha.220',
]
// Gets unique values for column `provevance` of table `finds`
$api->getUniqueVal('finds', 'provevance');
[
'Tapa Sardar, Vihara 17',
'Ghazni, Ghaznavid Palace Area',
'Ghazni, Ghaznavid Palace',
'Tapa Sardar, Room 36',
'Tapa Sardar, Upper Terrace',
'Tapa Sardar, II terrace',
'Tapa Sardar, Area 64-100',
...
]
// Gets unique values for column `provevance` of table `finds`, get only values containing `Tapa`
$api->getUniqueVal('finds', 'provevance', 'Tapa');
[
'Tapa Sardar, Vihara 17',
'Tapa Sardar, Room 36',
'Tapa Sardar, Upper Terrace',
'Tapa Sardar, II terrace',
'Tapa Sardar, Area 64-100',
...,
]
// Gets unique values for column `provevance` of table `finds`, get only values containing `Tapa` and limit search only to records having `Late period` in `relative_chronology` column
$api->getUniqueVal('finds', 'provevance', 'Tapa', 'relative_chronology|=|Late period');
[
'Tapa Sardar, Vihara 17',
'Tapa Sardar, Room 36',
'Tapa Sardar, Upper Terrace',
'Tapa Sardar, Vihara 37',
'Tapa Sardar, Vihara 23',
...,
]
$api->inspect();
[
'finds' => [
'name' => 'ghazni__finds',
'label' => 'Finds',
'order' => 'inv_no',
'id_field' => 'inv_no',
'preview' => [
'inv_no',
'archaeological_context',
...
],
'plugin' => [
'ghazni__m_biblio',
'ghazni__m_inscriptions',
...
],
'link' => [
[
'other_tb' => 'ghazni__funcomplex',
'fld' => [
[
'my' => 'funcomplex',
'other' => 'id',
]
]
]
],
'fields' => [
'id' => [
'name' => 'id',
'label' => 'ID',
...
],
'creator' => [
'name' => 'creator',
'label' => 'Creator',
'type' => 'text',
'hide' => '1',
'fullname' => 'ghazni__finds:ghazni__finds',
],
'inv_no' => [
'name' => 'inv_no',
'label' => 'Inventory no.',
'type' => 'text',
'check' => [
'no_dupl',
],
'fullname' => 'ghazni__finds:ghazni__finds',
],
'archaeological_context' => [
'name' => 'archaeological_context',
'label' => 'Cultural context',
'type' => 'combo_select',
'vocabulary_set' => 'archaeo_context',
'fullname' => 'ghazni__finds:ghazni__finds',
],
'provenance' => [
'name' => 'provenance',
'label' => 'Provenance',
'type' => 'combo_select',
'get_values_from_tb' => 'ghazni__finds:provenance',
'fullname' => 'ghazni__finds:ghazni__finds',
],
...
],
'stripped_name' => 'finds',
],
'excavations' => [
'name' => 'ghazni__excavations',
'label' => 'Excavations',
'order' => 'name',
'id_field' => 'name',
'preview' => [
'name',
'authors',
'start_year',
'end_year',
],
'fields' => [
'id' => [
'name' => 'id',
'type' => 'text',
'hide' => true,
'fullname' => 'ghazni__excavations:ghazni__excavations',
],
'name' => [
'name' => 'name',
'label' => 'Name',
'type' => 'text',
'check' => [
'no_dupl',
],
'fullname' => 'ghazni__excavations:ghazni__excavations',
],
...
],
'stripped_name' => 'excavations',
],
'funcomplex' => [
...
],
'bibliography' => [
...
],
'files' => [
...
],
'm_biblio' => [
...
]
]
$api->inspect('finds');
[
'stripped_name' => 'finds',
'name' => 'ghazni__finds',
'label' => 'Finds',
'order' => 'inv_no',
'id_field' => 'inv_no',
'preview' => [
'inv_no',
...
]
...
]
$api->searchShortSqlObj([
'tb' => 'finds',
'cols' => 'inv_no,archaeological_context,provenance,relative_chronology',
'where' => [
[
'fld' => 'archaeological_context',
'operator' => '=',
'value' => 'Buddhist'
],
[
'connector' => 'and',
'fld' => 'provenance',
'operator' => 'like',
'value' => 'Tapa Sardar'
],
],
]);
[
'head' => [
'total_rows' => 357,
'total_pages' => 12,
'stripped_table' => 'finds',
'table_label' => 'Finds',
'page' => 1,
'no_records_shown' => 30,
'fields' => [
'id' => 'ID',
'creator' => 'Creator',
'inv_no' => 'Inventory no.',
'archaeological_context' => 'Cultural context',
...
],
],
'debug' => false,
'records' => [
[
'id' => '168',
'creator' => '11',
'inv_no' => 'TS00038',
'archaeological_context' => 'Buddhist',
...
],
[
'id' => '678',
'creator' => '11',
...
]
]
]
$api->searchShortSqlObj([
'tb' => 'finds',
'cols' => 'inv_no,archaeological_context,provenance,relative_chronology',
'where' => [
[
'fld' => 'archaeological_context',
'operator' => '=',
'value' => 'Buddhist'
],
[
'connector' => 'and',
'fld' => 'provenance',
'operator' => 'like',
'value' => 'Tapa Sardar'
],
],
], [
'page' => 2
]);
[
'head' => [
'total_rows' => 357,
'total_pages' => 12,
'stripped_table' => 'finds',
'table_label' => 'Finds',
'page' => 2,
...
]
...
]
$api->searchShortSql('@finds~?archaeological_context|=|Buddhist||and|provenance|like|Tapa Sardar');
$api->searchShortSql('@finds~?archaeological_context|=|Buddhist||and|provenance|like|Tapa Sardar', ['page' => 2]);
// Get record with id = 1 from table finds
$api->getOne('finds', '1');
[
'metadata' => [
'tb_id' => 'ghazni__finds',
'rec_id' => [
'name' => 'id',
'label' => 'ID',
'val' => '1',
],
'tb_stripped' => 'finds',
'tb_label' => 'Finds',
],
'core' => [
'id' => [
'name' => 'id',
'label' => 'ID',
'val' => '1',
],
'creator' => [
'name' => 'creator',
'label' => 'Creator',
'val' => NULL,
],
'inv_no' => [
'name' => 'inv_no',
'label' => 'Inventory no.',
'val' => 'TS01092',
],
'archaeological_context' => [
'name' => 'archaeological_context',
'label' => 'Cultural context',
'val' => 'Buddhist',
],
...
],
'plugins' => [
'ghazni__m_biblio' => [
'metadata' => [
'tb_id' => 'ghazni__m_biblio',
'tb_stripped' => 'm_biblio',
'tb_label' => 'Bibliographic data',
'tot' => 2,
],
'data' => [
25 => [
'id' => [
'name' => 'id',
'label' => false,
'val' => '25',
],
'table_link' =>
...
],
],
],
],
'links' => [ ],
'backlinks' => [ ],
'manualLinks' => [ ],
'files' => [
[
'id' => '3',
'creator' => NULL,
'ext' => 'jpg',
'keywords' => NULL,
'description' => NULL,
'printable' => NULL,
'filename' => 'TS 1092',
],
...
],
'geodata' => [ ],
'rs' => [ ],
]