WHAT I AM DOING:
I am using cook to build mobile connections to Joomla and need to interact with the session table. This way I can keep the users connected even if the devices go to offline mode and return. The simple way would be to use the $query object, but prefer homogenous code. So in the end I took an hour and coded a best-fit solution.
What I found is that JDom has a heavy bios towards "id" and integer primary keys. This is hard coded and enforced by the use of "x = (int) $id" in some areas, but ought not to be so. Would love to see cook revisit this doctrine and offer developers the option to declare the key-name in the table class and then use that definition throughout the solution.
Fork table file:
public function __construct(&$db, $tbl = '#__session', $key = 'session_id')
{
JTable::__construct($tbl, $key, $db);
}
The solution I ended with can instance the list and item classes and display the list only. The fact that cook can't handle alphanumeric keys makes it "impossible" to view a single item without rewriting much of the cook code. Viewing/editing a record is not a requirement on this table anyway, so I'm happy with the final product.
This may seem trivial, but if one needs to determine/display the status of a user or anything like that, this is the go-to table. Cook should allow for easy integration of this important resource.
This is the code for retrieving the user-session:
$model = CkJModel::getInstance('Sessions', 'XModel');
$model->setState('filter.userid', 'auto');
$sessions = $model->getItems();
Best regards
v
PS: wanted to test my status as an Elite Member.