Loading plugins/content/content.cpp +31 −0 Original line number Diff line number Diff line Loading @@ -706,6 +706,37 @@ namespace blogi { } return true; } void Search(const int tid, const char* word, blogi::SearchRet& result, const char* sessionid){ std::vector<char> buf; blogi::SQL sql; blogi::DBResult res; sql << "SELECT title,descrition,id FROM content WHERE title @@ to_tsquery('" << word <<"') OR descrition @@ to_tsquery('" << word <<"') OR text @@ to_tsquery('" << word <<"');"; int count=Args->database[tid]->exec(&sql,res); for (int i=0; i < count; ++i) { SearchRet::Data data; data.title=res[i][0]; std::copy(res[i][1],res[i][1]+strlen(res[i][1]),std::back_inserter(data.text)); data.text.push_back('\0'); char url[512]; std::string surl=Args->config->buildurl("content/read/",url,512); surl+=res[i][2]; data.anchor=surl; result.push_back(data); } } }; }; Loading Loading
plugins/content/content.cpp +31 −0 Original line number Diff line number Diff line Loading @@ -706,6 +706,37 @@ namespace blogi { } return true; } void Search(const int tid, const char* word, blogi::SearchRet& result, const char* sessionid){ std::vector<char> buf; blogi::SQL sql; blogi::DBResult res; sql << "SELECT title,descrition,id FROM content WHERE title @@ to_tsquery('" << word <<"') OR descrition @@ to_tsquery('" << word <<"') OR text @@ to_tsquery('" << word <<"');"; int count=Args->database[tid]->exec(&sql,res); for (int i=0; i < count; ++i) { SearchRet::Data data; data.title=res[i][0]; std::copy(res[i][1],res[i][1]+strlen(res[i][1]),std::back_inserter(data.text)); data.text.push_back('\0'); char url[512]; std::string surl=Args->config->buildurl("content/read/",url,512); surl+=res[i][2]; data.anchor=surl; result.push_back(data); } } }; }; Loading