Table has multiple primary keys specified, only one primary key value provided.

69 views
Skip to first unread message

Walt Sorensen

unread,
Jun 25, 2015, 11:59:07 AM6/25/15
to joomla-de...@googlegroups.com
It's my first time trying to deal with JTable and multiple primary keys, Can anyone shed some lite on this error message?

Table has multiple primary keys specified, only one primary key value provided.

The table does have multiple primary keys, the multiple keys are specified in the JTable class for this table in the __construct override.

I have looked through my code for where 
primary key values are provided, but I can't seem to identify what function is having the fit and throwing the exception. 
I believe this error is triggered by and exception in the JTable parent load function. 

Controller 
extends JControllerForm
and overrides the __construct() function

model extends JModelAdmin
and overrides getTable() and getForm () functions

Table extends JTable
and overrides __construct(), (where it adds the multiple primary keys array)
and bind() functions

view extends JViewLegacy
and overrides display(), addToolbar()

So I'm a little lost on what I have that is still only calling the single primary key id integer (maybe an in the list view that calls the edit view?)

(Side note: it's a client's requirement to use existing tables with multiple primary keys, no option to restructure)

Michael Babker

unread,
Jun 25, 2015, 12:10:23 PM6/25/15
to joomla-de...@googlegroups.com
On 3.4.1, that exception gets thrown from JTable::load() (https://github.com/joomla/joomla-cms/blob/3.4.1/libraries/joomla/table/table.php#L693).

Catch that exception somewhere (either in your code or using JErrorPage) and follow the stack trace it provides up the chain.  My initial gut feeling tells me something in the MVC stack may not support the multiple PK structure like JTable can.

--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-gene...@googlegroups.com.
To post to this group, send email to joomla-de...@googlegroups.com.
Visit this group at http://groups.google.com/group/joomla-dev-general.
For more options, visit https://groups.google.com/d/optout.

Walt Sorensen

unread,
Jun 25, 2015, 1:43:21 PM6/25/15
to joomla-de...@googlegroups.com
Thanks Michael,

After looking at some class inheritances and functions in the libraries I'm thinking the issue might be related to the parent JModelAdmin->JModelList getItem() function.

I'll see if we can follow the stack trace up the chain to verify if that is the offending function or if there is something else in the MVC stack which may not support the multiple PK structure.

Walt Sorensen

unread,
Jul 8, 2015, 3:55:01 PM7/8/15
to joomla-de...@googlegroups.com
I think I may have found the issue, in the model we had basically followed the getItem() method from JModelAdmin
In JModelAdmin (and our model) when the table get's loaded the primary key value wasn't being passed as an array.
So the problem is partly in JModelAdmin::getItem() at line 853 (and my model) which expects an integer rather than following JTable which expects an integer, or an array of keys.

I guess this is a little bit of a mute point for me since we were able to implement some data restructuring and add a single primary key id integer to the table.
Reply all
Reply to author
Forward
0 new messages