Article Figure 1 Figure 2 Figure 3 Listing 1
Listing 2 Listing 3 Listing 4 Listing 5 mar2006.tar

Listing 1 Automatically generated example class

<?php

//
// Class: Example
// Table: example
// Database: APG
//
// Generated by buildClass.php, written by Dick Munroe (munroe@csworks.com)
//

include_once("SQLData/class.SQLData.php") ;             // (1)
include_once("SDD/class.SDD.php") ;

class Example extends SQLData                           // (2)
{

    //
    // Private (or constant) varibles.
    //
    
    var $m__tableName = 'example' ;                     // (3)

    //
    // Constructor
    //
    
    function Example($_dataBase,                        //(4)
                     $_host="localhost",
                     $_login="",
                     $_password="")
    {
        $this->SQLData($this->m__tableName, $_dataBase, $_host, \
          $_login, $_password) ;
    }

    //
    // Accessor Functions
    //
     
    function setId($theValue)                           // (5)
    {
        $this->set('id', $theValue) ;
    }
    
    function getId()                                    // (6)
    {
        return $this->get('id') ;
    }
    
    function initId($theValue)                          // (7)
    {
        $this->init('id', $theValue) ;
    }
    
    function un_setId()                                 // (8)
    {
      $this->un_set('id') ;
    }

    function is_setId()                                 // (9)
    {
      return $this->is_set('id') ;
    }

    //
    // Default update selector
    //

    function needUpdateSelector()                       // (10)
    {
        if (($this->is_setId()))
           return "where `id` = '" . $this->escape_string($this->getId()) .
                "'" ;

     trigger_error("Internal Logic Error: No key data present", 
                   E_USER_ERROR) ;
    }

    //
    // Insert function
    //

    function insert()                                   // (11)
    {
        $theReturnValue = parent::insert() ;
        if ($theReturnValue)
        {
            $this->initId($this->fetchLastInsertId()) ;
        }
        return $theReturnValue ;
    }

    //
    // Debugging Functions
    //

    function print_r()                                  // (12)
    {
      $sdd = new SDD() ;
      print($sdd->dump($this)) ;
    }
}

?>