PHP code example of shibudb-org / shibudb-client-php
1. Go to this page and download the library: Download shibudb-org/shibudb-client-php 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/ */
shibudb-org / shibudb-client-php example snippets
ent = new ShibuDbClient('localhost', 4444);
$client->authenticate('admin', 'admin');
reate client and authenticate
$client = new ShibuDbClient('localhost', 4444);
$client->authenticate('admin', 'admin');
// Your operations here
$response = $client->listSpaces();
print_r($response);
// Close connection (or let destructor handle it)
$client->close();
// Using the convenience function
$client = shibudb_connect('localhost', 4444, 'admin', 'admin');
$response = $client->listSpaces();
$client->close();
reate a connection pool
$pool = new ShibuDbConnectionPool(
'localhost', 4444, // host, port
'admin', 'admin', // username, password
30, 2, 10, 30 // timeout, min_size, max_size, acquire_timeout
);
// Use pooled connections
$client = $pool->getConnection();
$response = $client->listSpaces();
print_r($response);
$pool->releaseConnection($client);
// Get pool statistics
$stats = $pool->getStats();
print_r($stats);
// Close pool
$pool->close();
// Create and use a space
$client->createSpace('mytable', 'key-value');
$client->useSpace('mytable');
// Basic operations
$client->put('name', 'John Doe');
$response = $client->get('name');
echo $response['value']; // "John Doe"
$client->delete('name');
// Create a vector space
$client->createSpace('vectors', 'vector', 128, 'Flat', 'L2');
$client->useSpace('vectors');
// Insert vectors
$client->insertVector(1, array(0.1, 0.2, 0.3, /* ... */));
$client->insertVector(2, array(0.4, 0.5, 0.6, /* ... */));
// Search for similar vectors
$results = $client->searchTopk(array(0.1, 0.2, 0.3, /* ... */), 5);
echo $results['message']; // Search results
// Range search
$results = $client->rangeSearch(array(0.1, 0.2, 0.3, /* ... */), 0.5);
// Delete a vector by ID
$client->deleteVector(1);
new ShibuDbClient($host = 'localhost', $port = 4444, $timeout = 30)
error_reporting(E_ALL);
ini_set('display_errors', 1);
// Your ShibuDb code here
bash
php simple_test.php
bash
php example.php
bash
php pool_test.php
bash
php comprehensive_pool_test.php
bash
# Tests that php
php pool_test.php
php comprehensive_pool_test.php
# Tests that run without server
php json_parsing_test.php
php special_chars_test.php
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.