Recommend this page to a friend! |
Download .zip |
Info | View files (3) | Download .zip | Reputation | Support forum | Blog | Links |
Last Updated | Ratings | Unique User Downloads | Download Rankings | |||||
2002-12-18 (13 years ago) | Not yet rated by the users | Total: 1,221 | All time: 3,019 This week: 905 |
Version | License | Categories | ||||
class_mysql 1.0 | GNU General Publi... | Databases |
Description | Author | |
A wrapper for MySQL queries. Easy to use. |
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 |
File | Role | Description |
---|---|---|
class_mysql.php | Class | MySQL wrapper |
class_mysql_sample.php | Example | Sample script |
README.TXT | Doc. | Readme |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
0% |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.