PHP code example of clusterpoint / php-client-api-v4

1. Go to this page and download the library: Download clusterpoint/php-client-api-v4 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/ */

    

clusterpoint / php-client-api-v4 example snippets



 if you installed api without composer:
// ice
$cp = new Client([
	'host' => 'https://api-eu.clusterpoint.com/v4',
	'account_id' => '1',
	'username' => 'root',
	'password' => 'password',
	'debug' => true,
]);

// Set the database.collection to initalize the query builder for it.
$bikes = $cp->database("shop.bikes");

// Build your query
$results = $bikes->where('color', 'red')
	->where('availability', true)
	->limit(5)
	->groupBy('category')
	->orderBy('price')
	->select(['name', 'color', 'price', 'category'])
	->get();

// Access your results
echo "First bike price: ".$results[0]->price;