|
|
|
|
Like this code?
Show the author your appreciation.
|
|
| |
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 | |
|
|
|