PHP Classes

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

Recommend this page to a friend!

  Author Author  
Picture of Mitchelle Pascual
Name: Mitchelle Pascual <contact>
Classes: 3 packages by
Country: Philippines Philippines
Age: 38
All time rank: 1072 in Philippines Philippines
Week rank: 438 Down4 in Philippines Philippines Down


  Detailed description   Download Download .zip .tar.gz   Install with Composer Install with Composer  
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.

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

  Classes of Mitchelle Pascual  >  MySQL DB Class and Data Manipulation Class  >  Download Download .zip .tar.gz  >  Support forum Support forum (1)  >  Blog Blog  >  RSS 1.0 feed RSS 2.0 feed Latest changes  
Name: MySQL DB Class and Data Manipulation Class
Base name: mysqldbclass
Description: MySQL wrapper with data manipulation functions
Version: 1.0.0
PHP version: 5
License: Freely Distributable
All time users: 2661 users
All time rank: 1437
Week users: 0 users
Week rank: 423 Equal
 
  Groups   Rate classes User ratings   Applications   Related pages   Files Files  

  Groups  
Group folder image PHP 5 Classes using PHP 5 specific features View top rated classes
Group folder image Databases Database management, accessing and searching View top rated classes


  User ratings  
RatingsUtility Consistency Documentation Examples Tests Videos Overall Rank
All time: Sufficient (75%) Sufficient (75%) Sufficient (70%) Sufficient (70%) - - Not sure (59%) 1493
Month: Not yet rated by the users

  Applications that use this package  
No pages of applications that use this class were specified.

Add link image If you know an application of this package, send a message to the author to add a link here.


  Related pages  
Data Manipulation DEMO

  Files folder image Files  
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  /  conf  
File Role Description
  Accessible without login Plain text file config.php Conf. DB info configuration file

  Files folder image Files  /  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  /  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  /  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

Install with Composer Install with Composer - Download Download all files: mysqldbclass.tar.gz mysqldbclass.zip
NOTICE: if you are using a download manager program like 'GetRight', please Login before trying to download this archive.
  Files folder image Files  
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  /  conf  
File Role Description
  Accessible without login Plain text file config.php Conf. DB info configuration file

  Files folder image Files  /  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  /  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  /  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

Install with Composer Install with Composer - Download Download all files: mysqldbclass.tar.gz mysqldbclass.zip
NOTICE: if you are using a download manager program like 'GetRight', please Login before trying to download this archive.