Login   Register  
PHP Classes
elePHPant
Icontem

File: example

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Gautam Lohar  >  Automatic Priority Setting  >  example  >  Download  
File: example
Role: Example script
Content type: text/plain
Description: example to use the class
Class: Automatic Priority Setting
Update priority records in a MySQL database table
Author: By
Last change:
Date: 2010-02-18 11:05
Size: 1,236 bytes
 

Contents

Class file image Download
<?php
    
########### INSTRUCTIONS #############
    /*
    Run follwing two queries on your sample database or test datatbase then make connection and run this page on your browser
    
    
    create table test(TestID smallint unsigned not null PRIMARY KEY auto_increment,TestName varchar(20) not null default '',Priority tinyint(3) unsigned not null default 0)

    INSERT INTO `gatloding`.`test` (`TestID`, `TestName`, `Priority`) VALUES (NULL, 'Test1', '1'), (NULL, 'Test2', '2'), (NULL, 'Test3', '3'), ('4', 'Test4', '4'), ('5', 'Test5', '5')

     */
    #######################################
    
include("connection.php");
    include(
"priority.php");
    
    
$tableName            =    "test";
    
$fieldName            =    "Priority";
    
$primaryKey            =    "TestID";

    
$priorityObj        =    new priority($tableName,$fieldName,$primaryKey);

    
    
/*****To update priority or serial no*/
    
$id                    =    4;
    
$serialNo            =    1;    
    
$oldSerialNo        =    4;
    
$priorityObj    ->    updatePriority($id,$serialNo,$oldSerialNo);
    
/***************************/    

    /*****To maintain priority/serialno when we delete a PrimaryID*/
    //Please uncomment following two lines for delete
    //$id    =    3;
    //$priorityObj    ->    deletePriority($id);
    /**************************/

    
echo "Done successfully";

?>