J4 - Error storing article to database from Table::getInstance

Skip to first unread message


Jul 26, 2021, 4:54:37 AMJul 26
to Joomla! General Development
I am trying to migrate some code from an earlier version of Joomla and having some major problems.

use Joomla\CMS\Factory;
use Joomla\CMS\Table\Table;

$table = Table::getInstance('Content', 'Table');

$data = array();
$data['title'] = $title;
$data['alias'] = $title_alias;
$data['introtext'] = $overview;
$data['state'] = $is_published;
$data['catid'] = $category_id;
$data['created'] = $release_date;
$data['created_by'] = $created_by;
$data['modified'] = $publish_up;
$data['modified_by'] = $created_by;
$data['publish_up'] = $publish_up;
$data['language'] = $language;
$data['metadesc'] = $overview_meta;

if ($table->check()) {
    echo "success";
} else {
echo "error";

I receive the following error:
Call to a member function bind()

I had this working in Joomla 3.x and have been racking my brain for hours trying to figure this out! Any help would be greatly appreciated.

Hannes Papenberg

Jul 26, 2021, 4:58:51 AMJul 26
to Joomla! General Development
Your call to Table::getinstance() does not return an object. The parameters seem to be wrong.

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 view this discussion on the web, visit https://groups.google.com/d/msgid/joomla-dev-general/a61cc834-4874-4e72-89b0-3bb9773178bdn%40googlegroups.com.


Jul 26, 2021, 6:18:30 AMJul 26
to Joomla! General Development
I got it working....with one MAJOR problem!

Articles are being saved to the database but they are not showing up in the admin backend! 

I am now using:
$table = Table::getInstance('Content', 'JTable');

What would cause the articles not to show up in the backend???
Reply all
Reply to author
0 new messages