In my laravel project I have the following table named search_index
:
ik SERIAL PK
name VARCHAR
value ts_vector
And for this table I have the following model:
namespace AppModel;
use IlluminateDatabaseEloquentModel;
/**
* @property integer id
* @property string name
* @property string value
*/
class SearchIndex extends Model
{
}
And I want to insert an new record to the table:
$search_index = new SearchIndex();
$search_index->name = 'lorem_impsum';
$search_index->value = 'lorem ipsum dolores omea wa mou shindeiru';
$search_index->save();
What I want to do is once I set the value
property into SearchIndex
to run through to_tsvector()
once I save it. In other wotds I want the equivalent query to be:
INSERT INTO search_index(name,value) values ('lorem_impsum', to_tsvector('lorem ipsum dolores omea wa mou shindeiru'));
Do you know how I can do this?
question from:
https://stackoverflow.com/questions/65847371/how-i-can-insert-a-value-to-a-model-that-is-type-ts-vector 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…