Created
February 22, 2015 15:54
-
-
Save CauanCabral/6ad346ac2d54ca69e3fe to your computer and use it in GitHub Desktop.
CakePHP 3.0 - Textual search support in Postgresql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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