|
|
|
|
|
|
| |
| #!/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
?> | | |
|
| file class , uploade file , download file already uploaded on another website Categories : PHP, PHP Classes, Filesystem, Web Services | | | Authorize.net AIM Interface Class v1.0.0 Categories : PHP, PHP Classes, Ecommerce, Payment Gateways | | | crop and resize image class using gd library function Categories : PHP, PHP Classes, GD image library, Graphics | | | News management class Categories : PHP, PHP Classes, Beginner Guides | | | The class to check load time of your script
VERY usefull for relatively slow applications, but not only.. Categories : PHP, PHP Classes, Debugging | | | Expose - PHP template engine, supports server and client-sided caching,a plugin system, multiple languages, template script language is based on PHP itself. Categories : PHP, PHP Classes, Templates, Complete Programs | | | Simple Template Class/Example Categories : PHP, Templates, PHP Classes | | | RSS parser.
Parses RSS into an array. Quick and nasty but does the job.
No checking is done for correct Tags, only correct XML.
PHP4 needed to display result (uses print_r). Categories : PHP, XML, PHP Classes, Rich Site Summary (RSS) | | | MS Word Mail Merge Automation (COM) Categories : PHP, PHP Classes, COM | | | Very minimal templating engine Categories : PHP, PHP Classes, Templates | | | ElfReader: An ELF (Executable and Linking Format) header information in PHP. Shows how to use the UNPACK function to read data. Categories : PHP, Linux, PHP Classes | | | an example of the cyberlib payment class Categories : PHP, PHP Classes, Ecommerce, Credit Cards | | | pcCalendar class - Allows for the creation of calendars in HTML pages. All output functions can be easily overridden, refer to article 1471 for an example.
Categories : PHP, Date Time, Calendar, PHP Classes | | | Class for sending mail with MIME attachments in multipart format using external sendmail, mimencode and zip Categories : Email, Network, PHP, PHP Classes | | | Powerful php/mysql Pagination for up to 6 URL Params Categories : PHP, PHP Classes, Databases, MySQL, Navigation | |
|
|
|