1

As I develop the back end manage record functionality of a component, I am getting "Save failed with the following error: Unknown column 'created' in 'field list'"

I built the helloworld component according to the Joomla docs tutorial: https://docs.joomla.org/J3.x:Developing_an_MVC_Component/Introduction

I am trying to extend the back-end from simply displaying the list of items ( https://docs.joomla.org/J3.x:Developing_an_MVC_Component/Basic_backend ) to modify (i.e., manage) each record. For this, I copied the back-end's com_banners banner view and the related files (controller, model, table, etc.), and adjusted the files to reflect the structure of my component's single record.

My component's table only has 3 columns, id, greeting, and state.

The manage record view for my component is displaying the record correctly, but when I modify the greeting and try to save it, I get the error

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

Like I said, the table of my component only has 3 columns, id, greeting, and state. The error implies the query included the additional column 'created'. Why is this additional column added to the query?

UPDATE:

@Sharky suggested to delete $this->created = JFactory::getDate()->toSql(); from the Table class of the component. I did, and then I got the error

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

Right now, the Table class for my component looks like:

class HelloWorldTableHelloWorld extends JTable
{
    /**
     * Constructor
     *
     * @param   JDatabaseDriver  $db  Database connector object
     *
     * @since   1.5
     */
    public function __construct(&$db)
    {

        parent::__construct('#__helloworld', 'id', $db);

        JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_helloworld.helloworld'));

        $this->setColumnAlias('published', 'state');

    }

}
1

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:

$this->created = JFactory::getDate()->toSql();

Also, look at the class of your component's model.

Based on your update, and given the advice I gave you (i.e., review your component for Banner's specific code), from class HelloWorldModelHelloWorld, you would delete the lines from method prepareTable:

$table->modified    = $date->toSql();
$table->modified_by = $user->id;
$table->version++;
  • Deleting $this->created = JFactory::getDate()->toSql(); from the HelloWorldTableHelloWorld did not work. I am now getting the error "Save failed with the following error: Unknown column 'modified' in 'field list'" – IberoMedia Sep 25 '18 at 11:21

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.