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
Submit Site
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 : 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 : 3708
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 
 



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
Powerful php/mysql Pagination for up to 6 URL Params
Categories : PHP, PHP Classes, Databases, MySQL, Navigation
Password reminder
Categories : PHP, PHP Classes, Databases, MySQL, Mail
MySQL Class to ease Database connectivity
Categories : MySQL, PHP Classes, Databases, PHP
usercounter class
Categories : PHP, PHP Classes, Databases, MySQL, Environment Variables
Simple Mini Poll class library (SimPoll)
Categories : PHP, PHP Classes, Databases, MySQL, Complete Programs
MySQL Handler
Categories : PHP, Databases, MySQL, Classes and Objects, PHP Classes
PostGreSQL and MySQL 2 in 1 db Manager
Categories : PHP, PHP Classes, Databases, PostgreSQL, MySQL
Simple database class
Categories : PHP, PHP Classes, MySQL, Databases
Simple usersOnline class - keep track of how many users are online on your site
Categories : PHP, PHP Classes, Databases, MySQL
Online Automatic Class Generator for MySQL Tables
Categories : PHP, PHP Classes, Classes and Objects, Databases, MySQL
Specify your connection settings and create a link to a MySQL database.
Categories : PHP, PHP Classes, Databases, MySQL, Beginner Guides
Setting up InnoDB on MySQL and using Transactions Begin, Commit, Rollback in PHP.
Categories : PHP Classes, Databases, PHP, MySQL, InnoDB
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