1. Go to this page and download the library: Download zteradb/zteradb-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/ */
zteradb / zteradb-php example snippets
ZTeraDB\Config\ZTeraDBConfig;
use ZTeraDB\Connection\ZTeraDBConnection;
use ZTeraDB\Query\ZTeraDBQuery;
use ZTeraDB\Config\ResponseDataTypes;
use ZTeraDB\Config\ENVS;
// 1. Setup Configuration
$config = new ZTeraDBConfig([
'client_key' => getenv('ZTERADB_CLIENT_KEY'),
'access_key' => getenv('ZTERADB_ACCESS_KEY'),
'secret_key' => getenv('ZTERADB_SECRET_KEY'),
'database_id' => getenv('ZTERADB_DATABASE_ID'),
'env' => ENVS::dev,
'response_data_type' => ResponseDataTypes::json,
]);
// 2. Initialize Connection
$db = new ZTeraDBConnection(
getenv("ZTERADB_HOST"),
getenv("ZTERADB_PORT"),
$config
);
// 3. Build ZQL Query
$query = (new ZTeraDBQuery("user"))->select();
// 4. Execute and Stream Results
foreach ($db->run($query) as $row) {
print_r($row);
}
// 5. Close Connection
$db->close();