JTable

From Joomla! Documentation
(Difference between revisions)
Jump to: navigation, search
(New page: '''JTable''' is an abstract class which provides a number of methods to handle database tables. Some of the methods listed will be overridden by the child class so you should check the ch...)
 
Line 51: Line 51:
 
!Method name
 
!Method name
 
!Description
 
!Description
 +
|-
 +
|[[JTable/__construct|construct]]
 +
|Object constructor to set table and key field
 
|-
 
|-
 
|[[JTable/addIncludePath|addIncludePath]]
 
|[[JTable/addIncludePath|addIncludePath]]
Line 110: Line 113:
 
|}
 
|}
 
===Importing===
 
===Importing===
<source lang="php">jimport( 'joomla.document.document' );</source>
+
<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]
  
===Adding support for new document types===
 
New document types are added by creating a new sub-directory under the /libraries/joomla/document/ directory with the same name as the type.  For example, to add a document type called "mytype", you would create the directory /libraries/joomla/document/mytype.  In this directory you must then create a file called mytype.php which will contain the class definition for JDocumentMytype which extends JDocument.  Look at the code for existing document types to see what needs to be done.
 
 
===See also===
 
===See also===
* [http://api.joomla.org/Joomla-Framework/Document/JDocument.html JDocument on api.joomla.org]
+
* [http://docs.joomla.org/Developing_a_Model-View-Controller_Component_-_Part_4_-_Creating_an_Administrator_Interface#Creating_the_Table_Class Extending the JTable Class (MVC Tutorial)]
* [[JDocumentRenderer]]
+
<noinclude>[[Category:Development]][[Category:Framework]][[Category:JTable]]</noinclude>
<noinclude>[[Category:Development]][[Category:Framework]][[Category:JDocument]]</noinclude>
+

Revision as of 16:28, 6 November 2008

JTable is an abstract class which provides a number of methods to handle database tables. Some of the methods listed will be overridden by the child class so you should check the child class documentation for further information.

Contents

Defined in

/joomla/database/table.php

Extends

Extended by

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 method.

Get method Set method Description Property
getDBO setDBO Method to set/get the Database Object used for all table transactions $_db
getTableName Method to get the name of the database table, that is being representent by the table-object $_tbl
getTableKey Method to get the name of the primary key of the table $_tbl_key

Other Methods

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

Importing

jimport( 'joomla.database.table' );

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 MVC Tutorial

See also

Personal tools
Namespaces

Variants
Actions
Navigation
Joomla! Sites
Toolbox