Exemple #1
0
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;
        }
    }
}
Exemple #2
0
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 != &param) {
				// pprepare() returned a new string object instead of
				// updating param in place, so we need to delete it.
				delete ss;
			}
		}
	}
}
Exemple #3
0
SQLQueryParms SQLQueryParms::operator + (const SQLQueryParms &other) const {
    if (other.size() <= size()) return *this;
    SQLQueryParms New = *this;
    unsigned int i;
    for(i = size(); i < other.size(); i++) {
        New.push_back(other[i]);
    }
    return New;
}