1. Go to this page and download the library: Download colopl/laravel-spanner 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/ */
// There are four types of timestamp bounds: ExactStaleness, MaxStaleness, MinReadTimestamp and ReadTimestamp.
$timestampBound = new ExactStaleness(10);
// by Connection
$connection->selectWithTimestampBound('SELECT ...', $bindings, $timestampBound);
// by Query Builder
$queryBuilder
->withStaleness($timestampBound)
->get();
// Using Connection
$connection->selectWithOptions('SELECT ...', $bindings, ['dataBoostEnabled' => true]);
// Using Query Builder
$queryBuilder
->useDataBoost()
->setRequestTimeoutSeconds(60)
->get();
$schemaBuilder->create('user', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->string('name');
// adds an invisible column for full text search
$table->tokenList('UserNameTokens', TokenizerFunction::FullText, 'name', ['language_tag' => 'en']);
// adds a SEARCH INDEX
$table->fullText(['UserNameTokens']);
});
User::query()->searchFullText('UserNameTokens', 'John OR Kevin', ['enhance_query' => true])->get();