->set*() and ->get*()

->set*() and ->get*()

->set*() and ->get*() -- Automatic Setters and Getters using overload

Description

From version PHP 4.3.2RC2 onwards, DB_DataObject is automatically overloaded, providing access to all variables using $object->set{ColumnName}() and $object->set{ColumnName}($value) even if you have not defined the method.

It is assumed that set methods return strings as errors or TRUE, so that it can interact with setFrom and return array's of error strings.

The get Methods are used by toArray(), if defined they can be used to alter the appearance of columns ,like making dates human readable

The logic is very simple, if you call $object->setXXX() and it is not defined, it will just set the value, if you define a method setXXXX, that will be called instead of the default handler, same applies to getXXX().

Due to the naming conflict possiblity of a column named from, the associated method for column 'from' is set_from, rather than setFrom()

Parameter

  • mixed $value - on setters only (the value to assign to the column), on getters you may like to implement date formating or sprintf formating as the argument.

Return value

mixed - setters will return TRUE from the default method, in your implementations of setters. It is expected that setXXX($value) will return a string (the error) if it is invalid or TRUE on success. getXXX may return the value or a formated value, remember though it affects $object->toArray().

Note

This function can not be called statically.

Warning: This is experimental, its behavour may change slightly in the future.

© Copyright 2003-2023 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.