Minecraft Spigot create a New PlayerInventory - minecraft

So I want to create a new PlayerInventory, and am not sure if this is the way to go about it.
PlayerInventory inv = (PlayerInventory) Bukkit.createInventory(null, InventoryType.PLAYER);

I wanted to ask you: "And what's your problem?"
If you exactly want to create player's inventory, then you're right. But I can't imagine why you want players inventory. If you mean to open inventory to player like a chest, then you can use another Bukkit method:
// Bukkit.createInventory(InventoryHolder owner, int size, String title);
// size = 9 * rows
Inventory inv = Bukkit.createInventory(null, 27, "Title");
player.openInventory(inv);
If you just want to get inventory and change it, then:
Inventory inv = player.getInventory();

Related

Prestashop 1.6 Database inserting products

I've added product by sql query but even when I have ps_product_shop and ps_product_lang set correctly the product in back office is shown with null name and no description what so ever and additionaly there is no category connection too.
What am I missing, can I add product by SQL? If so how do I do it.
I was looking everywhere but there was no query to help me, if someone could help me out I would appreciate that.
Manually adding products directly to database through sql query is not advisable. If you did so, problem may be your id_lang field in ps_product_lang table. For English id_lang is 1. Please check with your query.
Here I did for English lang. You can add through code like below otherwise you can use admin panel for product creation.
$product = new Product();
$product->name[1] = "This is test product";
$product->description[1] = "Description";
$product->description_short[1] = "Descriptio short";
$product->active = 1;
$product->condition = "new";
$product->link_rewrite = Tools::link_rewrite('This is test product');;
$product->id_tax_rules_group = 1;
$product->price = 100;
$product->wholesale_price = 90;
$product->id_manufacturer = 1;
$product->add();

Prestashop - change product category in database

I need to mass change product categories. I updated two tables in database: ps_category_product (changed old id_category) and ps_products (changed old id_category_default) but in BO product table and webshop I still see old category (home).
When I edit product, select tab associations I see that product is associated with my new caterogy. Only when I save the product by click save button I see that product in properly categories.
I compared two rows in database (product with changed category by mysql query and product changed in BO) and these two look identical.
What am I doing wrong? I was trying clean cache (delete cache/cachefs and smarty/compile), disable all cache options but with no result.
To change the category, the following queries must be executed:
Db::getInstance()->execute('UPDATE '._DB_PREFIX_.'category_product SET id_category = NEW_ID_CATEGORY WHERE id_category = OLD_ID_CATEGORY');
Db::getInstance()->execute('UPDATE '._DB_PREFIX_.'product_shop SET id_category_default = NEW_ID_CATEGORY WHERE id_category_default = OLD_ID_CATEGORY AND id_shop = ID_SHOP');
Db::getInstance()->execute('UPDATE '._DB_PREFIX_.'product SET id_category_default = NEW_ID_CATEGORY WHERE id_category_default = OLD_ID_CATEGORY');
Regards

populating field in access 2007 based on another field

I have data for tennis. I have two tables,(game_atp(Player 1, player 2, Name_T, surface) and tours_atp(ID, tournament, court surface)). In games_atp table i want to create a field surface and put the surface based on the tournament its played in( so based on Name_T), getting the info from tours_atp table.
thank you
Do you have a way to connect a row in game_atp to a row in tours_atp? For instance, is tours_atp.ID the same as game_atp.Name_T? There has to be a way to connect them. Also am I assuming that surface will be equal to whatever is in court surface? Assuming that tours_atp.ID is the same as game_atp.Name_T then you can just do...
UPDATE game_atp Set surface = (SELECT court_surface FROM tours_atp WHERE tours_atp.ID = game_atp.NAME_T)
This code will update all rows. If you want to update only a specific game then you will have to use a WHERE clause and tell it the id of the game like so...
UPDATE game_atp Set surface = (SELECT court_surface FROM tours_atp WHERE tours_atp.ID = game_atp.NAME_T ) WHERE game_atp.Name_T = '5555'

Find materials by bill of material

I have a stlnr and a stlal and I want to find all materials in a bill of material using these two fields. I have no idea how to do that, so please help :)
the tables you need to look at are STKO (header), STAS (position selection) and STPO (positions). You need to know the type of BOM, which is in field STKO~STLTY. Using the type and your STLNR you can get the header row from table STKO. The STKO entry is connected to STAS using STLTY, STLNR and STLAL. Table STPO contains the actual BOM positions and is connected to STAS using STLTY, STLNR and STLKN (which is in STAS but not in STKO, which is why you need table STAS too).
You also may need to look at table STPU which is connected to STPO and contains subelements within a BOM position. In our system STPU is completly empty but that may not be the case in yours.
You can call the FM CABM_READ_BOM_ITEM, you will need the following:
CALL FUNCTION 'CABM_READ_BOM_ITEM'
EXPORTING
i_stlty = i_stlty
i_stlnr = i_stlnr
i_stlal = i_stlal
i_date_from = i_date_from
* I_DATE_TO = I_DATE_TO
* I_WERKS = I_WERKS
TABLES
exp_bom_item = exp_bom_item
* EXCEPTIONS
* NO_RECORD_FOUND = 1
Which means you will need STLTY, as it is part of the key of STKO.

Updating a field within a table based on a field within the same table

HI ALL
I wish to update a row within my table from a row within that same table,
I have a table called INVENTORY. it stores PRICES for products.
I have SALES codes and I have STOCK codes which are related.
I wish to transfer all the PRICING from the SALES codes to the STOCK codes.
I wish to do something like this:
update INVENTORY
set PRICE = (SELECT PRICE WHERE CODE = "SALES CODE EQUIVALENT OF THE STOCK CODE IM IN")
WHERE
CODE = "SOME STOCK CODE"
a SALES CODE would look like this "U_12345", its STOCK code equivalent would look like "S_12345"
thanks
You're very close, you just need to specify which table you're selecting from as part of your sub-query...
update INVENTORY
set PRICE = (SELECT PRICE FROM your_table WHERE CODE = "SALES CODE EQUIVALENT OF THE STOCK CODE IM IN")
WHERE
CODE = "SOME STOCK CODE"
Even if "your_table" is INVENTORY, you still need to specify it in there.
The only time it gets 'tricky' is when your selecting from the same table that you're update, AND when you need a value from the updated record in the SELECT statement. In that case you need to differentiate between the two references, using an alias. For example...
update INVENTORY
set PRICE = (SELECT PRICE FROM INVENTORY AS [new_price] WHERE [new_price].CODE = INVENTORY.NEW_CODE)
WHERE
CODE = "SOME STOCK CODE"
UPDATE INVENTORY
SET PRICE = i_sales.PRICE
FROM INVENTORY, INVENTORY i_sales
WHERE INVENTORY.CODE LIKE 'S\_%'
AND i_sales.CODE = REPLACE(INVENTORY.Code, 'S', 'U')
This updates prices for all 'stock' records in INVENTORY with prices from the corresponding 'sales' records.
If you would prefer to update individual prices, change WHERE to something like this:
WHERE i_stock.CODE = 'S_12345'
or this:
WHERE i_stock.CODE IN ('S_12345', 'S_12346')
Note: The FROM syntax used is based on this doc page.