36 lines
1.1 KiB
PHP
36 lines
1.1 KiB
PHP
<?php
|
|
require __DIR__ . '/vendor/autoload.php';
|
|
$app = require_once __DIR__ . '/bootstrap/app.php';
|
|
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
|
|
$kernel->bootstrap();
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\Schema;
|
|
|
|
try {
|
|
$searchTerm = 'Repair';
|
|
// Test MySQL 8.x word boundary syntax (\b)
|
|
// Note: In ICU, \b is used for word boundaries.
|
|
$results = DB::table('services')
|
|
->whereRaw('name REGEXP ?', ["\\b{$searchTerm}\\b"])
|
|
->limit(1)
|
|
->get();
|
|
|
|
echo "Success with \\b syntax: " . $results->count() . " results found.\n";
|
|
} catch (\Exception $e) {
|
|
echo "Failed with \\b syntax: " . $e->getMessage() . "\n";
|
|
}
|
|
|
|
try {
|
|
$searchTerm = 'Repair';
|
|
// Test the old syntax to confirm it fails (as expected)
|
|
$results = DB::table('services')
|
|
->whereRaw('name REGEXP ?', ["[[:<:]]{$searchTerm}[[:>:]]"])
|
|
->limit(1)
|
|
->get();
|
|
|
|
echo "Unexpectedly worked with [[:<:]] syntax: " . $results->count() . " results found.\n";
|
|
} catch (\Exception $e) {
|
|
echo "Confirmed failure with [[:<:]] syntax: " . $e->getMessage() . "\n";
|
|
}
|