PyRep *SearchDB::Query(std::string match, std::vector<int> *searchID) { DBQueryResult res; DBResultRow row; std::string id; uint32 i,size; std::string equal = ""; std::string matchEsc = ""; // Find out if search is exact or not and remove the trailing '*' std::size_t found=match.find('*'); if (found!=std::string::npos) { match.erase (std::remove(match.begin(), match.end(), '*'), match.end()); equal = " RLIKE "; } else { equal = " = "; } // Escape the searchString sDatabase.DoEscapeString(matchEsc, match.c_str()); // The client wants a dict in return // [searchID][Results] PyDict *dict = new PyDict(); size = searchID->size(); for(i=0; i<size; i++){ switch(searchID->at(i)) { case 1: //searchResultAgent = 1 sDatabase.RunQuery(res, "SELECT" " itemID AS agentID" " FROM entity" " WHERE itemName %s '%s' " " AND itemID BETWEEN 2999999 AND 4000000 " " LIMIT 0, 10", equal.c_str(), matchEsc.c_str() ); break; case 2: //searchResultCharacter = 2 sDatabase.RunQuery(res, "SELECT" " itemID" " FROM entity" " WHERE itemName %s '%s' " " AND itemId >= %u" " AND ownerID = 1",equal.c_str(), matchEsc.c_str(),EVEMU_MINIMUM_ID ); break; case 3: //searchResultCorporation = 3 sDatabase.RunQuery(res, "SELECT" " corporationID" " FROM corporation" " WHERE corporationName %s '%s' " " LIMIT 0, 10", equal.c_str(), matchEsc.c_str() ); break; case 4: //searchResultAlliance = 4 sDatabase.RunQuery(res, "SELECT allianceID" " FROM alliance_ShortNames" " WHERE shortName %s '%s'" " LIMIT 0, 10", equal.c_str(), matchEsc.c_str() ); break; case 5: //searchResultFaction = 5 sDatabase.RunQuery(res, "SELECT factionID" " FROM chrFactions" " WHERE factionName %S '%s' " " LIMIT 0, 10", equal.c_str(), matchEsc.c_str() ); break; case 6: //searchResultConstellation = 6 sDatabase.RunQuery(res, "SELECT" " constellationID" " FROM mapConstellations" " WHERE constellationName %s '%s' " " LIMIT 0, 10", equal.c_str(), matchEsc.c_str() ); break; case 7: //searchResultSolarSystem = 7 sDatabase.RunQuery(res, "SELECT " " solarSystemID" " FROM mapSolarSystems" " WHERE solarSystemName %s '%s' " " LIMIT 0, 10", equal.c_str(), matchEsc.c_str() ); break; case 8: //searchResultRegion = 8 sDatabase.RunQuery(res, "SELECT " " regionID" " FROM mapRegions" " WHERE regionName %s '%s' " " LIMIT 0, 10", equal.c_str(), matchEsc.c_str() ); break; case 9: //searchResultStation = 9 sDatabase.RunQuery(res, "SELECT " " stationID" " FROM staStations " " WHERE stationName %s '%s' " " LIMIT 0, 10", equal.c_str(), matchEsc.c_str() ); break; case 10: //searchResultInventoryType = 10 sDatabase.RunQuery(res, "SELECT" " typeID" " FROM entity" " WHERE itemName %s '%s'", equal.c_str(), matchEsc.c_str() ); break; } dict->SetItem(new PyInt(searchID->at(i)),DBResultToIntIntDict(res)); res.Reset(); } return dict; }
PyRep *ConfigDB::GetMultiOwnersEx(const std::vector<int32> &entityIDs) { #ifndef WIN32 #warning we need to deal with corporations! #endif //im not sure how this query is supposed to work, as far as what table //we use to get the fields from. //we only get called for items which are not already sent in the // eveStaticOwners cachable object. std::string ids; ListToINString(entityIDs, ids, "-1"); DBQueryResult res; DBResultRow row; if(!sDatabase.RunQuery(res, "SELECT " " entity.itemID as ownerID," " entity.itemName as ownerName," " entity.typeID," " NULL as ownerNameID," " 0 as gender" " FROM entity " " WHERE itemID in (%s)", ids.c_str())) { codelog(SERVICE__ERROR, "Error in query: %s", res.error.c_str()); return NULL; } //this is pretty hackish... will NOT work if they mix things... //this was only put in to deal with "new" statics, like corporations. if(!res.GetRow(row)) { if(!sDatabase.RunQuery(res, "SELECT " " ownerID,ownerName,typeID," " NULL as ownerNameID," " 0 as gender" " FROM eveStaticOwners " " WHERE ownerID in (%s)", ids.c_str())) { codelog(SERVICE__ERROR, "Error in query: %s", res.error.c_str()); return NULL; } } else { res.Reset(); } if(!res.GetRow(row)) { if(!sDatabase.RunQuery(res, "SELECT " " characterID as ownerID," " itemName as ownerName," " typeID," " NULL as ownerNameID," " 0 as gender" " FROM character_ " " LEFT JOIN entity ON characterID = itemID" " WHERE characterID in (%s)", ids.c_str())) { codelog(SERVICE__ERROR, "Error in query: %s", res.error.c_str()); return NULL; } } else { res.Reset(); } return(DBResultToTupleSet(res)); }