PHP Classes

MyClasses: Set of classes for Web application development

Recommend this page to a friend!
  Info   View files Documentation   View files View files (6)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2022-07-23 (4 months ago) RSS 2.0 feedNot yet rated by the usersTotal: 86 All time: 9,834 This week: 138Up
Version License PHP version Categories
myclasses 1.0GNU General Publi...5PHP 5, Databases, E-Commerce, Web ser..., V..., L...
Description Author

This package provides a set of classes for Web application development.

It comes with several classes that implement functionality that can be used in any Web application.

Currently, it provides classes for:

- Shopping cart class that uses PHP sessions to store products in cart items

- Exception handling class that sends exception error messages in log files

- A form validation class that can validate submitted values of several types

- A database access class that can perform several types of queries using MySQLi

- A weather forecast retrieval that uses the Wunderground API

Picture of Nemeth Zoltan
  Performance   Level  
Name: Nemeth Zoltan is available for providing paid consulting. Contact Nemeth Zoltan .
Classes: 9 packages by
Country: Hungary Hungary
Age: 45
All time rank: 158613 in Hungary Hungary
Week rank: 287 Up3 in Hungary Hungary Up
Innovation award
Innovation award
Nominee: 2x

Winner: 1x

Details

MyClasses is a package folder with my usable or developed classes.

Please use carefull!

IDatabase

This class is a MySQL Database access wrapper using MySQLi.

It can: - Connect to a MySQL server - Get MySQL server statistics - Execute a SELECT SQL query and return all the results into an array - Execute SQL INSERT, UPDATE and DELETE queries given the SQL query - Execute SQL INSERT or UPDATE queries given the table name, the list of field names and values - Get the number of records in a table that match a given condition - Get a single field or a single row of a table that matches a condition

Sample uses:

Include the neccessary classes:

include_once 'classes/IDatabase.class.php';
include_once 'classes/EException.class.php';

...or use autoload.

Create a connection and run a basic query:

$connection = IDatabase::getSingleton();
$sample = $connection->select("SELECT * FROM sampletable");

Wunderground API

include_once 'classes/EException.class.php';
include_once 'classes/IDatabase.class.php';
include_once 'classes/Wunderground.class.php';
define("SERVICE_KEY", ""); // Add service key here! 
define("SERVICE_URL", "http://api.wunderground.com/api/!key/!action/lang:!lang/q/");
$wunderground = new WunderGroundAPI(SERVICE_KEY, SERVICE_URL);

// Check class data 
print $wunderground;

// Set city and country 
$wunderground->setCity('Sydney','AU'); 

// Get data, if enable caching then from the cache 
// Actions: forecast, alerts, almanac, astronomy, conditions, currenthurricane, forecast10day, geolookup, hourly, hourly10day, rawtide, satellite, tide, webcams, yesterday
$ret = $wunderground->getData('forecast'); 

FormDataValidator

require_once 'classes/FormDataValidator.class.php';
 
$accepted = array('name', 'nick', 'email', 'message'); 
$required = array('name', 'nick', 'message'); 

$validator = new FormDataValidator($_POST, $accepted, $required); 
$resp = $validator->validate(); 

var_export($resp); 

Basket

Include main class

include_once 'Basket.class.php';

Sample summary function for testing:

  function summarylist() { 
    $items = Basket::getItemList(); 
    var_export($items); 
    print "<br>Full price: " . Basket::getFullPrice(); 
    print "<br>Item quantity: " . Basket::getItemCount(); 
    print "<br>Item types: " . Basket::getItemtypeCount(); 
    print "<br>Last modify: " . Basket::getLastModify(false). " (".Basket::getLastModify().")"; 
  } 

Empty basket:

  Basket::emptyBasket(); 
  print "Simple Static Basket with session storage<br>"; 
  print "<br>Basket (empty) [emptyBasket, getItemList]<br>"; 
  summarylist(); 

Add simple or multiple items:

  print "<br><br>Add a simple item [changeItem]<br>"; 
  Basket::changeItem('sugar_01', 12.25, 'Sugar, 1kg', 0.75); 
  summarylist();
   
  print "<br><br>Add multiple items [addItemFromArray]<br>"; 
  $add_items = array( 
    array('id' => 'salt_01', 'quantity' => 4.57, 'name' => 'Salt, 1kg', 'price' => 0.65), 
    array('id' => 'salt_02', 'quantity' => 3.10, 'name' => 'Salt, 2kg', 'price' => 1.15), 
    array('id' => 'salt_03', 'quantity' => 2.90, 'name' => 'Salt, 5kg', 'price' => 2.55), 
    array('id' => 'sugar_02', 'quantity' => 1.34, 'name' => 'Sugar, 2kg', 'price' => 1.40), 
    array('id' => 'sugar_03', 'quantity' => 13.45, 'name' => 'Sugar, 5kg', 'price' => 3.59), 
  ); 
  Basket::addItemFromArray($add_items); 
  summarylist(); 

Remove a single item:

  print "<br><br>Remove salt_03 [removeItem]<br>"; 
  Basket::removeItem('salt_03'); 
  summarylist(); 

Change item quantity, price or name:

  print "<br><br>Change the quantity of salt_02 to 3.45 [changeItem]<br>"; 
  Basket::changeItem('salt_02', 3.45, null, 0); 
  summarylist(); 

  print "<br><br>Change the price of salt_02 to 1.23 [changeItem]<br>"; 
  Basket::changeItem('salt_02', 0, null, 1.23); 
  summarylist(); 

  print "<br><br>Change the name of salt_02 to Sugar, 1.5kg [changeItem]<br>"; 
  Basket::changeItem('salt_02', 0, 'Sugar, 1.5kg', 0); 
  summarylist(); 
  Files folder image Files  
File Role Description
Files folder imageclasses (5 files)
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  classes  
File Role Description
  Plain text file Basket.class.php Class Class source
  Plain text file EException.class.php Class Class source
  Plain text file FormDataValidator.class.php Class Class source
  Plain text file IDatabase.class.php Class Class source
  Plain text file Wunderground.class.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:86
This week:0
All time:9,834
This week:138Up