WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Forex Trading Online forex trading platform

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : MySQL High Level Wrapper
Categories : PHP, PHP Classes, MySQL, Databases Click here to Update Your Picture
Victor Roman Archidona
Date : Dec 06th 2005
Grade : 4 of 5 (graded 5 times)
Viewed : 2954
File : 4271.zip
Images : No Images for this code example.
Search : More code by Victor Roman Archidona
Action : Grade This Code Example
Tools : My Examples List

 
Like this code?
Show the author your appreciation.
Submit your own code examples 
 

This class allows the programmer to easily communicate with a MySQL server. It wraps around (in fact, is a wrapper) the PHP's mysql routines.

The ZIP file attached contains the full class and a Doxygen generated documentation.

Three examples are provided in one file:

<?php
require_once "MySQL.class.php";

$user = "root";      # Your database username
$pass = "";          # The password of your user account
$host = "localhost"; # Host with MySQL running
$db   = "mysql";     # Database to use

$mysql = new MySQL();

/* Connects to database */
$mysql->Connect($host, $user, $pass, $db, 0);

####################
# Sample 1
# --------
# This example shows ALL tables with all fields and their maximum length
# inside the current database
####################
foreach($mysql->getTables() as $table) {
    echo
"$table <br />"
   
    foreach (
$mysql->getFields($table) as $field) {
       
$cur_length = $mysql->getFieldLength($table, $field);
        echo
"   |-- $field (Length: $cur_length)<br />";
    }
       
    echo
"<br />";
}

####################
# Sample 2
# --------
# Enables the internal debugger and optimizes all tables into the inside
# database
####################
$mysql->setDebug(true);
$mysql->optimizeAll();
$mysql->setDebug(false);

####################
# Sample 3
# --------
# Simple query which retrieves all users in this MySQL server (needs to be
# root). The resultset is taken from an associative array using fetchAssoc().
####################
$res = $mysql->Query("SELECT * FROM user");
while (
$ret = $mysql->fetchAssoc()) {
    foreach (
$ret as $k => $v) {
        echo
"\$ret[$k] => $v<br />";
    }
}
     
   
/* Disconnects */
$mysql->Disconnect();
?>



MySQL Connection/Query Class
Categories : Databases, MySQL, PHP, PHP Classes
Create and restore backup of MySQL databases
Categories : MySQL, Databases, PHP, PHP Classes, Complete Programs
Specify your connection settings and create a link to a MySQL database.
Categories : PHP, PHP Classes, Databases, MySQL, Beginner Guides
MySQL Class to ease Database connectivity
Categories : MySQL, PHP Classes, Databases, PHP
PHP Transfer data from text file to Mysql Table
Categories : PHP, PHP Classes, Filesystem, Databases, MySQL
MySQL database class
Categories : PHP, MySQL, Databases, PHP Classes
Powerful php/mysql Pagination for up to 6 URL Params
Categories : PHP, PHP Classes, Databases, MySQL, Navigation
A script to generate a report from a valid mysql connection. The user has to supply which fields he wants to display in table. All properties are changable.
Categories : PHP, PHP Classes, Databases, MySQL, HTML and PHP
PHP Object Example of the Perl DBI with MySQL
Categories : PHP, PHP Classes, MySQL, Databases, Perl
usercounter class
Categories : PHP, PHP Classes, Databases, MySQL, Environment Variables
DBXML- A Class to backup databases in XML Format using web interface
Categories : PHP, PHP Classes, Databases, MySQL, XML
TAB_STRUCT Class: Is supporting Class for the DBXML Class
Categories : PHP, PHP Classes, MySQL, XML, Databases
bookmarker - PHP, PHPLIB, MySQL WWW based bookmark manager
Categories : MySQL, PHP, MySQL, Complete Programs, Databases
Link Manager for Link Exchangers
Categories : PHP, PHP Classes, Databases, MySQL, CURL
Setting up InnoDB on MySQL and using Transactions Begin, Commit, Rollback in PHP.
Categories : PHP Classes, Databases, PHP, MySQL, InnoDB