Skip to content

Instantly share code, notes, and snippets.

@CauanCabral
Created February 22, 2015 15:54
Show Gist options
  • Save CauanCabral/6ad346ac2d54ca69e3fe to your computer and use it in GitHub Desktop.
Save CauanCabral/6ad346ac2d54ca69e3fe to your computer and use it in GitHub Desktop.
CakePHP 3.0 - Textual search support in Postgresql
<?php
namespace App\Database\Type;
use Cake\Database\Driver;
use Cake\Database\Type;
use PDO;
class TsvectorType extends Type
{
public function toPHP($value, Driver $driver)
{
if ($value === null) {
return null;
}
return $value;
}
public function toDatabase($value, Driver $driver)
{
return $value;
}
public function toStatement($value, Driver $driver)
{
if ($value === null) {
return PDO::PARAM_NULL;
}
return PDO::PARAM_STR;
}
}
// Load it at bootstrap
// use Cake\Database\Type;
// Type::map('tsvector', 'App\Database\Type\TsvectorType');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment