-INSERT INTO alias (nom, cmd, argc) VALUES ('ls', 'select id,texte from raw order by date asc;', 0)
+INSERT INTO alias (nom, cmd, argc) VALUES ('ls', 'select id,texte from raw order by date asc;', 0);
+INSERT INTO alias (nom, cmd, argc) VALUES ('search', 'select id, texte from raw where texte like \'%1\' order by date asc', 1);
+INSERT INTO alias (nom, cmd, argc) VALUES ('rm', 'DELETE FROM raw WHERE id =\'%1\';', 1);
+INSERT INTO alias (nom, cmd, argc) VALUES ('alias', 'select nom from alias;', 0);
else if (words[0]=="p") diary.print();
else if (words[0]=="help") help();
else if (words[0]=="status") diary.status();
- else if (words[0]=="rm"){// little useless
- if (words.size()==2){// cmd : rm "id"
- diary.deletetuple(words[1]);
- }
- else if (words.size()==3){// cmd : rm "date1" "date2"
- string date1=words[1], date2=words[2];
- diary.deletedate(date1, date2);
- }
- }
+
else if (words[0]=="var") diary.var();
else if (words[0]=="now") cout<<now()<<endl;
else if (words[0]=="alias") {
exec(command);
return 0;
}
-vector< vector <string> > sqlpg::list(string a){
- vector<string> tmp;
- string command;
- ret.clear();
- command="SELECT * FROM "+a+" ORDER BY date ASC;";//PQfname(res, 0) can't works here !
-
- //cout<<command<<endl;
- //res=PQexec(conn, command.c_str());
- exec(command);
- for (int i=0; i<PQntuples(res); i++){
- for (int j=0; j<PQnfields(res); j++){
- tmp.push_back(PQgetvalue(res, i, j));
- };
- ret.push_back(tmp);
- tmp.clear();
- };
- return ret;
-}
-std::vector < std::vector <std::string> > sqlpg::listdate(string begin, string end){
- vector<string> tmp;
- string command;
- ret.clear();
- command="SELECT * FROM raw WHERE date BETWEEN '"+begin+"' AND '"+end+"';";
- //cout<<command<<endl;
- /*res=PQexec(conn, command.c_str());
- testSQL();*/
- exec(command);
- for (int i=0; i<PQntuples(res); i++){
- for (int j=0; j<PQnfields(res); j++){
- tmp.push_back(PQgetvalue(res, i, j));
- };
- ret.push_back(tmp);
- tmp.clear();
- };
- return ret;
-};
-void sqlpg::deletetuple(string tmp){
- string command;
- command="DELETE FROM raw WHERE id ='" + tmp + "'";
- /*res=PQexec(conn, command.c_str());
- testSQL();*/
- exec(command);
- //cout<<command<<endl;
-}
void sqlpg::deletedate(string a, string b){
string command;
command="delete from raw where date between '"+a+"' and '"+b+"';";