The following warnings occurred:
Warning [2] Undefined array key "threadviews_countguests" - Line: 745 - File: showthread.php PHP 8.1.31 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/showthread.php 745 errorHandler->error_callback
Warning [2] Undefined array key "allowautourl" - Line: 584 - File: inc/class_parser.php PHP 8.1.31 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/class_parser.php 584 errorHandler->error_callback
/inc/class_parser.php 228 postParser->parse_mycode
/inc/functions_post.php 830 postParser->parse_message
/showthread.php 1121 build_postbit
Warning [2] Undefined property: MyLanguage::$thread_modes - Line: 46 - File: showthread.php(1650) : eval()'d code PHP 8.1.31 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/showthread.php(1650) : eval()'d code 46 errorHandler->error_callback
/showthread.php 1650 eval




Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CategoryJoins for ItemManager 2.2+
#1
CategoryJoins for ItemManager

Joins are used to combine fields into one data item from two or more categories

For very large item-objects (with bigger field values for example) and a large number of items it is sometimes advisable to split the item into two parts, and load them only at the time when they are really needed. This improves loading efficiency and saves performance for both the server and client.

Let's say we have a Members-Category with a large number of items and a number of input fields (about 12) for the address data. It's rather inefficient to spend lots of memory to fully load all the member-objects with all the address field data if we only wish to display a list of user names for example.
The one reasonable solution would be to split the members into two parts/categories: Members and Addresses with following fields.

1. Members:
[Image: im.members.fields.png?dl=1]


2. Addresses:
[Image: im.address.png?dl=1]
Member list view in admin:
[Image: im.members.list.png?dl=1]



With a very small members-objects, we can now handle very well and load the address-data by the item id only at the time when it’s really needed:

PHP Code:
$manager = new IManager();
$itemMapper $manager->getItemClass();
// ID of the Members category
$memberId 19;
// ID of the Addresses category
$addressId 5;
// Initialize all the items of category with ID 19 (Members)
$itemMapper->init($memberId);
// Let's get a member named "Banana Joe"
$joe $itemMapper->getItem('name=Banana Joe');
// Next we'll join Joe's address by linking Addresses category
$joe->join($addressId);

// Now, we can access the address fields by calling linked_fields[linked_category_id]
echo '<p>'.$joe->linked_fields[$addressId]->first_name->value ' '
    
$joe->linked_fields[$addressId]->last_name->value .'</p>'
Reply




Users browsing this thread: 1 Guest(s)