PHP Classes

MARK_MYSQL: MySQL interface

Recommend this page to a friend!
  Info   View files View files (3)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 1,225 All time: 3,113 This week: 451Up
Version License Categories
class_mysql 1.0GNU General Publi...Databases


A wrapper for MySQL queries. Easy to use.

Picture of Mark Quah
Name: Mark Quah <contact>
Classes: 7 packages by
Country: Singapore Singapore
Age: ???
All time rank: 2601 in Singapore Singapore
Week rank: 364 Down2 in Singapore Singapore Down


Another unpolished class. Those take time to polish it up please do inform me. This class has been used extensively in my web project and I really find that it is very much convenient to use. This is the way to use it: ------------------------------------------------ INITIALIZATION: include_once "class_mysql.php"; $my_db = new MYSQL("server", "user", "passwd", "database to use"); ------------------------------------------------ DO A QUERY EXPECTING INPUT $stmt = "SELECT * ...."; $status = $my_db->RunDB($stmt); if ($status != "OK") { echo "FAIL"; die; } now the number of records retreived is stored in $no_rec = $my_db->no_rows; to retrieve individual fields, say field name is "A", "B", C" for ($i = 0; $i < $no_rec; $i ++) // record number { $fieldA=$my_db->row[$i]['A']; $fieldA=$my_db->row[$i]['B']; $fieldA=$my_db->row[$i]['C']; ... do your processing. } IF you don't know about the field names, here's what you can do: for ($j = 0; $j < $my_db->no_fields; $j ++) $field_name[j] = $my_db->field[$j]; no_fields contains no of fields within a record. each field name is contained in $my_db->field[$j] --------------------------------------------------- DO A SQL STATEMENT NOT EXPECTING OUTPUT If you do a insert or update, you do not expect the array $my_db->row to be filled, so you specify a 0 after the RunDB statement: $stmt="INSERT INTO table (a,b,c) VALUES(1,2,3);"; $status = $my_db->RunDB($stmt, 0); if ($status != "OK") { echo "FAILED: $status"; die; } ------------------------------------------------------ USE THE BUILT IN HTML OUTPUT Pretty but seldom used function. This is for me to displayed an unknown SQL table data. $status = $my_db->RunDB("select * from user;"); if ($status != "OK") { echo "<HR>DB Error: $status.<HR>"; die; } $mysql->ShowHTML("table_header","row header","cell header"); The HTML output will be something like: <TABLE table_header> <TR row_header> <TD cell_header> value ....

  Files folder image Files  
File Role Description
Plain text file class_mysql.php Class MySQL wrapper
Accessible without login Plain text file class_mysql_sample.php Example Sample script
Accessible without login Plain text file README.TXT Doc. Readme

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:3,113
This week:451Up