Sponsored Links

Go Back   WebMasters.org Forums > Website Design & Development > PHP Forum

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-13-2008, 04:41 PM
smartcoderin smartcoderin is offline
Junior Member
 
Join Date: Mar 2008
Posts: 16
Default Simple Mysql Manager

Somebody asked to me to write a simple mysql manager for simple database application.
I have created a simple script here.

<?php



/*
##================================================ =========================================
## Mysql Manager Version 1.0 => Beta Release.
## Mysql Utilities for Web Based application .
## Written By Kiran Krishnan => smart_coder@yahoo.co.in
## Copyright to smartcoderin ->smartcoderin@yahoo.co.in
## Platform Mysql 5.0 or above with PHP 5.0 or above.

## Phase : Development : Started on 31-January - 2008 : Test remain
## Tested on Wamp Server with Mysql 4.2
##================================================ ===========================================
*/

class MysqlManager
{


/*

Global varibaless accessible outside the utility
Rendered for easy access of functionality

*/


var $QueryString; //exec query String //
var $QueryResult; //Resultnat ARray
var $QueryRows; //Num rows
var $QueryError; //QueryErrors //

var $DbUser;
var $DbPass;
var $DbHost;
var $DbCon;
var $DbName;

var $field_count;
var $row_count;

/*

*/


function MysqlManager()
{
//Initializing Mysql Manager //


$this->QueryString = '';
$this->QueryResult = '';
$this->QueryRows = '';
$this->QueryError = '';
$this->DbUser = "root"; //server auth user //
$this->DbPass = ""; //server auth pass //
$this->DbHost = "localhost"; //server address //
$this->DbName = "folklore"; //

$this->field_count = 0;
$this->row_count = 0;

}


//Nothing just displays the error //

function _mysql_error($error)
{
$this->QueryError = $error;
trigger_error("Mysql Manager Said : ".$this->QueryError,E_USER_NOTICE); //call error trigger //
}



//close mysql connection //

function _close_mysql()
{
if(!$this->DbCon)
{
mysql_close($this->DbCon); //closing the mysql server //
}
}



//connect to mysql database //

function _connect_mysql()
{
$this->DbCon = @mysql_connect($this->DbHost,$this->DbUser,$this->DbPass); //Conect Myql Server //
if(!$this->DbCon)
{
$this->_mysql_error(mysql_error());
}
else
{
$this->_select_database();
}
}

//Now select database for the application//


function _select_database()
{
if(empty($this->DbName))
{
$this->_mysql_error("Database Name Empty ");
}
else
{
$db = @mysql_select_db($this->DbName);
if(!$db)
{
$this->_mysql_error("Cannot Find the Database ");
}
}
}

//execute Query section //


function _exec_query($query)
{
$this->QueryString = $query;
$this->QueryResult = @mysql_query($this->QueryString);
if(!$this->QueryResult)
{
//
$this->_mysql_error(mysql_error());
return false;
}
else
{
return true;
}

}

//Get all fields from the table //

function _table_describe($table_name)
{
$this->QueryString = "DESCRIBE `".$table_name."` ";

if($this->_exec_query($this->QueryString))
{
if(mysql_num_rows($this->QueryResult)>0)
{
while($row = mysql_fetch_row($this->QueryResult))
{
$field_name = $row[0];
}
}
}

}


//execute Simple query //

function _simple_query($query,$type)
{
$this->QueryString = $query;

if($this->_exec_query($this->QueryString))
{
if(strtolower($type)=="select")
{
$this->_format_result(); //format the results only for select statement //
}
}
}


//--->format the result set after selection<---- //

function _format_result()
{


$num_fields = mysql_num_fields($this->QueryResult);

if(mysql_num_rows($this->QueryResult)>0)
{
$arr_cnt=0;
while($row=mysql_fetch_row($this->QueryResult))
{

for($i=0;$i<$num_fields;$i++)
{
$field_name = mysql_field_name($this->QueryResult,$i);
$this->row_values[$arr_cnt][$field_name] = remove_slashes($row[$i]);
$this->row_name[$i] = $field_name;
}
$arr_cnt++;
}
}
else
{
$arr_cnt = 0;
}

$this->field_count = $num_fields; //Total fields selected //
$this->row_count = $arr_cnt; //total records found //



}




function _clear_mysql()
{
@mysql_free_result($this->QueryResult);
$this->QueryString="";
unset($this->field_count);
unset($this->row_count);
unset($this->row_name);
unset($this->row_values);
}





}


?>

To download code snippets you can visit

SmartCoderIn => Scripts and tutorials : We give online assistance
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-21-2008, 08:56 AM
chandan123 chandan123 is offline
Junior Member
 
Join Date: Apr 2008
Location: Denied.in
Posts: 10
Default

nice thanks a lot

do u have whois script to store in DB ?
__________________
Chandan- Denied.in - Unidentify.info - Sex4u.co.in - Free BookMarks - IBM Proxy
G Proxy - G Proxy - Indian Proxy - Best Proxy -Magic
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 09-26-2008, 08:17 PM
TheGamerX TheGamerX is offline
Senior Member
 
Join Date: Aug 2008
Posts: 107
Default

What does this script do exactly?
__________________
My favorite kind of Online games are
MMORPG | MMO | Free MMORPG |Free MMO | Games like MapleStory and Warcraft are amazing . MMORPGs are fun because they're social. You interact with more people.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 01:00 PM.


Sponsored Links

Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.0.0
vB Ad Management by =RedTyger=