0

I would like to get the ID of an item that I recently saved using store-method.

On Joomla 3.4.48 I was able to use this source:

$data['userid'] = $userid;
$data['title'] = $title;                
$data['content'] = $content;

$data['state'] = $state;

// Lets store it!    
$row = JTable::getInstance('Message','BestiaTable');
$row->bind($data);
$row->check();
$store = $row->store(); 

if($store)                        return $row->id;

Now $row->id is always NULL.

How can I change that?

1

The problem is solved. On Joomla 3.5 the PDO driver does not return an id.

This is discussed and will be solved: https://github.com/joomla/joomla-cms/issues/9534

0

To get the last insertId use:

$newID = $row->insertId();

Here is the documentation You have to call it just after

$store = $row->store(); 
  • Hm, unfortunately this still returns NULL. – MyFault Mar 26 '16 at 11:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.