Benutzer-Werkzeuge

Webseiten-Werkzeuge


en:webedition:code-examples:deleting-an-object-using-php

Deleting an object using PHP

Prerequisites

  • DB/Object Module

The following example shows you how to delete an object (DB/Object Module) using PHP. You may execute this source code from any dynamical PHP-page.

Source code

<?php
  // ID of object to be deleted (here: 501)
  $i_object_id = (int) 501;
 
  // Avoid safety lock
  // If the value of this global PHP-Variable is not set to "true",
  // a valid webEdition-session is required.
  // Otherwise, the PHP-Script abandons.
  $GLOBALS['NOT_PROTECT'] = (bool) true;
 
  // Embed PHP-classes of webEdition to work with objects
  include_once $_SERVER['DOCUMENT_ROOT'].'/webEdition/we/include/we.inc.php';
  include_once $_SERVER['DOCUMENT_ROOT'].'/webEdition/we/include/we_delete_fn.inc.php';
 
  // Delete object with provided ID
  deleteEntry($i_object_id, OBJECT_FILES_TABLE);
?>

The IDs of all deleted object are saved in the PHP-array $deletedItemst. The following example shows you how to put out that information after deleting.

Source code

<?php
  // ID of object to be deleted
  $i_object_id = (int) 501;
 
  // Avoid safety lock
  // If the value of this global PHP-Variable is not set to "true",
  // a valid webEdition-session is required.
  // Otherwise, the PHP-Script abandons.
  $GLOBALS['NOT_PROTECT'] = (bool) true;
 
  // Embed PHP-classes of webEdition to work with objects
  include_once $_SERVER['DOCUMENT_ROOT'].'/webEdition/we/include/we.inc.php';
  include_once $_SERVER['DOCUMENT_ROOT'].'/webEdition/we/include/we_delete_fn.inc.php';
 
  // Delete object with provided ID
  deleteEntry($i_object_id, OBJECT_FILES_TABLE);
 
  // output of all deleted objects
  if (isset($deletedItems)) {
    print_r($deletedItems);
  }
?>
en/webedition/code-examples/deleting-an-object-using-php.txt · Zuletzt geändert: 2009/05/27 11:03 von Dirk Einecke

Recent changes RSS feed