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
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
Mobile Dev World

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 : PHP class generator, must be used from Command line interface.
Categories : PHP, PHP Classes, Shell Scripting Click here to Update Your Picture
David Perez
Date : May 05th 2003
Grade : 2 of 5 (graded 8 times)
Viewed : 5169
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 
 

#!/usr/local/bin/php -q -c /usr/local/etc
<?php
// this PHP script must be used from Command line
// the script create a file with a PHP class
// is like a Command Line CASE tool for php
//
//
// Arguments
//# $1 Variables for the Class in a Text file
//# $2 Class name
//# $3 Extends class name. MysqlRecordSet for this sample
//     see example of MysqlRecordSet at
//     LINK1http://examples.weberdev.com/get_example.php3?count=3576LINK1
//# $4 Table name that will host the class data
//# $5 Output file name
//
// step one we Read the file that have the Variables
$campos = file($argv[1]);
$fp = fopen ($argv[5], "a");

// step 2 create the class name
fputs($fp,"<?\n");
fputs($fp,"class ". $argv[2] . " extends " . $argv[3] .  "\n");
fputs($fp," {\n");

// step 3 the Variables where created here
for ($x=0;$x<(sizeof($campos));$x++)
{
 
fputs($fp,"  var \$". trim($campos[$x],"\n") .";\n");
}

// step 4 generate the constructor
fputs($fp," function ". $argv[2] . "()\n");
fputs($fp,"  {\n");
for (
$x=0;$x<(sizeof($campos));$x++)
{
 
fputs($fp,"    \$this->" . trim($campos[$x],"\n") . "=\"\";\n");
}
fputs($fp,"    \$this->" . $argv[3] . "();\n");
fputs($fp,"   }\n");

// End the Constructor
//Funciontions  Add,Del,Query,Update
//see example of MysqlRecordSet at
// LINK2http://examples.weberdev.com/get_example.php3?count=3576LINK2


fputs($fp," function Add(\$dbname,\$cnx)\n");
fputs($fp,"  {\n");
fputs($fp,"    \$sql=\"insert into " . $argv[4] . " values('\" . ");
for (
$x=0;$x<(sizeof($campos)-1);$x++)
{
 
fputs($fp,"\$this->" . trim($campos[$x],"\n") . " . \"','\" . ");
}
fputs($fp,"\$this->" . trim($campos[$x],"\n") . ". \"')\";\n");
fputs($fp,"    \$this->open(\$dbname,\$sql,\$cnx);\n");
fputs($fp,"    \$this->close();\n");
fputs($fp,"   }\n");

fputs($fp," function Del(\$dbname,\$cnx)\n");
fputs($fp,"  {\n");
fputs($fp,"    \$sql=\"delete from " . $argv[4] . " values('\" . ");
for (
$x=0;$x<(sizeof($campos)-1);$x++)
{
 
fputs($fp,"\$this->" . trim($campos[$x],"\n") . " . \"','\" . ");
}
fputs($fp,"\$this->" . trim($campos[$x],"\n") . ". \"')\";\n");
fputs($fp,"    \$this->open(\$dbname,\$sql,\$cnx);\n");
fputs($fp,"    \$this->close();\n");
fputs($fp,"   }\n");
fputs($fp," }\n");
fputs($fp,"?>");
fclose($fp);

//last step we close the file !
//enjoy the class generator
?>



Filter - A simple class that lets you use multiple functions to create custom filters.
Categories : PHP, PHP Classes, Strings
PHP5 SQLite Abstraction class
Categories : PHP, PHP Classes, SQLite, Databases
DbObject - A PHP wrapper for working with various databases
Categories : Databases, PHP, PHP Classes
The Ajax Tree view class fetches data from a db for the requested parent category id. The data is then stored in an array and converted into JSON (Javascript Object Notation) format. This format is then used by JavaScript for populating tree view.
Categories : PHP, PHP Classes, Java Script, AJAX, Databases
Simple class that uses GD to draw pie charts. After the class definition there's some sample code to demonstrate how you use the class.
Categories : Graphics, PHP, PHP Classes, GD image library, Charts and Graphs
Browser Detecor Class
Categories : PHP Classes, PHP, HTML
Building a basic error handler with custom error types
Categories : PHP, PHP Classes, Errors and Logging
Bs_IniHandler is a class that can read and write ini-style files (and strings)
Categories : PHP, Filesystem, PHP Classes
PostGreSQL and MySQL 2 in 1 db Manager
Categories : PHP, PHP Classes, Databases, PostgreSQL, MySQL
[PHP5] aDB PDO LIKE Database Abstraction. Switch easily from one db server to another, strong errors management, manage transactions, queries preparation and more.
Categories : PHP, PHP Classes, Databases, MS SQL Server, MySQL
Customizable Calendar Class
Categories : HTML and PHP, Date Time, PHP, PHP Classes, Calendar
Client classes for Dictionary servers UPDATED: 2000-06-06
Categories : Network, Search, Complete Programs, PHP Classes, PHP
Class that allows the PHP developer to create and manage UNIX like password files suitable for use as Apache authentication password files.
Categories : HTTP, PHP, PHP Classes, Filesystem
filesplit : Split big text files in multiple small ones
Categories : PHP, Log Files, Filesystem, PHP Classes
Vote-Poll script that has a wrapper class that allows the user to create multiple polls on the same page with little trouble.
Categories : PHP, PHP Classes, HTML and PHP