PHP Classes

File: mysql_example.php

Recommend this page to a friend!
  Classes of Cornelius Bolten   Version Control 2006   mysql_example.php   Download  
File: mysql_example.php
Role: Example script
Content type: text/plain
Description: mysql example
Class: Version Control 2006
Managing revisions of content articles
Author: By
Last change:
Date: 18 years ago
Size: 1,799 bytes
 

Contents

Class file image Download
<?php

   
include_once('VersionControl.php');
    include_once(
'VersionControlMySQL.php');


   
/*
    * define a random content-object containing:
    * - a unique object-identifier (like a unique id, a unique string, or what ever)
    * - some data as array (e.g. an title, and description and some text)
    * - an editor id, who created the object (e.g. an editorial journalist)
    * - an comment as a description of the content
    */
   
$sUniqueObjectIdentifier = md5('asdfiupweoiraoidfjasoldfjaef');
   
$aObjectData = array(
       
2,'a',
       
3,'b',
       
4,'c'
   
);
   
$iEditorId = 1;
   
$sComment = 'this is a random content object';


   
/*
    * now initiate a new versioncontrol-MYSQL object
    */
   
$oVC = new VersionControlMySQL();
    try {
       
/*
        * try to submit the content-object to the repository
        */
       
$oVC->submit_version($sUniqueObjectIdentifier, $aObjectData, $iEditorId, $sComment);
    } catch (
ObjectVersionAlreadyExistsException $e) {
       
/*
        * the first time, this error will NOT occur.
        * after the content-object has been submitted to the repository,
        * the versioncontrol will throw the error "Object Already Exists",
        * which means nothing more than, "there is already an identical object in the repository"
        */

        // return the latest version of our content-object
       
echo 'This is the latest version available in the versioncontrol-repository:<br/>';
       
print_r(
           
$oVC->get_latest_version($sUniqueObjectIdentifier);
        );
    } catch (
Exception $e2) {
       
/*
        * another error occured
        */
       
echo $e2->getMessage();
    }
?>