O'Reilly logo

Learning Joomla! 1.5 Extension Development by Joseph L. LeBlanc

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding ordered records

There are many circumstances where you will want to enforce a specific ordering for your database records. In our case, certain critics may request to be placed at the top of the list due to their seniority. The JTable class has built-in functions that help you move records up and down within a list and add new ones in the correct place.

When we added the jos_critic table to the database, an ordering column was added. Because records are now added without values for this column, we need to go back and add this information now. For the record with id set to 1, change the ordering column to 1, and change ordering to 2 for record 2. If you are using the MySQL command line client, this query will do it automatically:

UPDATE jos_critic ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required