1. Go to this page and download the library: Download cuppett/cakephp-pg_utils 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/ */
sql
CREATE TABLE primary_objects (
id UUID NOT NULL default uuid_generate_v4(),
"name" varchar(255) not null,
description text,
created timestamp with time zone not null default CURRENT_TIMESTAMP,
modified timestamp with time zone not null default CURRENT_TIMESTAMP,
searchable_text tsvector
);
CREATE OR REPLACE FUNCTION updateVector() RETURNS trigger AS $$
BEGIN
NEW.searchable_text =
setweight(to_tsvector('pg_catalog.english', coalesce(NEW."name", '')), 'A') ||
setweight(to_tsvector('pg_catalog.english', coalesce(NEW.description, '')), 'D');
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER indexObjects
BEFORE INSERT OR UPDATE OF "name", description ON primary_objects
FOR EACH ROW
EXECUTE PROCEDURE updateVector();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.