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 : Online Automatic Class Generator for MySQL Tables
Categories : PHP, PHP Classes, Classes and Objects, Databases, MySQL Click here to Update Your Picture
David Perez
Date : Apr 14th 2005
Grade : 4 of 5 (graded 4 times)
Viewed : 7733
File : No file for this code example.
Images : No Images for this code example.
Search : More code by David Perez
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

<?
/*
this sample uses the classes described in the sample LINK1http://www.weberdev.com/get_example-3576.htmlLINK1.
*/
?>
<html>
<head>
<title>NDH AphpCCG v 0.2 by dperez</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><style type="text/css">
<!--
body,td,th {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
}
-->
</style></head>
<body>
<?
// Automatic PHP Class Code Generator v 0.2
// dependency: clases.php,v 1.0
include("inc/clases.php");//http://www.weberdev.com/get_example-3576.html
$db_host="dbServer";
$db_data="dataBase";
$db_pass="password";
$db_login="user";
// Creating a new conection to the database
$cnx = new MysqlCnx;
$cnx->host = $db_host;
$cnx->user = $db_login;
$cnx->pass = $db_pass;
$cnx->open();
// Crating a new recordset for extract table list
$rst = new MysqlRecordSet;
$rst->cnx = $cnx->cnx;
$rst->dbname = $db_data;
$rst->sql = "show tables";
$rst->open();
$rst->moveFirst();
while(
$rst->EOF!=true)
{
//Build the tables list
 
if ($rst->datos[0]!="")
   {
    echo
"Tabla <a href=\"" . $PHPSELF . "?tabla=" . $rst->datos[0] . "\">" . $rst->datos[0] . "</a><br>";
    }
 
$rst->moveNext();
}
$rst->close();
if (isset(
$_GET['tabla']) && ($_GET['tabla']!=""))
{
// if table is selected we construct the code for a PHP
//class using the fields for selected table
     
echo "Campos de la Tabla " . $_GET['tabla'] . "<br>";
 
$rst->sql = "describe " . $_GET['tabla'];
       
$rst->open();
       
$rst->moveFirst();
        echo
"<br>";
        echo
"class " $_GET['tabla'] . " extends MysqlRecordSet<br>";
        echo
"{<br>";
        while(
$rst->EOF!=true)
         {
          if (
$rst->datos[0]!="")
          {
           echo
"  var \$" . $rst->datos[0] . ";<br>";
          }
         
$rst->moveNext();
         }
       
$rst->moveFirst();
  echo
"<br>function " . $_GET['tabla'] . "()<br>";
        echo
" {<br>";
        while(
$rst->EOF!=true)
         {
          if (
$rst->datos[0]!="")
          {
           echo
"   \$this->" . $rst->datos[0] . "=\"\";<br>";
          }
         
$rst->moveNext();
         }
            echo
"   \$this->MysqlRecordSet();<br>";
            echo
" }<br>";
       
$rst->moveFirst();
  echo
"<br>function Add()<br>";
        echo
" {<br>";
        echo
"   \$this->sql =\" insert into " . $_GET['tabla'] . " values ('";
        while(
$rst->EOF!=true)
         {
            if (
$rst->posicion==($rst->numFil-1))
             {
                  echo
"\" . \$this->" . $rst->datos[0] . " . \"')\";<br>";
                }
         elseif (
$rst->datos[0]!="")
          {
           echo
"\" . \$this->" . $rst->datos[0] . " . \" ','";
          }
         
$rst->moveNext();
         }
            echo
"   \$this->open();<br>";
            echo
"   \$this->close();<br>";
            echo
" }<br>";
       
$rst->moveFirst();
  echo
"<br>function Update()<br>";
        echo
" {<br>";
        echo
"   \$this->sql =\" update " . $_GET['tabla'] . " set ";
        while(
$rst->EOF!=true)
         {
            if (
$rst->posicion==($rst->numFil-1))
             {
                  echo
$rst->datos[0] . "='\" . \$this->" . $rst->datos[0] . " . \"' ";
                }
         elseif (
$rst->datos[0]!="")
          {
           echo
$rst->datos[0] . "='\" . \$this->" . $rst->datos[0] . " . \" ', ";
          }
         
$rst->moveNext();
         }
       
$rst->moveFirst();
        echo
" where " . $rst->datos[0] . "='\" . \$this->" . $rst->datos[0] . " . \"'\";<br>";
        echo
"   \$this->open();<br>";
        echo
"   \$this->close();<br>";
        echo
" }<br>";
  echo
"<br>function Query()<br>";
        echo
" {<br>";
        echo
"   \$this->sql =\" select * from " . $_GET['tabla'] . " where " . $rst->datos[0] . "='\" . \$this->" . $rst->datos[0] . " . \"'\";<br>";
        echo
"   \$this->open();<br>";
        echo
"   \$this->moveFirst();<br>";
 
$i = 0;
        while(
$rst->EOF!=true)
         {
          if (
$rst->datos[0]!="")
          {
           echo
"   \$this->" . $rst->datos[0] . "= \$this->datos[" . $i . "];<br>";
             
$i++;
          }
         
$rst->moveNext();
         }
            echo
"   \$this->close();<br>";           
            echo
" }<br>";
            echo
"}// End class generated by AphpCCG v 0.2 dperez <br>";
}
?>
</body>
</html>
<?
// You can add your owns template for the class
// and save a lot of programing time like i do!
// Enjoy it

$cnx->close();
// Any Comment are Welcome
?>



MySQL Handler
Categories : PHP, Databases, MySQL, Classes and Objects, PHP Classes
Powerful php/mysql Pagination for up to 6 URL Params
Categories : PHP, PHP Classes, Databases, MySQL, Navigation
PostGreSQL and MySQL 2 in 1 db Manager
Categories : PHP, PHP Classes, Databases, PostgreSQL, MySQL
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
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
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
Convert SQL from oracle,mysql,mssql,sqlite and odbc to SQL compatible
Categories : PHP, PHP Classes, Databases, MySQL, MS SQL Server
MySQL Connection/Query Class
Categories : Databases, MySQL, PHP, PHP Classes