PHP Classes

Automatic Priority Setting in any table Modified: Update or delete MySQL records with given priority

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 177 All time: 8,749 This week: 123Up
Version License PHP version Categories
priority-class 1.0.0GNU General Publi...5PHP 5, Databases
Description 

Author

This class can update or delete MySQL records with given priority.

It can find records in a given MySQL table that match a given condition and have a given priority field set to a given value

The class sets priority field of the found records to a new value.

It can also delete records that match given conditions.

The table names and the fields that have the priority values are configurable parameters.

Picture of Gautam Lohar
Name: Gautam Lohar <contact>
Classes: 2 packages by
Country: India India
Age: 41
All time rank: 3513231 in India India
Week rank: 214 Up11 in India India Up

Example

<?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 = "product_parts";
   
$fieldName = "unique_ids";
   
$primaryKey = "part_id";
   
   
   
$priorityObj = new priority($tableName,$fieldName,$primaryKey);
   
$a_condiotionIDs = array('product_sku'=>'DVP8922');

   
   
/*****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 = 604;
   
$priorityObj -> deletePriority($id,$a_condiotionIDs);
   
/**************************/

   
echo "Done successfully";

?>


  Files folder image Files (3)  
File Role Description
Accessible without login Plain text file connection.php Aux. connection file
Accessible without login Plain text file example.php Example Example
Plain text file priority.php Class Priority Class

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 0%
Total:177
This week:0
All time:8,749
This week:123Up
User Comments (1)