]> git.nothing2do.fr Git - diary-shell/commitdiff
I've tryed to put the default command into SQL (but this isn't done)
authorNorbert Moutarde <norbert.moutarde@nothing2do.eu>
Tue, 23 Jul 2013 07:59:11 +0000 (09:59 +0200)
committerNorbert Moutarde <norbert.moutarde@nothing2do.eu>
Tue, 23 Jul 2013 07:59:11 +0000 (09:59 +0200)
sqldb.cpp

index 292f57d5080d54f9a73422743fa4caa299038487..a6fa671a02399f4ae267117737f9d1d9616e296f 100644 (file)
--- a/sqldb.cpp
+++ b/sqldb.cpp
@@ -50,20 +50,21 @@ template<typename T> string sqlpg::toString( const T & Value ){
 int sqlpg::insert(vector<string> text) {
     clog<<"insert(vector<string>) begin\n";
 
+    string command="INSERT INTO raw (date, texte) VALUES ($1::timestamp, $2::text);";/*PQgetvalue(res, 0, 0);*/
+    clog<<"commande : "<<command<<endl;
 
-    string command="INSERT INTO raw (date, texte) VALUES ($1::timestamp, $2::text);";
     string tmp="";
     int argc=2;
     const char * value[2];
     int length[2];
     int binary[2];
     PQprepare(conn, "insert", command.c_str(), 2, NULL);
-
+    string a;
     if (text.size()>2){
         if ((isdate(text[0]))+(isdate(text[1]))==3){
             clog<<"text[0]+text[1]==3(L55)\n";
             date=text[0];
-            string a=date+" "+text[1];
+            a=date+" "+text[1];
             value[0]=a.c_str();
             length[0]=a.size();
             binary[0]=0;
@@ -80,7 +81,7 @@ int sqlpg::insert(vector<string> text) {
         else if((text[0]=="-")&&(isdate(text[1])==2)){
             clog<<"date partielle(L72)\n";
             tmp=text[2];
-            string a=date+" "+text[1];
+            a=date+" "+text[1];
             value[0]=a.c_str();
             length[0]=a.size();
             binary[0]=0;
@@ -95,9 +96,12 @@ int sqlpg::insert(vector<string> text) {
 
         }
         else{
-            clog<<"text.size()>2 && text[0] & text[1] isn't date. L89";
+            clog<<"text.size()>2 && text[0] & text[1] isn't date. L101";
             tmp=text[0];
-            string a="1971-11-11 22:22:22";
+            a="now";
+            for (int i=1;i<text.size(); i++){
+                tmp=tmp+" "+text[i];
+            }
             value[0]=a.c_str();
             length[0]=a.size();
             binary[0]=0;
@@ -105,13 +109,9 @@ int sqlpg::insert(vector<string> text) {
             value[1]=tmp.c_str();
             length[1]=tmp.size();
             binary[1]=0;
-            for (int a=1;a<text.size(); a++){
-                tmp=tmp+" "+text[a];
-            }
             //command="INSERT INTO raw (date, texte) VALUES ('now()', '"+tmp+"')";
 
         };
-
     }
     else {
         clog<<"text.size()<2\n";