|
|
|
|
|
|
| |
| <?
/*
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 | |
|
|
|