API15

Difference between revisions of "JTable"

From Joomla! Documentation

m (fixing)
Line 98: Line 98:
 
<dpl>
 
<dpl>
 
  noresultsheader=\n
 
  noresultsheader=\n
 +
namespace=CodeExample
 
  category=JTable
 
  category=JTable
 
  category=CodeExample
 
  category=CodeExample

Revision as of 21:15, 4 July 2013

The "API15" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.

[Edit Descripton] Template:Description:JTable

Defined in[edit]

libraries/joomla/database/table.php

Methods[edit]

Method name Description
__construct Object constructor to set table and key field
getInstance Returns a reference to the a Table object, always creating it
getDBO Get the internal database object
setDBO Set the internal database object
getTableName Gets the internal table name for the object
getKeyName Gets the internal primary key name
reset Resets the default properties void
bind Binds a named array/hash to this object
load Loads a row from the database and binds the fields to the object properties
check Generic check method
store Inserts a new row if id is zero or updates an existing row in the database table
move Description
getNextOrder Returns the ordering value to place a new item last in its group
reorder Compacts the ordering sequence of the selected records
canDelete Generic check for whether dependancies exist for this object in the db schema
delete Default delete method
checkout Checks out a row
checkin Checks in a row
hit Description
save Generic save function
publish Generic Publish/Unpublish function
toXML Export item list to xml
addIncludePath Add a directory where JTable should search for table types. You may either pass a string or an array of directories.
isCheckedOut Check if an item is checked out

Importing[edit]

jimport( 'joomla.database.table' );

[Edit See Also] Template:SeeAlso:JTable

Examples[edit]

<CodeExamplesForm />

Automatically Generated Properties

From 2.5 As of Joomla 2.5, JTable properties are automatically generated based on the schema of the specified table. When you specify a table in a class that extends JTable, the field names are read from the table and set as properties. When using Joomla 1.5, you must manually declare all table columns as properties of the class that extends JTable.


Chris Davenport 12:21, 17 April 2011 (CDT) Edit comment

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.

Field name Methods using the field name
checked_out checkOut, checkIn, isCheckedOut
checked_out_time checkOut, checkIn, isCheckedOut
hits hit
ordering getNextOrder, reorder, move
published publish


Chris Davenport 12:22, 17 April 2011 (CDT) Edit comment

Check-in/check-out

Joomla tables implement a simple mechanism for preventing a 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 checkOut and checkIn methods, there is a isCheckedOut method to determine if a given table row is currently checked out by another user.


Chris Davenport 12:23, 17 April 2011 (CDT) Edit comment

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: hit.


Chris Davenport 12:24, 17 April 2011 (CDT) Edit comment