Definition
XoopsObjectHandler(Database $db )
Most Important Methods
create() - creates a new object get() - get object from database insert() - save object in database (either insert or update) delete() - delete object in database
Usage
Instead of instantiating your objects directly, the idea is to use the ObjectHandler instead. An object is created (new object - it can still come from the database or be an entirely new object) with this code:
$class_handler =& xoops_gethandler('classname'); //NOT classnameHandler
$thisobject =& $class_handler->get($objectid);
This is for an existing object in the database. For a new object, use this:
$class_handler =& xoops_gethandler('classname'); //NOT classnameHandler
$thisobject =& $class_handler->create();
This is for core classes. Module classhandlers should be fetched with
$class_handler =& xoops_getmodulehandler('classname', 'dirname'); //NOT classnameHandler
The classHandler class should be in a file called classname.php placed in the modules/modulename/class directory. E.g. if the Story module has an Article class, extending XoopsObject, the class should be placed in a file called modules/story/class/article.php with the handler class in the same file and called StoryArticleHandler, extending XoopsObjectHandler and retrieved with xoops_getmodulehandler('article', 'story').
You do not need to include the php file yourself, if it follows the naming convention.
Back to Main Page

![[Main Page]](/modules/mediawiki/images/mediawiki.png)





