|
|
| (5 intermediate revisions by 2 users not shown) |
| Line 1: |
Line 1: |
| − | '''JTable''' is an abstract class that forms the basis for all database table classes. Some of the methods listed will be overridden by the child class so you should check the child class documentation for further information.
| + | This class is available in the following Joomla versions:- |
| − | | + | <splist showpath=notparent /> |
| − | Each physical database table created should have a corresponding class derived from '''JTable''' to represent it. '''JTable''' provides many methods to make common manipulations to the table much simpler. For example, one of the most common operations you will need to perform is to read a table row into memory given a value for the primary key. This can be done easily using the [[JTable/load|load]] method. The table row can then be just as easily updated using the [[JTable/save|save]] method, which also performs any predefined sanity checks on the table fields.
| + | <noinclude>[[Category:Platform JClasses]][[Category:JTable]]</noinclude> |
| − | | + | |
| − | ===Availability===
| + | |
| − | {{JVer|1.5|From Joomla 1.5}} {{JVer|1.6|With additional functionality in Joomla 1.6}}
| + | |
| − | | + | |
| − | ===Defined in===
| + | |
| − | /joomla/database/table.php
| + | |
| − | | + | |
| − | ===Extends===
| + | |
| − | * [[JObject]]
| + | |
| − | | + | |
| − | ===Extended by===
| + | |
| − | * [[JTableARO]]
| + | |
| − | * [[JTableAROGroup]]
| + | |
| − | * [[JTableAsset]] {{JVer|1.6|From 1.6}}
| + | |
| − | * [[JTableCategory]]
| + | |
| − | * [[JTableComponent]]
| + | |
| − | * [[JTableContent]]
| + | |
| − | * [[JTableMenu]]
| + | |
| − | * [[JTableMenuTypes]]
| + | |
| − | * [[JTableModule]]
| + | |
| − | * [[JTableNested]] {{JVer|1.6|From 1.6}}
| + | |
| − | * [[JTablePlugin]]
| + | |
| − | * [[JTableSection]]
| + | |
| − | * [[JTableSession]]
| + | |
| − | * [[JTableTree]] {{JVer|1.6|From 1.6}}
| + | |
| − | * [[JTableUser]]
| + | |
| − | | + | |
| − | ===Reserved Database Field Names===
| + | |
| − | Some of the optional features of JTable require the existence of specially-named fields in the database table. If you require this additional functionality you should ensure that these named fields are present in the table. These field names should be considered reserved as any attempts to use them for purposes other than those supported by JTable may result in conflict.
| + | |
| − | {| class="wikitable"
| + | |
| − | |-
| + | |
| − | !Field name
| + | |
| − | !Methods using the field name
| + | |
| − | |-
| + | |
| − | |checked_out
| + | |
| − | |[[JTable/checkOut|checkOut]], [[JTable/checkIn|checkIn]], [[JTable/isCheckedOut|isCheckedOut]]
| + | |
| − | |-
| + | |
| − | |checked_out_time
| + | |
| − | |[[JTable/checkOut|checkOut]], [[JTable/checkIn|checkIn]], [[JTable/isCheckedOut|isCheckedOut]]
| + | |
| − | |-
| + | |
| − | |hits
| + | |
| − | |[[JTable/hit|hit]]
| + | |
| − | |-
| + | |
| − | |ordering
| + | |
| − | |[[JTable/getNextOrder|getNextOrder]], [[JTable/reorder|reorder]], [[JTable/move|move]]
| + | |
| − | |-
| + | |
| − | |published
| + | |
| − | |[[JTable/publish|publish]]
| + | |
| − | |}
| + | |
| − | | + | |
| − | ====Check-in/check-out====
| + | |
| − | Joomla tables implement a simple mechanism for preventing a [[wikipedia:race condition|race condition]] while editing rows in a database. This depends on the existence of database fields called "checked_out" and "checked_out_time" and if these fields are present '''JTable''' will automatically support this mechanism so that it can be easily used in your tables too. In addition to the [[JTable/checkOut|checkOut]] and [[JTable/checkIn|checkIn]] methods, there is a [[JTable/isCheckedOut|isCheckedOut]] method to determine if a given table row is currently checked out by another user. | + | |
| − | | + | |
| − | ====Hit counter====
| + | |
| − | Some Joomla tables contain a field called "hits" which records the number of times that a table row has been accessed. '''JTable''' provides a simple method to increment this field: [[JTable/hit|hit]].
| + | |
| − | | + | |
| − | ====Ordering====
| + | |
| − | Many Joomla tables support a user-defined ordering of the rows.
| + | |
| − | | + | |
| − | To be written.
| + | |
| − | | + | |
| − | ====Publish/Unpublish====
| + | |
| − | To be written.
| + | |
| − | | + | |
| − | ===Get and Set Methods===
| + | |
| − | Properties which do not have specific get or set methods listed here can be retrieved or set using the inherited [[JObject/get|JObject->get]] method.
| + | |
| − | {| class="wikitable"
| + | |
| − | |-
| + | |
| − | !Get method
| + | |
| − | !Set method
| + | |
| − | !Description
| + | |
| − | |-
| + | |
| − | |[[JTable/getAssetNamePrefix|getAssetNamePrefix]]
| + | |
| − | |
| + | |
| − | |Abstract method to return the name prefix to use for the asset table. {{JVer|1.6|From 1.6}}
| + | |
| − | |-
| + | |
| − | |[[JTable/getAssetSection|getAssetSection]]
| + | |
| − | |
| + | |
| − | |Abstract method to return the access section name for the asset table. {{JVer|1.6|From 1.6}}
| + | |
| − | |-
| + | |
| − | |[[JTable/getAssetTitle|getAssetTitle]]
| + | |
| − | |
| + | |
| − | |Abstract method to return the title to use for the asset table. {{JVer|1.6|From 1.6}}
| + | |
| − | |-
| + | |
| − | |[[JTable/getDBO|getDBO]]
| + | |
| − | |[[JTable/setDBO|setDBO]]
| + | |
| − | |Method to set/get the [[JDatabase]] connector object associated with the table.
| + | |
| − | |-
| + | |
| − | |[[JTable/getTableName|getTableName]]
| + | |
| − | |
| + | |
| − | |Method to get the name of the database table.
| + | |
| − | |-
| + | |
| − | |[[JTable/getKeyName|getKeyName]]
| + | |
| − | |
| + | |
| − | |Method to get the primary key field name for the table
| + | |
| − | |}
| + | |
| − | | + | |
| − | ===Other Methods===
| + | |
| − | {| class="wikitable"
| + | |
| − | |-
| + | |
| − | !Method name
| + | |
| − | !Description
| + | |
| − | |-
| + | |
| − | |[[JTable/__construct|construct]]
| + | |
| − | |Object constructor to set table and key field
| + | |
| − | |-
| + | |
| − | |[[JTable/addIncludePath|addIncludePath]]
| + | |
| − | |Add a filesystem path where '''JTable''' should search for table class files.
| + | |
| − | |-
| + | |
| − | |[[JTable/bind|bind]]
| + | |
| − | |Binds an associative array or object to the '''JTable''' instance.
| + | |
| − | |-
| + | |
| − | |[[JTable/canDelete|canDelete]]
| + | |
| − | |Checks whether dependencies exist for this object in the database schema.
| + | |
| − | |-
| + | |
| − | |[[JTable/check|check]]
| + | |
| − | |Perform sanity checks on the '''JTable''' instance properties.
| + | |
| − | |-
| + | |
| − | |[[JTable/checkin|checkin]]
| + | |
| − | |Checks a row in if the necessary instance properties and table fields exist.
| + | |
| − | |-
| + | |
| − | |[[JTable/checkout|checkout]]
| + | |
| − | |Checks a row out if the necessary instance properties and table fields exist.
| + | |
| − | |-
| + | |
| − | |[[JTable/delete|delete]]
| + | |
| − | |Deletes a row from the database table by primary key value.
| + | |
| − | |-
| + | |
| − | |[[JTable/getInstance|getInstance]]
| + | |
| − | |Static method to get an instance of a '''JTable''' class.
| + | |
| − | |-
| + | |
| − | |[[JTable/getNextOrder|getNextOrder]]
| + | |
| − | |Gets the next ordering value for a group of rows defined by an SQL WHERE clause.
| + | |
| − | |-
| + | |
| − | |[[JTable/hit|hit]]
| + | |
| − | |Increments the hits for a row if the necessary instance property and table field exists.
| + | |
| − | |-
| + | |
| − | |[[JTable/isCheckedOut|isCheckedOut]]
| + | |
| − | |Determines if a row is checked out and therefore un-editable by a user.
| + | |
| − | |-
| + | |
| − | |[[JTable/load|load]]
| + | |
| − | |Loads a row from the database by primary key and binds the fields to the '''JTable''' instance properties.
| + | |
| − | |-
| + | |
| − | |[[JTable/move|move]]
| + | |
| − | |Moves a row in the ordering sequence of a group of rows defined by an SQL WHERE clause.
| + | |
| − | |-
| + | |
| − | |[[JTable/publish|publish]]
| + | |
| − | |Sets the publishing state for a row or list of rows in the database table.
| + | |
| − | |-
| + | |
| − | |[[JTable/reorder|reorder]]
| + | |
| − | |Compacts the ordering values of rows in a group of rows defined by an SQL WHERE clause.
| + | |
| − | |-
| + | |
| − | |[[JTable/reset|reset]]
| + | |
| − | |Resets class properties to the defaults set in the class definition.
| + | |
| − | |-
| + | |
| − | |[[JTable/save|save]]
| + | |
| − | |Provides a shortcut to binding, checking and storing a '''JTable''' instance to the database table.
| + | |
| − | |-
| + | |
| − | |[[JTable/store|store]]
| + | |
| − | |Stores a row in the database from the '''JTable''' instance properties.
| + | |
| − | |-
| + | |
| − | |[[JTable/toXML|toXML]]
| + | |
| − | |Exports the '''JTable''' instance properties to an XML string.
| + | |
| − | |}
| + | |
| − | ===Importing===
| + | |
| − | <source lang="php">jimport( 'joomla.database.table' );</source> | + | |
| − | | + | |
| − | ===Extending the JTable Class for new database tables===
| + | |
| − | The JTable Class can easily be extended in order to make the table object represent any table in your database.
| + | |
| − | A good start how to learn about creating Child Classes for the JTable Class is to take a look at the fourth part of the [http://docs.joomla.org/Developing_a_Model-View-Controller_Component_-_Part_4_-_Creating_an_Administrator_Interface#Creating_the_Table_Class MVC Tutorial]
| + | |
| − | | + | |
| − | ===See also===
| + | |
| − | * [http://api.joomla.org/Joomla-Framework/Table/JTable.html JTable on api.joomla.org]
| + | |
| − | * [[How to use the JTable class]]
| + | |
| − | * [[How to use the database classes in your script]]
| + | |
| − | * [[Developing a Model-View-Controller Component - Part 4 - Creating an Administrator Interface]]
| + | |
| − | * [[How to connect to an external database]]
| + | |
| − | <noinclude>[[Category:Development]][[Category:Framework]][[Category:JTable]]</noinclude> | + | |