yihang hwang
yihang hwang

Reputation: 419

for loop that batch the data and throw it to MySQL query in c++ part2

code

    void write_token_to_data()
    {

        int count=0;
        string str;
        typedef double* DynamicMatrix[l+m];
        // DynamicMatrix Count;
        typedef double* DynamicMatrix2[l+m];
        //DynamicMatrix2 Prob;
        for(int i=0; i<(l+m); i++)
        {
            for(int j=0; j<(l+m); j++)
            {
                //--------------------------------------------------
                if (count >100 || count == 0)
                {
                    // execute the string
                    //mysqlinsert(str);
                    // initialize str as empty string
                    str = "INSERT INTO EM ( sourceindex,targetindex,source,target) VALUES";
                    count = 0;
                }
                if (count <= 100)
                {
                    // concatinate the string with prev str
                    str +=(i,j,combine[i],combine[j])+',';
                    cout<<str<<endl;
                    count++;
                }

            }
        }
        //outfile.close();
    }//end of function

the question is about the str go to the sql query and i found i cout the code of str and str disapear the '(' ,')' and i and j i and j should be the index number and type is integer how can i change this code without wrong

Upvotes: 0

Views: 43

Answers (1)

Raghaven 3534
Raghaven 3534

Reputation: 296

try like this !!!! Not tested
str += '('+ i +',' + j +',' + combine[i] + ',' + combine[j] ')'+',';

Upvotes: 1

Related Questions