Open Source Content Management System

MidCOM DBA object method create

bool create();

This function creates a new database entry based on the current object state. In general, this function wraps MgdSchema::create() but provides more functionality in terms of event handlers (see below). It will return true if it was successful.

It is currently unknown to me what happens if you call create() on an object which has been already stored to the database. I suspect that Midgard will create a new record based on the current object, but I have not tested this yet.

After successfully storing the object, the id and guid member variables of the object will be populated with the newly generated identifiers.

Currently there is not much protection against invalid records that might not be useable afterwards built into the system. This is especially important if you want to used MgdSchema created functions with legacy Midgard.

$article = new midcom_baseclasses_database_article();  
$object->title = $title;
$object->name = $name;  
$object->topic = $topic->id;  

if ($object->create()) 
{
    print "Object created with ID {$obj->id}";
}

Required Privileges: midgard:create on the desired parent object. If this is a top-level object, you need at least the class restricted global ("SELF-Style") midgard:create privilege.

< Back to the MidCOM DBA Object API overview

Designed by Nemein, hosted by Anykey