WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
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 Resources
Web Development Content
Internet Security Software
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
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

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 : TAB_STRUCT Class: Is supporting Class for the DBXML Class
Categories : PHP, PHP Classes, MySQL, XML, Databases Click here to Update Your Picture
Vivek Ramnath
Date : Aug 05th 2004
Grade : 3 of 5 (graded 4 times)
Viewed : 6556
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Vivek Ramnath
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 



This is the supporting class that retrieves the tables views and creates the backup of the views .
This is an extension of the DBXML Class .
U will need this class to work with DBXML properly.
Any bugs or class design issuez in this class please mail "TAB_STRUCT : Bug Mail " in the subject line.
Any bugs or class design issuez in DBXML please mail "DBXML : Bug Mail " in the subject line.

if anybody have any job oppz for PHP or want support please feel free to contact me.It wuld b of great help.

NOTE: Be careful about the " '.A single change will cause problem in viewing the XML file.

The next class is coming for generation DTDs customised ones!!!
Thank you for the support

<?php
class TAB_STRUCT
{

function
xml_tbl_create($tbl
{
 
$creat="";
 
$sql = "SHOW CREATE TABLE ".$tbl."";
 
$res = mysql_query($sql) or die(mysql_error());
 
$creat="<create_table value=\"".$tbl."\">";
  while (
$row = mysql_fetch_assoc($res))
   {
       
$creat=$creat.$row["Create Table"]."</create_table>";
   }

  return
$creat;
}

function
tbl_struct_xml($db,$tbl,$fnme)
{
 
$tt="";
 
mysql_select_db($db) or die("Could not select database");
 
$fnme=$fnme.$tbl."_STRUCT.xml";
 
$sql = "DESC ".$db.".".$tbl."";
 
$res = mysql_query($sql) or die(mysql_error());
 
$ft=fopen($fnme,"w");
 
$tt="<?xml version=\"1.0\"?".">"."<xml><".$db."><".$tbl."_struct>".TAB_STRUCT::xml_tbl_create($tbl).TAB_STRUCT::gen_insert($db,$tbl);
while (
$row = mysql_fetch_assoc($res))
  {

$tt=$tt."<field_start><name>".$row["Field"]."</name><type>".$row["Type"]."</type><is_null>".$row["Null"]."</is_null><is_key>".$row["Key"]."</is_key><default_value>".$row["Default"]."</default_value></field_start>";
   
   }
   
$tt=$tt."</".$tbl."_struct></".$db."></xml>";
 
$bw=fwrite($ft,$tt);
 
$d=fclose($ft);
  Return
$d;
}
function
show_db_status($db)
{
$stat="";
$fnme="C:\\".$db."_status.xml";
$sql="SHOW TABLE STATUS";
mysql_select_db($db) or die("Could not select database");
$t_stat= mysql_query($sql) or die(mysql_error());
$ft=fopen($fnme,"w");
$stat="<?xml version=\"1.0\"?".">"."<xml><".$db.">";

while (
$row = mysql_fetch_assoc($t_stat))
{
$stat=$stat."<table><name>".$row"Name"]."</name><records>".$row["Rows"]."</records><row_format>".$row["Row_format"]."</row_format><type>".$row["Type"]."</type></table>";
  }
 
$stat=$stat."</".$db."></xml>";
 
$bw=fwrite($ft,$stat);
 
$d=fclose($ft);
  Return
$d;

  }
function
gen_insert($db,$tbl)
{
 
$fd = mysql_list_fields($db,$tbl);
 
$col = mysql_num_fields($fd);
$ins="<insert_prototype value=\"".$tbl."\">INSERT INTO ".$tbl." ( ";
 
$ins=$ins.mysql_field_name($fd,0);
for (
$i = 1; $i < $col; $i++)
{
$ins=$ins." , ".mysql_field_name($fd, $i);
}
$ins=$ins.") VALUES(";
for (
$i = 0; $i < $col; $i++)
{
 
$k=mysql_field_type($fd,$i);
  switch(
$k)
   {
        case
"int"     :      $ins=$ins." , ";
                              break;
        case
"real"    :      $ins=$ins."0.00, ";
                              break;
              case
"float"   :      $ins=$ins." 0.0, ";
                                   break;             
        case
"varchar(100)" :      $ins=$ins."\'vchr100\',";
                              break;
            case
"varchar(50)" :      $ins=$ins."\'vchr50\' ,";
                              break;
        case
"char"    :      $ins=$ins.",";
                              break;
        case
"blob"    :      $ins=$ins."'blob',";
                              break;
        case
"string"  :      $ins=$ins."'',";
                              break;
         default  :     
$ins=$ins.",";
                              break;   
    }
}

   
$ins=$ins.")</insert_prototype>";
        return
$ins;
}
}
?>



DBXML- A Class to backup databases in XML Format using web interface
Categories : PHP, PHP Classes, Databases, MySQL, XML
MySQL database class
Categories : PHP, MySQL, Databases, PHP Classes
Ajax PHP Tree (Left and Right) with MySQL
Categories : PHP, Databases, MySQL, AJAX, PHP Classes
YellowPages Content Grabber (PHP5 +)
Categories : PHP, PHP Classes, Regexps, Databases, MySQL
This program allows you to upload an ODBC ressource - i.e. an MS-Access database to a MySQL server.
Categories : Databases, MySQL, Complete Programs, PHP, Databases
Setting up InnoDB on MySQL and using Transactions Begin, Commit, Rollback in PHP.
Categories : PHP Classes, Databases, PHP, MySQL, InnoDB
PHP Transfer data from text file to Mysql Table
Categories : PHP, PHP Classes, Filesystem, Databases, MySQL
Sort the results from a SELECT query (any number of columns) into an array automatically.
Categories : PHP, PHP Classes, Arrays, Databases, MySQL
Simple database class
Categories : PHP, PHP Classes, MySQL, Databases
usercounter class
Categories : PHP, PHP Classes, Databases, MySQL, Environment Variables
Link Manager for Link Exchangers
Categories : PHP, PHP Classes, Databases, MySQL, CURL
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
Convert SQL from oracle,mysql,mssql,sqlite and odbc to SQL compatible
Categories : PHP, PHP Classes, Databases, MySQL, MS SQL Server
Simple Mini Poll class library (SimPoll)
Categories : PHP, PHP Classes, Databases, MySQL, Complete Programs
Powerful php/mysql Pagination for up to 6 URL Params
Categories : PHP, PHP Classes, Databases, MySQL, Navigation