I'm using a helper which is called by an Joomla-CLI-Script. In this script I would like to add items to my database using JTable::store.

In the storing-process I'm checking some JINPUT-values, that are not stored to the database. The inputs come from fields I defined in my fields.xml.

This is my source so far:

 * generateItem function.
 * @access public
 * @param mixed $jsontable
 * @param mixed $ids
 * @return void
public function generateItem($jsontable, $ids)
    $app                        =           JFactory::getApplication();
    $input                      =           $app->input;
    $input->set('creationdate', JFactory::getDate()->toSql());

    // Lets store it!   
    $row                        =           JTable::getInstance('Item','BestiaTable');      

    $store                      =           $row->store(); 

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

    else                                    return false;       

Well, now I got the following problem: The item IS fetchable in JTable::store with

$jinput = JFactory::getApplication()->input;

If I run it via CLI - but if I save the item via admin-backend (there is a form to create items the manual way without CLI) I'm getting NULL for my var_dump.

Is there any possibility to solve that problem?

Thanks a LOT in advance! :-)

1 Answer 1


You must find an solution to bind the Data from input to the TableObject, thats all.

$dataToStore=array('creationdate'=> $input->get('creationdate'));
$row = JTable::getInstance('Item','BestiaTable'); 

   $row->check(); // please write an check method which checks the datas before store!
   $store  = $row->store(); 
  • Hi JProof, thanks a lot for your reply. The problem is, that the field "creationdate" does not exist in DB. After bind() the field is lost :-(
    – MyFault
    Oct 28, 2015 at 13:38
  • Yes, it is good to loose the overlapping data. The tableObject represents an Database-Table not an Free-Style-Object ;-) . You better build an Object, that represents the Data from input, that gives the data to JTable instance and response the data back to ..what ever you want
    – JProof
    Oct 28, 2015 at 13:49
  • Okay, that would be a possibility. But in my JTable::store() I would have to check if it runs from CLI or not, because if it does not, I would still have to work with JInput. Could you give me an example how to solve that? Does not need to be completely working, just how to see where to change what :-)
    – MyFault
    Oct 28, 2015 at 14:08
  • i should see the whole(the controllers/models/tables/helpers) code with both cycles(web and client). perhaps you can upload it somewhere? So i will mark the code for.
    – JProof
    Oct 28, 2015 at 14:15
  • 1
    Let us continue this discussion in chat.
    – JProof
    Oct 28, 2015 at 15:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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