PHP Classes

MySQLi Complete Class: Perform SQL queries from parameters using MySQLi

Recommend this page to a friend!
  Info   View files Example   View files View files (3)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStarStar 70%Total: 544 All time: 5,518 This week: 200Up
Version License PHP version Categories
mysqli-complete 1.0.0Freely Distributable5PHP 5, Databases, Utilities and Tools
Description Author

This package can perform SQL queries from parameters using MySQLi.

It can connect to a MySQL database using MySQLi and executes common SQL queries composed using given parameters like table names, fields, field values and conditions. Currently it can execute:

- SELECT queries of given table fields and condition
- INSERT queries with given table field values
- UPDATE queries with given table field values and condition
- DELETE queries on given table and condition
- List fields of a given table

Picture of Marcelo Franco
  Performance   Level  
Name: Marcelo Franco <contact>
Classes: 1 package by
Country: Brazil Brazil
Age: 59
All time rank: 3159232 in Brazil Brazil
Week rank: 587 Up38 in Brazil Brazil Up

Details
MySQLi CLASS ------------------------------------------------------------------------------------------------------------------------ Example Table: CREATE TABLE `_Users` ( `UserID` INT(11) NOT NULL AUTO_INCREMENT, `UserName` VARCHAR(100) NULL DEFAULT NULL, `UserMail` VARCHAR(180) NULL DEFAULT NULL, PRIMARY KEY (`UserID`) ) ENGINE=innoDB ; INSERT INTO `_Users` (`UserName`, `UserMail`) VALUES ('User 01 Name', 'user1@industriavirtual.com.br'); INSERT INTO `_Users` (`UserName`, `UserMail`) VALUES ('User 02 Name', 'user2@industriavirtual.com.br'); INSERT INTO `_Users` (`UserName`, `UserMail`) VALUES ('User 03 Name', 'user3@industriavirtual.com.br'); ------------------------------------------------------------------------------------------------------------------------ HOW TO USE (in your PHP code): 1) Define Database Connection: define("DBHOST", "host"); define("DBUSER", "user"); define("DBPASS", "password"); define("DBNAME", "database"); ------------------------------------------------------------------------------------------------------------------------ 2) Include Class File: require_once("mysqli.php"); ------------------------------------------------------------------------------------------------------------------------ 3) Open Connection: $db = new dbConn(); ------------------------------------------------------------------------------------------------------------------------ 3) Record Select Example: if ($r = $db->select("UserID, UserName, UserMail", "_Users", "where UserID=1")) { echo $r["UserMail"] . "<br />"; } else { echo "- No Record Found!<br />"; } unset($r); ------------------------------------------------------------------------------------------------------------------------ 3) Close Connection: $db->close(); ------------------------------------------------------------------------------------------------------------------------ NOTE: Optional Connection With Other Database: $db = new dbConn("host", "user", "password", "database"); ------------------------------------------------------------------------------------------------------------------------ OTHER INCLUDED FUNCTIONS: A) Select Group of Records Example: $d = $db->selectGroup("*", "_Users", "LIMIT 10"); while($r = $d->fetch_assoc() ) { echo $r["UserMail"] . "<br />"; } $d->close(); ------------------------------------------------------------------------------------------------------------------------ B) Insert Example: $t = array(); $t["UserName"] = "Industria Virtual 1"; $t["UserMail"] = "email1@industriavirtual.com.br"; $db->insert("_Users", $t) ------------------------------------------------------------------------------------------------------------------------ C) Update Example: $t = array(); $t["UserName"] = "Industria Virtual 2"; $t["UserMail"] = "email2@industriavirtual.com.br"; $db->update("_Users", $t, "WHERE UserID=1") ------------------------------------------------------------------------------------------------------------------------ D) Delete Example: $db->delete("_Users", "WHERE UserID=1") ------------------------------------------------------------------------------------------------------------------------ E) Free Query Execute: $a = $db->query("select * from _Users"); foreach ($a as $b) { echo $b["UserMail"] . "<br />"; } $a->close(); ------------------------------------------------------------------------------------------------------------------------ BONUS: I) List Tables in Database: $tables = $db->listTables(); $arrlength = count($tables); for($x = 0; $x < $arrlength; $x++) { echo $tables[$x] . "<br />"; } ------------------------------------------------------------------------------------------------------------------------ II) List Fields from Table: $fields = $db->listFields("_Users"); $arrlength = count($fields); for($x = 0; $x < $arrlength; $x++) { echo "Field [" . $fields[$x]['name'] . "] - Type [" . $fields[$x]['type'] . " (" . $fields[$x]['code'] . ")] - Max Length [" . $fields[$x]['size'] . "]<br />"; } ------------------------------------------------------------------------------------------------------------------------ Check file "example.php" for more information. Contact: Marcelo Franco (codes@industriavirtual.com.br)
  Files folder image Files  
File Role Description
Accessible without login Plain text file example.php Example Example of use.
Plain text file mysqli.php Class A complete class for MySQL database handling with standard MSQLI connection.
Accessible without login Plain text file readme.txt Doc. README file.

 Version Control Unique User Downloads Download Rankings  
 0%
Total:544
This week:0
All time:5,518
This week:200Up
 User Ratings  
 
 All time
Utility:90%StarStarStarStarStar
Consistency:90%StarStarStarStarStar
Documentation:80%StarStarStarStarStar
Examples:80%StarStarStarStarStar
Tests:-
Videos:-
Overall:70%StarStarStarStar
Rank:379