Skip to main content
4 votes
Accepted

JTable return associative array instead of object

$table->getProperties() already returns an array. You need to remove ArrayHelper::toObject() call which converts the array to an object.
Sharky's user avatar
  • 11.3k
4 votes
Accepted

Find user by email

Joomla\CMS\Table\User::load() can only load rows by user ID. Use database query to get user ID by email and pass it to table's load() method: $db = JFactory::getDbo(); $query = $db->getQuery(true) ...
Sharky's user avatar
  • 11.3k
3 votes
Accepted

Why does Joomla have both models and tables?

Class JTable is created to work strictly on database object. Table object should create,modify,delete,check data in database. It can be used in many models, helpers, modules. Single model some times ...
Artur Stępień's user avatar
2 votes
Accepted

storing id using JTables

Your $data needs to be just column names, not with any values. $data = array('articleId', 'title', 'sharetoken'); and $values dosen't have correct id right now, since your are quoting just pasic ...
Rene Korss's user avatar
  • 3,208
2 votes
Accepted

Strange behavior with dates

I looked at the code for this. JDate::dateformat is public, which means ANY code can modify the value. I would start doing a grep/search through my source tree (and any plugins/modules/libraries) to ...
George Sexton's user avatar
2 votes
Accepted

Use JTable to save frontend-data

Let me explain how joomla works imo. Controllers are for creating / executing route and calling model for some work. In controller you have method called save but it's preprocess $_POST aka $data ...
Lanah's user avatar
  • 522
2 votes

Joomla 3.9 replace zero dates with null on save/checkin (mysql zero date deprecated)

With thanks to @glenn-arkell who pointed me in the right direction, for j3.9 this works to stop Joomla writing '0000-00-00 00:00:00' into the checked_out_time field. For other fields (eg modified and ...
RogerCO's user avatar
  • 61
2 votes
Accepted

JTable, new row doesn't get inserted with table->save method

save() calls store(). Store() works like this: If a primary key value is set the row with that primary key value will be updated with the instance property values. If no primary key value is set a new ...
astridx's user avatar
  • 449
2 votes
Accepted

Joomla core table names for JTable::getInstance?

Class name is TemplatesTableStyle. But since it's not a core class, you have to register it: JLoader::register('TemplatesTableStyle', JPATH_ADMINISTRATOR . '/components/com_templates/tables/style.php'...
Sharky's user avatar
  • 11.3k
2 votes
Accepted

J4. Table class in controller

Use the MVC factory. Joomla\CMS\Table\Table::addIncludePath() call is not needed in J4 style components. $table = $this->factory->createTable('Espacios', 'Administrator');
Sharky's user avatar
  • 11.3k
1 vote

Using a table from a library when namespaced

You can try either of these method that I have used in components. use Mylib\Library\Table\MyTable; ... $this->db = $this->db ? :Factory::getContainer()->get('DatabaseDriver'); $...
Irata's user avatar
  • 3,927
1 vote
Accepted

I want to display a form with the data added already

There is a method $form->setProperty() which does this.
DeesreX's user avatar
  • 87
1 vote

Joomla 3.9 replace zero dates with null on save/checkin (mysql zero date deprecated)

Some added suggestions around null dates - I came upon the need to remove a date from a datetime field using the standard Table from the Model class. This makes the removal of a date nice and clean. ...
Glenn Arkell's user avatar
1 vote

Programmatically update Menu Item in Component

If the menu item already exists then you don't need jtablenested at all - you should just update the fields directly in the database. What you do need is the menu item's id in Joomla's menu table. ...
jamesgarrett's user avatar
  • 3,299
1 vote
Accepted

where is JTable defined?

JTable is an alias to Joomla\CMS\Table\Table class defined in libraries/src/Table/Table.php.
Sharky's user avatar
  • 11.3k
1 vote
Accepted

Store category record using JTable instance from controller

I get the solution by the help of @mickmackusa and using this forum link https://forum.joomla.org/viewtopic.php?t=592653. My final code is now $table = JTable::getInstance('Category'); $data = ...
Sajeeb Ahamed's user avatar
1 vote
Accepted

Save failed with the following error: Unknown column 'created' in 'field list'

You must have missed something when adapting the files to your table structure. Run a search for created through the files. It could be this line in /administrator/com_banners/tables/banner.php: $...
Sharky's user avatar
  • 11.3k
1 vote
Accepted

How to use look-up tables in a custom component?

All of the 3 ways (models, JTable, helper class) are legit ways in Joomla to solve your problem. I would probably make a JTable class for your look up table (for CRUD operations) and add models (list ...
fruppel's user avatar
  • 3,733
1 vote

After upgrade to 3.5: return $row->id (last saved item) does not work

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
MyFault's user avatar
  • 677
1 vote

Using tags: JTable::store() returns false

First of all this: if(!empty($this->dateofbirth)) // Prepare DOB to be saved in database { // Set this to a format the sql-table is able to save $date = JFactory::getDate($this->...
Artur Stępień's user avatar
1 vote

Store data to other table and get the id

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
MyFault's user avatar
  • 677
1 vote

Store data to other table and get the id

To get the last insertId use: $newID = $row->insertId(); Here is the documentation You have to call it just after $store = $row->store();
Pierre-André Vullioud's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible