6
votes
Accepted
Where is class $tableClass defined?
$tableClass is a variable. You won't find a class named "tableClass". It's just a placeholder for the real class name which will be generated at the beginning of the getInstance method.
Take a look ...
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.
4
votes
Accepted
Delete items of database via CLI
It's been awhile since I've done this, but as I recall putting this within doExecute should do what you want.
$basePath = JPATH_ADMINISTRATOR.'/components/com_content';
require_once $basePath.'/...
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)
...
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 ...
2
votes
Working with Entities and Repositories in Joomla
I don't know if there is a better way.
Joomla has been developed more in a historic way, whereas both Symfony1 and 2 had a clean slate approach. They are also build for different purposes, Joomla's ...
2
votes
Accepted
Save JINPUT to JTable via CLI AND web-backend
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','...
2
votes
Question about JTable::getInstance in libraries/joomla/table/table.php file
Joomla is flexible and relaxed with the physical storage of Table-Classes.
The dirty way (I think you do not use a debugger) is to rewrite the following line
$paths = self::addIncludePath();
to:
...
2
votes
Joomla: How to insert $jinput to JTable::store via CLI?
I'm not sure if I'm understanding the question or not, but here's an example of code that I routinely use from the CLI using the model for saving/creating articles in #__content, hopefully it will ...
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 ...
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 ...
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 ...
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'...
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 ...
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 ...
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');
1
vote
Accepted
I want to display a form with the data added already
There is a method $form->setProperty() which does this.
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. ...
1
vote
Accepted
where is JTable defined?
JTable is an alias to Joomla\CMS\Table\Table class defined in libraries/src/Table/Table.php.
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 = ...
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:
$...
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. ...
1
vote
Load from JTable with some null values
May need some more detail on the db structure here. For example, if I understand you correctly that you have defined three fields in the db as 'must be unique,' any database that correctly follows the ...
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 ...
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
1
vote
Why is there no rebuild() function call after deleting a usergroup?
The question would be if there is a need to rebuild the structure after a deletion.
In my opinion, only new items force a rebuild and usergroup deletion does not require a rebuild.
If you find a ...
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->...
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
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();
1
vote
Accepted
JTable - Access properties that does not belongs to the specified table
From my understanding you should be using multiple JTable instances in your model when you have multiple tables.
Take a look at these models in the CMS they might give you some direction for how to ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
jtable × 47joomla-3.x × 16
custom-component × 7
database × 7
model × 7
php × 6
component × 4
joomla-3.4 × 4
mvc × 4
development × 2
mysql × 2
jform × 2
jdatabase × 2
joomla-4.x × 2
date × 2
jmodeladmin × 2
joomla-2.5 × 1
plugin × 1
articles × 1
user × 1
css × 1
menu × 1
custom-field × 1
k2 × 1
tags × 1