问题描述
在我的 Laravel 项目中,我有一个名为 search_index
的表:
ik SERIAL PK
name VARCHAR
value ts_vector
对于这张表,我有以下模型:
namespace App\Model;
use Illuminate\Database\Eloquent\Model;
/**
* @property integer id
* @property string name
* @property string value
*/
class SearchIndex extends Model
{
}
我想在表中插入一条新记录:
$search_index = new SearchIndex();
$search_index->name = 'lorem_impsum';
$search_index->value = 'lorem ipsum dolores omea wa mou shindeiru';
$search_index->save();
我想要做的是一旦我将 value
属性设置为 SearchIndex
以在保存后运行 to_tsvector()
。在其他 wotds 中,我希望等效的查询是:
INSERT INTO search_index(name,value) values ('lorem_impsum',to_tsvector('lorem ipsum dolores omea wa mou shindeiru'));
你知道我该怎么做吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)