$object->create

(unknown)

$object->create -- Create a record

Description

int $object->create (void)

Minimum version: Midgard 1.4 (Bifrost)

Is used to create a new record. An object must first be instantiated by calling mgd_get_XXX() without parameters.

Returns record id if successful. Returns FALSE on failure.


<?php
  $article = mgd_get_article();
  $article->topic     = 17; // Article will be under topic no. 17
  $article->title     = "\$article->create(); example";
  $article->abstract  = "Creating articles is easy ...";
  $article->content   = "Creating articles is easy, "; 
  $article->content  .= "using the \$article->create(); method ";
  $article->content  .= "makes it even easier. Code will be ";
  $article->content  .= "more readable, too.";
  $article->author    = $midgard->user;
  
  if(! $id = $article->create()) {
    echo "Failed to create article.<br>\n";
    echo "Reason: " . mgd_errstr() . "<br>\n";
  } else {
    echo "Article created. ID of article is $id.<br>\n";
  }
?>
      

Method available for: article, element, event, event_member, group, host, member, page, pageelement, pagelink, person, preference, sitegroup, snippet, snippetdir, style and topic objects.