class BaseDatabaseModel extends JObject

Base class for a database aware Joomla Model

Acts as a Factory class for application specific objects and provides many supporting API functions.

Methods

static  array
addIncludePath( mixed $path = '', string $prefix = '')

Add a directory where \JModelLegacy should search for models. You may either pass a string or an array of directories.

static  void
addTablePath( mixed $path)

Adds to the stack of model table paths in LIFO order.

static  JModelLegacy|boolean
getInstance( string $type, string $prefix = '', array $config = array())

Returns a Model object, always creating it

__construct( array $config = array())

Constructor

getDbo()

Method to get the database driver object

string
getName()

Method to get the model name

mixed
getState( string $property = null, mixed $default = null)

Method to get model state variables

JTable
getTable( string $name = '', string $prefix = 'Table', array $options = array())

Method to get a table object, load it if necessary.

boolean
loadHistory( integer $version_id, JTable $table)

Method to load a row for editing from the version history table.

void
setDbo( JDatabaseDriver $db)

Method to set the database driver object

mixed
setState( string $property, mixed $value = null)

Method to set model state variables

Details

static array addIncludePath( mixed $path = '', string $prefix = '')

Add a directory where \JModelLegacy should search for models. You may either pass a string or an array of directories.

Parameters

mixed $path A path or array[sting] of paths to search.
string $prefix A prefix for models.

Return Value

array An array with directory elements. If prefix is equal to '', all directories are returned.

static void addTablePath( mixed $path)

Adds to the stack of model table paths in LIFO order.

Parameters

mixed $path The directory as a string or directories as an array to add.

Return Value

void

static JModelLegacy|boolean getInstance( string $type, string $prefix = '', array $config = array())

Returns a Model object, always creating it

Parameters

string $type The model type to instantiate
string $prefix Prefix for the model class name. Optional.
array $config Configuration array for model. Optional.

Return Value

JModelLegacy|boolean A \JModelLegacy instance or false on failure

__construct( array $config = array())

Constructor

Parameters

array $config An array of configuration options (name, state, dbo, tablepath, ignorerequest).

Exceptions

Exception

JDatabaseDriver getDbo()

Method to get the database driver object

Return Value

JDatabaseDriver

string getName()

Method to get the model name

The model name. By default parsed using the classname or it can be set by passing a $config['name'] in the class constructor

Return Value

string The name of the model

Exceptions

Exception

mixed getState( string $property = null, mixed $default = null)

Method to get model state variables

Parameters

string $property Optional parameter name
mixed $default Optional default value

Return Value

mixed The property where specified, the state object where omitted

JTable getTable( string $name = '', string $prefix = 'Table', array $options = array())

Method to get a table object, load it if necessary.

Parameters

string $name The table name. Optional.
string $prefix The class prefix. Optional.
array $options Configuration array for model. Optional.

Return Value

JTable A \JTable object

Exceptions

Exception

boolean loadHistory( integer $version_id, JTable $table)

Method to load a row for editing from the version history table.

Parameters

integer $version_id Key to the version history table.
JTable $table &$table Content table object being loaded.

Return Value

boolean False on failure or error, true otherwise.

void setDbo( JDatabaseDriver $db)

Method to set the database driver object

Parameters

JDatabaseDriver $db A \JDatabaseDriver based object

Return Value

void

mixed setState( string $property, mixed $value = null)

Method to set model state variables

Parameters

string $property The name of the property.
mixed $value The value of the property to set or null.

Return Value

mixed The previous value of the property or null if not set.