Beispiel #1
0
	void submit(SQLQuery *req, const std::string& q, const ParamL& p)
	{
		std::string res;
		unsigned int param = 0;
		for(std::string::size_type i = 0; i < q.length(); i++)
		{
			if (q[i] != '?')
				res.push_back(q[i]);
			else
			{
				if (param < p.size())
				{
					std::string parm = p[param++];
					std::vector<char> buffer(parm.length() * 2 + 1);
#ifdef PGSQL_HAS_ESCAPECONN
					int error;
					size_t escapedsize = PQescapeStringConn(sql, &buffer[0], parm.data(), parm.length(), &error);
					if (error)
						ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "BUG: Apparently PQescapeStringConn() failed");
#else
					size_t escapedsize = PQescapeString(&buffer[0], parm.data(), parm.length());
#endif
					res.append(&buffer[0], escapedsize);
				}
			}
		}
		submit(req, res);
	}
Beispiel #2
0
 void submit(SQLQuery* query, const std::string& q, const ParamL& p)
 {
     std::string res;
     unsigned int param = 0;
     for(std::string::size_type i = 0; i < q.length(); i++)
     {
         if (q[i] != '?')
             res.push_back(q[i]);
         else
         {
             if (param < p.size())
             {
                 char* escaped = sqlite3_mprintf("%q", p[param++].c_str());
                 res.append(escaped);
                 sqlite3_free(escaped);
             }
         }
     }
     submit(query, res);
 }