|
|
|
|
|
|
| |
|
#!/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 | |
|
|