Login   Register  
PHP Classes
elePHPant
Icontem

File: bnkMstr01.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Prakash Khanchandani  >  Table Maintenance  >  bnkMstr01.php  >  Download  
File: bnkMstr01.php
Role: Example script
Content type: text/plain
Description: 4th level example
Class: Table Maintenance
Manage forms for CRUD MySQL table records
Author: By
Last change:
Date: 1 year ago
Size: 1,791 bytes
 

Contents

Class file image Download
<?php

/**
 * @author Prakash Khanchandani
 * @copyright 2013
 * @program bnkMstr01.php 
 * @description bank master maintenance
 * @specialities    - programming override to check whether delete allowed
 */


session_start();
require_once (
"classes.php");


function 
createTableObject()
{
    
$obj = new bnkMstrTbl;
    if (
$obj->getListAndColumns() === false)
        return 
false;
    else
        return 
$obj;
}


#
#
#
#
#


class bnkMstrTbl extends mstrTable
{
    function 
getListAndColumns()
    {
        
$this->tableName 'bnkMstr';

        
$this->orderByClause 'bank';
        
/*
        generate the list with auto determined columns, ie., dont pass any parameters. */
        
$result parent::getListAndColumns();
        return 
$result;
    }


    function 
canDelete()
    {
        
/* if the bnkMstr record is used in brnchMstr, cannot delete. Otherwise, can.
        Funciton returns a 'no' for cannot delete and a 'yes' for can delete. You
        cannot return true/false since that is used for returning error condition */
        
$id $this->getColDefsId('bank');
        
$val $this->colDefs[$id]['colValu'];
        
$script = new mstrScripts;
        
// check if bank is used in brnchMstr
        
$result $script->readMasterRecord("brnchMstr""bank='$val'""limit 1");
        if (
$result === false) {
            
addToErrorMsg($script->getErrorMsg());
            return 
false;
        }
        if (
count($result) > 0)
            return 
"no";
        else
            return 
"yes";
    }
}


#
#
#
#
#


if (!isset($_REQUEST['actn'])) {
    
$obj createTableObject();
} else {
    
/* if the user has taken some action, handle it. */
    
$obj handleRequestOption();
}


$form = new mstrFH($obj);
$form->setDemoNotes(bnk01Notes());
$form->displayForm();
?>