PHP Classes

MySQL DB Class and Data Manipulation Class: MySQL wrapper with data manipulation functions

Recommend this page to a friend!
     
  Info   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStar 55%Total: 2,663 All time: 1,437 This week: 206Up
Version License PHP version Categories
mysqldbclass 1.0.0Freely Distributable5PHP 5, Databases
Description 

Author

This package is a MySQL database access wrapper with data manipulation functions.

There is one base class that can establish MySQL database connections, sanitize values to use in SQL queries, execute SQL queries, retrieve SELECT query results into arrays, execute SQL INSERT queries and retrieve the last inserted identifier.

There is also a sub-class that can retrieve the list of fields of a table, compose and execute an SQL SELECT, INSERT, UPDATE and DELETE queries from a list of parameters.

Picture of Mitchelle Pascual
Name: Mitchelle Pascual <contact>
Classes: 3 packages by
Country: Philippines Philippines
Age: 40
All time rank: 1072 in Philippines Philippines
Week rank: 180 Down3 in Philippines Philippines Down

Details

This package is a MySQL database access wrapper with data manipulation functions. There is one base class that can establish MySQL database connections, sanitize values to use in SQL queries, execute SQL queries, retrieve SELECT query results into arrays, execute SQL INSERT queries and retrieve the last inserted identifier. There is also a sub-class that can retrieve the list of fields of a table, compose and execute an SQL SELECT, INSERT, UPDATE and DELETE queries from a list of parameters. Steps: 1. Configure db info @ folder ("conf/config.php"). 2. Connect to db. eg. $dbconn = new MySQLDB($conf['dbhost'], $conf['dbusername'], $conf['dbpassword'], $conf['dbname']); 3. Instantiate table. eg. $my_data = new Data('my_table_name'); *************************************** Adding Data Sample: *************************************** @params: array of table fields @params: array of form name and its value $my_data->addData(array('field1', 'field2', 'field3'), array('field1'=>'value1', 'field2'=>'value2', 'field3'=>'value3')); *************************************** Updating Data Sample: *************************************** @params: array of table fields @params: array of form name and its value @params: array or string of condition $my_data->updateData(array('field1', 'field2', 'field3'), array('field1'=>'value1', 'field2'=>'value2', 'field3'=>'value3'), array('field1'=>1)); *************************************** Deleting Data Sample: *************************************** @param: array or string of condition $my_data->deleteData(array('field1'=>1)); $my_data->deleteData(array("field1=1 AND field2=2")); *************************************** Retrieving more than one data sample: *************************************** -------------------------------------- @params: array of table fields $my_data->getAllData(array('field1', 'field2', 'field3')); -------------------------------------- @params: array of table fields @params: arrays conditions $my_data->getAllData(array('field1', 'field2', 'field3'), array( array(TRUE, 'AND', array('field1'=>'value1')) ), array(TRUE, '', array('field2'=>'value2')) ) ); -------------------------------------- @params: array of table fields @params: arrays conditions @params: array of ordering/sorting $my_data->getAllData(array('field1', 'field2', 'field3'), array( array(TRUE, '', array('field2'=>'value2')) ), array('field1'=>'ASC', 'field2'=>'DESC') ); -------------------------------------- @params: array of table fields @params: arrays conditions @params: array of ordering/sorting @params: int starting row of query @params: int limitation of query $my_data->getAllData(array('field1', 'field2', 'field3'), array( array(TRUE, '', array('field2'=>'value2')) ), array('field1'=>'ASC', 'field2'=>'DESC'), 0, 10 ); *************************************** Notes: *************************************** To dynamically get array of table fields from specified table name: $fields = $my_data->getFields(); To run your own query: After instantiating db connection, eg. $dbconn = new MySQLDB($conf['dbhost'], $conf['dbusername'], $conf['dbpassword'], $conf['dbname']); Then @params: your query @params: result type - options: "ARRAY" = more than one row, "ROW" = only one row @params: query type - options 0 = MYSQL_BOTH, 1 = MYSQL_NUM, default 2 = MYSQL_ASSOC $dbconn->MySQLDB_GetData("SELECT * FROM tbl", "ARRAY", 0) By: Mitchelle C. Pascual (mitch.pascual at gmail dot com) http://ordinarywebguy.wordpress.com

  Files folder image Files (10)  
File Role Description
Files folder imageconf (1 file)
Files folder imageincludes (1 file, 2 directories)
Accessible without login Plain text file init.php Example Load/Initialize class
Accessible without login Plain text file localhost.sql Data db sample
Accessible without login Plain text file README.txt Doc. How to use
Accessible without login Plain text file sample_data.php Example sample script

  Files folder image Files (10)  /  conf  
File Role Description
  Accessible without login Plain text file config.php Conf. DB info configuration file

  Files folder image Files (10)  /  includes  
File Role Description
Files folder imagedbclasses (2 files)
Files folder imagejs (2 files)
  Accessible without login Plain text file DBOpen.php Example Initialize DB connection

  Files folder image Files (10)  /  includes  /  dbclasses  
File Role Description
  Plain text file Data.class.php Class Data Manipulation Class
  Plain text file MySQLDB.php Class MySQL DB Abstraction Class

  Files folder image Files (10)  /  includes  /  js  
File Role Description
  Accessible without login Plain text file confirm.js Data Prompt confirmation
  Accessible without login Plain text file validation.js Data Render Form Validation in JS

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:2,663
This week:0
All time:1,437
This week:206Up
User Ratings User Comments (1)
 All time
Utility:70%StarStarStarStar
Consistency:70%StarStarStarStar
Documentation:66%StarStarStarStar
Examples:66%StarStarStarStar
Tests:-
Videos:-
Overall:55%StarStarStar
Rank:1914
 
testing
16 years ago (sivakumar)
62%StarStarStarStar