Zmiana zapytania do bazy z lua do C++.

0

witam w jaki sposób mogę to dodać
query("UPDATE z_shop_history_itemSETtrans_state='realized', trans_real=" .. os.time() .. " WHERE id = " .. id .. ";")
do tego

   void Game::checkShopItems(Player* player)
{
    if(!player)
        return;

    Database* db = Database::getInstance();
    DBQuery query;
    DBResult* result;
    std::stringstream informacja;
    query << "SELECT * FROM `z_ots_comunication` WHERE `name` " << db->getStringComparisonOperator() << db->escapeString(player->getName());
    if(!(result = db->storeQuery(query.str())))
        return;
    do
    {
        if(result->getDataString("action") == "give_item")
        {
            uint32_t id = result->getDataInt("id");
            uint16_t itemid = atoi(result->getDataString("param1").c_str());
            uint8_t count = atoi(result->getDataString("param2").c_str());
            std::string itemname = result->getDataString("param6");
            Item* item = Item::CreateItem(itemid,count);
            if(player->addItem(item))
            {
                informacja << "You received " << itemname << " from SMS-SHOP.";
                query.str("");
                query << "DELETE FROM `z_ots_comunication` WHERE `id` = " << id;
                db->executeQuery(query.str());
                player->sendTextMessage(MSG_EVENT_DEFAULT, informacja.str().c_str());
                informacja.str("");
            }
            else
            {
                informacja << "I can't add a item from SMS shop! Make a free place and relog.";
                player->sendTextMessage(MSG_EVENT_DEFAULT, informacja.str().c_str());
                informacja.str("");
            }

        }
    }
    while(result->next());

    result->free();
}
0

ref

0

ref

0

ref

1

ref

0

ref

0
   void Game::checkShopItems(Player* player)
{
    if(!player)
        return;
 
    Database* db = Database::getInstance();
    DBQuery query;
    DBResult* result;
    std::stringstream informacja;
    query << "SELECT * FROM `z_ots_comunication` WHERE `name` " << db->getStringComparisonOperator() << db->escapeString(player->getName());
    if(!(result = db->storeQuery(query.str())))
        return;
    do
    {
        if(result->getDataString("action") == "give_item")
        {
            uint32_t id = result->getDataInt("id");
            uint16_t itemid = atoi(result->getDataString("param1").c_str());
            uint8_t count = atoi(result->getDataString("param2").c_str());
            std::string itemname = result->getDataString("param6");
            Item* item = Item::CreateItem(itemid,count);
            if(player->addItem(item))
            {
                informacja << "You received " << itemname << " from SMS-SHOP.";
                query.str("");
                query << "DELETE FROM `z_ots_comunication` WHERE `id` = " << id;
                db->executeQuery(query.str());
                player->sendTextMessage(MSG_EVENT_DEFAULT, informacja.str().c_str());
                informacja.str("");
            }
            else
            {
                informacja << "I can't add a item from SMS shop! Make a free place and relog.";
                player->sendTextMessage(MSG_EVENT_DEFAULT, informacja.str().c_str());
                informacja.str("");
            }
 
        }
    }
    while(result->next());
 
    result->free();
}
query("UPDATE `z_shop_history_item` SET `trans_state`='realized', `trans_real`=" .. os.time() .. " WHERE id = " .. id .. ";")

dodałem za ciebie. nie dziękuj

1 użytkowników online, w tym zalogowanych: 0, gości: 1