Hi! An ongoing issue some of you might have encountered is with items that have a duplicate name merging in lists. For example you might notice if you have multiple adopts with the same name you can only see one entry in the breed adopt dropdowns.
(I actually have 4 male adopts, all called Unnamed!)
In this small tutorial we're going to fix it!
Find and open resource/core/database.php.
Find:
Underneath it, put this:
Now you can open service/helper/formhelper.php and in any function where you see fetchMap and you want to display both the name and ID of the item, replace fetchMap with fetchMapID!
I added a new function as not all lists need or can display an ID, and you might not want or need to replace them all.
Some functions I recommend replacing are:
buildUsernameList,
buildAdoptTypeList,
buildItemShopList,
buildAdoptShopList,
buildItemNameList
In other files, I recommend:
controller/main/accountcontroller.php public function profile
controller/main/breedingcontroller.php public function index (do it for both male and female adopts)
service/applicationservice/tradeservice.php (do it for all instances, there should be 6)
Finally, in controller/main/inventorycontroller.php (it's a special case) find:
Replace with:
If you need any help, let me know and I can try to troubleshoot!
(I actually have 4 male adopts, all called Unnamed!)
In this small tutorial we're going to fix it!
Find and open resource/core/database.php.
Find:
PHP:
public function fetchMap(PDOStatement $stmt){
$map = new LinkedHashMap;
while($fields = $stmt->fetch(PDO::FETCH_NUM)){
if(count($fields) == 1) $fields[1] = $fields[0];
$map->put(new MysString($fields[0]), new MysString($fields[1]));
}
return $map;
}
Underneath it, put this:
PHP:
public function fetchMapID(PDOStatement $stmt){
$map = new LinkedHashMap;
while($fields = $stmt->fetch(PDO::FETCH_NUM)){
if(count($fields) == 1) $fields[1] = $fields[0];
$map->put(new MysString("{$fields[0]} [ID: {$fields[1]}]"), new MysString($fields[1]));
}
return $map;
}
Now you can open service/helper/formhelper.php and in any function where you see fetchMap and you want to display both the name and ID of the item, replace fetchMap with fetchMapID!
I added a new function as not all lists need or can display an ID, and you might not want or need to replace them all.
Some functions I recommend replacing are:
buildUsernameList,
buildAdoptTypeList,
buildItemShopList,
buildAdoptShopList,
buildItemNameList
In other files, I recommend:
controller/main/accountcontroller.php public function profile
controller/main/breedingcontroller.php public function index (do it for both male and female adopts)
service/applicationservice/tradeservice.php (do it for all instances, there should be 6)
Finally, in controller/main/inventorycontroller.php (it's a special case) find:
PHP:
$stmt = $mysidia->db->select("owned_adoptables", ["aid", "name"], "owner = '{$mysidia->user->getID()}'");
$map = $mysidia->db->fetchMap($stmt);
Replace with:
PHP:
$stmt = $mysidia->db->select("owned_adoptables", ["name", "aid"], "owner = '{$mysidia->user->getID()}'");
$map = $mysidia->db->fetchMapID($stmt);
If you need any help, let me know and I can try to troubleshoot!