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 : 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 : 5898
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  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
?>



Search and Replace Text : Searches Files for Specified Text and Replaces It by a Given Text
Categories : PHP, PHP Classes, Search, Filesystem
Class: Info on Users, Servers and the running script
Categories : PHP, Classes and Objects, User Interface, PHP Classes
Timer - a class that uses microtime() to provide easy calculation of elapsed times
Categories : Algorithms, PHP, PHP Classes
Returns Yahoo! Address Book and Messenger List as an Array
Categories : PHP, PHP Classes, CURL
a class for doing payments to a cybercash server
Categories : Ecommerce, Complete Programs, PHP Classes, PHP
PHP Image Class
Categories : PHP, PHP Classes, Multimedia, GD image library
Create HTML forms dynamicly using Javascript & PHP
Categories : PHP, PHP Classes, Java Script
Open and Close your website in fixed times .
Categories : PHP, PHP Classes, Cron, Date Time
Simple Template Class/Example
Categories : PHP, Templates, PHP Classes
Greatest Common Denominator - A simple class that finds the greatest common denominator for two integers.
Categories : PHP, PHP Classes, Math.
Object() = Custom __autoload + Singleton. "automagically" instantiates a class and always retuns the same instance of the same class. It's pretty useful when you want to have persistence in objects.
Categories : PHP, PHP Classes, Algorithms
MySQL Class to ease Database connectivity
Categories : MySQL, PHP Classes, Databases, PHP
Database and Recordset classes fo SyBASE Usage is obvious.
Categories : Sybase, Databases, PHP Classes, PHP
Aspect-Oriented Programming Library fo PHP
Categories : PHP, PHP Classes, Aspect Oriented Programming
Password Creator: This PHP code exmaple shows how to use bitwise operations on a single variable and using it as a flagged variable. The class generates passwords of a given length using specified characters and the flags.
Categories : PHP, PHP Classes, Algorithms, Security