25.07.2013, 16:09
Helllo, I have another problem I can't solve.
If I insert query then How I get the ID of the INSERTED query?
The Code:
The public function
And saveFunriture stck:
Thanks.
If I insert query then How I get the ID of the INSERTED query?
The Code:
PHP Code:
if(EDIT_OBJ_ID[playerid]) {
SetDynamicObjectPos(EDIT_OBJ_ID[playerid], x, y, z);
SetDynamicObjectRot(EDIT_OBJ_ID[playerid], rx, ry, rz);
EDIT_OBJ_ID[playerid] = objectid;
furnitureVariables[EDIT_OBJ_ID[playerid]][fFurniturePos][0] = x;
furnitureVariables[EDIT_OBJ_ID[playerid]][fFurniturePos][1] = y;
furnitureVariables[EDIT_OBJ_ID[playerid]][fFurniturePos][2] = z;
furnitureVariables[EDIT_OBJ_ID[playerid]][fFurnitureRot][0] = rx;
furnitureVariables[EDIT_OBJ_ID[playerid]][fFurnitureRot][1] = ry;
furnitureVariables[EDIT_OBJ_ID[playerid]][fFurnitureRot][2] = rz;
furnitureVariables[EDIT_OBJ_ID[playerid]][fFurnitureHouseID] = getPlayerHouseID(playerid);
furnitureVariables[EDIT_OBJ_ID[playerid]][fFurnitureINT] = GetPlayerInterior(playerid);
furnitureVariables[EDIT_OBJ_ID[playerid]][fFurnitureVW] = GetPlayerVirtualWorld(playerid);
if(isnull(furnitureVariables[EDIT_OBJ_ID[playerid]][fFurniturePlanter])) {
furnitureVariables[EDIT_OBJ_ID[playerid]][fFurniturePlanter] = playerVariables[playerid][pNormalName];
format(szQueryInput, sizeof(szQueryInput), "INSERT INTO furniture (objectModelID, objectPosX, objectPosY, objectPosZ, objectHouseID, objectRotX, objectRotY, objectRotZ, objectPlanterName, objectVW, objectINT) VALUES ('%d', '%f', '%f', '%f', '%d', '%f', '%f', '%f', '%s', '%d', '%d')", furnitureVariables[EDIT_OBJ_ID[playerid]][fFurnitureOID],
furnitureVariables[EDIT_OBJ_ID[playerid]][fFurniturePos][0], furnitureVariables[EDIT_OBJ_ID[playerid]][fFurniturePos][1], furnitureVariables[EDIT_OBJ_ID[playerid]][fFurniturePos][2], furnitureVariables[EDIT_OBJ_ID[playerid]][fFurnitureHouseID],
furnitureVariables[EDIT_OBJ_ID[playerid]][fFurnitureRot][0], furnitureVariables[EDIT_OBJ_ID[playerid]][fFurnitureRot][1], furnitureVariables[EDIT_OBJ_ID[playerid]][fFurnitureRot][2], furnitureVariables[EDIT_OBJ_ID[playerid]][fFurniturePlanter],furnitureVariables[EDIT_OBJ_ID[playerid]][fFurnitureINT],furnitureVariables[EDIT_OBJ_ID[playerid]][fFurnitureVW]);
mysql_function_query(connection, szQueryInput, true, "insertFurniture", "d", playerid);
#if defined DEBUG
printf("%s", szQueryInput);
#endif
EDIT_OBJ_ID[playerid] = 0;
pEDIT_OBJ[playerid] = 0;
} else if(!isnull(furnitureVariables[EDIT_OBJ_ID[playerid]][fFurniturePlanter])) {
saveFurniture(EDIT_OBJ_ID[playerid]);
EDIT_OBJ_ID[playerid] = 0;
pEDIT_OBJ[playerid] = 0;
}
}
PHP Code:
public insertFurniture(playerid) {
furnitureVariables[EDIT_OBJ_ID[playerid]][fFurnitureID] = mysql_insert_id();
return 1;
}
PHP Code:
public saveFurniture(furnitureID) {
format(szQueryInput, sizeof(szQueryInput), "UPDATE furniture SET objectModelID = '%d', objectPosX = '%f', objectPosY = '%f', objectPosZ = '%f', objectHouseID = '%d', objectRotX = '%f', objectRotY = '%f', objectRotZ = '%f', objectPlanterName = '%s', objectVW = '%d', objectINT = '%d'",
furnitureVariables[furnitureID][fFurnitureOID], furnitureVariables[furnitureID][fFurniturePos][0], furnitureVariables[furnitureID][fFurniturePos][1], furnitureVariables[furnitureID][fFurniturePos][2], furnitureVariables[furnitureID][fFurnitureHouseID], furnitureVariables[furnitureID][fFurnitureRot][0], furnitureVariables[furnitureID][fFurnitureRot][1], furnitureVariables[furnitureID][fFurnitureRot][2], furnitureVariables[furnitureID][fFurniturePlanter],
furnitureVariables[furnitureID][fFurnitureVW], furnitureVariables[furnitureID][fFurnitureINT]);
format(szQueryInput, sizeof(szQueryInput), "%s WHRE objectID = '%d'", szQueryInput, furnitureVariables[furnitureID][fFurnitureID]);
#if defined DEBUG
printf("%s", szQueryInput);
#endif
return 1;
}