Book Image

Learning Joomla! 1.5 Extension Development

Book Image

Learning Joomla! 1.5 Extension Development

Overview of this book

Table of Contents (17 chapters)
Learning Joomla! 1.5 Extension Development
Credits
About the Author
About the Reviewer
Preface

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 SET ordering = id;

In phpMyAdmin, click the Browse tab after selecting the jos_critic table, then edit both records individually. Click on the pencil icon to the left of the data columns, then add the appropriate value in the ordering field...