Jump to content
  • 0

item id and mysql


Question

Posted

Hello is possible?

Im with php insered item, example:

INSERT INTO `items` (`owner_id`,`object_id`,`item_id`,`count`,`enchant_level`,`loc`,`loc_data`,`custom_type1`,`custom_type2`,`mana_left`) VALUES ('".$char['obj_Id']."',(SELECT MAX(object_id)+1 FROM items AS object_id),'".$item."','1','".$row['enchant_level']."','INVENTORY',0,0,0,-1)

then at same time game server overwrite me insered item with same object id? because some time it just put without any error, but in table the row wrong.. cant find problem

2 answers to this question

Recommended Posts

  • 0
Posted

this shit replace me insered item from web donate system.

private void updateInDb()
	{
		if (Config.ASSERT)
			assert _existsInDb;
		
		if (_wear)
			return;
		
		if (_storedInDb)
			return;
		
		Connection con = null;
		try
		{
			con = L2DatabaseFactory.getInstance().getConnection(false);
			PreparedStatement statement = con.prepareStatement("UPDATE items SET owner_id=?,count=?,loc=?,loc_data=?,enchant_level=?,price_sell=?,price_buy=?,custom_type1=?,custom_type2=?,mana_left=? " + "WHERE object_id = ?");
			statement.setInt(1, _ownerId);
			statement.setInt(2, getCount());
			statement.setString(3, _loc.name());
			statement.setInt(4, _locData);
			statement.setInt(5, getEnchantLevel());
			statement.setInt(6, _priceSell);
			statement.setInt(7, _priceBuy);
			statement.setInt(8, getCustomType1());
			statement.setInt(9, getCustomType2());
			statement.setInt(10, getMana());
			statement.setInt(11, getObjectId());
			statement.executeUpdate();
			_existsInDb = true;
			_storedInDb = true;
			DatabaseUtils.close(statement);
			statement = null;
			
		}
		catch (final Exception e)
		{
			if (Config.ENABLE_ALL_EXCEPTIONS)
				e.printStackTrace();
			
			LOGGER.error("Could not update item " + getObjectId() + " in DB: Reason: ");
			e.printStackTrace();
		}
		finally
		{
			CloseUtil.close(con);
			con = null;
			
		}
		
		if (_existsInDb)
			fireEvent(EventType.STORE.name, (Object[]) null);
	}

any solution? or ideas?

  • 0
Posted

ok found one solution. I see all object id start at 26*******, example 268438424, for web donate system i make start id 16*******, example 160000001 with incresement, maybe its not good?

so why in every server object id start with 26*******???

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...