void Query::proc(SQLQueryParms& p) { sbuffer_.str(""); for (std::vector<SQLParseElement>::iterator i = parse_elems_.begin(); i != parse_elems_.end(); ++i) { MYSQLPP_QUERY_THISPTR << i->before; int num = i->num; if (num >= 0) { SQLQueryParms* c; if (size_t(num) < p.size()) { c = &p; } else if (size_t(num) < def.size()) { c = &def; } else { *this << " ERROR"; throw BadParamCount( "Not enough parameters to fill the template."); } SQLString& param = (*c)[num]; SQLString* ss = pprepare(i->option, param, c->bound()); MYSQLPP_QUERY_THISPTR << *ss; if (ss != ¶m) { // pprepare() returned a new string object instead of // updating param in place, so we need to delete it. delete ss; } } } }
void SQLQuery::proc(SQLQueryParms& p) { seekg (0,ios::beg); seekp (0,ios::beg); char num; SQLString *ss; SQLQueryParms *c; for (vector<SQLParseElement>::iterator i = parsed.begin(); i != parsed.end(); i++) { *this << i->before; num = i->num; if (num == -1) { // do nothing } else { if (num < (int)p.size()) c = &p; else if (num < (int)def.size()) c = &def; else { *this << " ERROR"; throw SQLQueryNEParms("Not enough parameters to fill the template."); } ss = pprepare(i->option, (*c)[num], c->bound()); *this << *ss; if (ss != &(*c)[num]) delete ss; } } }