Multiple primary keys with Non-integer keys in JTable Joomla 3.4.

144 views
Skip to first unread message

Walt Sorensen

unread,
Jun 22, 2015, 8:13:27 PM6/22/15
to joomla-de...@googlegroups.com

Does anyone know of some examples or can give some advice on overriding JTable to support Multiple primary keys and Non-integer keys?


Walt Sorensen

unread,
Jun 23, 2015, 2:21:29 PM6/23/15
to joomla-de...@googlegroups.com
Here is what I have found so far in relation to multiple keys with JTable in Joomla 3.4

Looks like since platform 11.1 there is some support for multiple primary keys in JTable.
JTable::getKeyName(true) will return an array of primary keys for a table.
JTable::load() this abstract class possibly accepts an array of primary keys (array of fields to match), Loading a row from the database and binds the fields to the object properties.

Since platform 12.3
JTable::getPrimaryKey($keys) accepts an array of primary keys, returning an array of primary key names and values.
JTable::appendPrimaryKeys() seems to address multiple primary keys

Walt Sorensen

unread,
Jun 23, 2015, 4:29:49 PM6/23/15
to joomla-de...@googlegroups.com
I found an example JTable with multiple keys (look starting at line 247 "// For all keys")

Still looking for something with Non-integer keys

Walt Sorensen

unread,
Jun 24, 2015, 4:32:42 PM6/24/15
to joomla-de...@googlegroups.com
More J3.4 JTable Multiple primary key discoveries:
When overriding the JTable __construct function to explicitly set the table and key fields, note that $key is either the name of the primary key or an array of field names that compose the primary key
example
public function __construct(&$db)
{
parent::__construct('#__My_Table', array('key1','key2','key3'), $db);
}


Reply all
Reply to author
Forward
0 new messages