Column alias

From Joomla! Documentation

Other languages:
English

The JTable class makes it possible to use column aliases. This can be used for when your database table has a different name than the data going into your table class.

An example is the state field. Often you will find that the database table has a field called state to keep track of the published/unpublished state of an item. Using the name state within Joomla is not recommended as it can lead to conflicts, instead the name published is used.

How to tell Joomla to store the value of the published form field into the state database field? We do this by using the method setColumnAlias().

We tell JTable that the database table has a field called state and not published. This statement needs to go into the __construct() method of your table class.

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

Now when you publish an item the database query will look like this:

UPDATE prefix_yourtable
SET `state` = 1
WHERE (checked_out = 0 OR checked_out = 748) AND `id` = '72'

As you can see not the field published is set but the state field is set here.