PHP Classes

Code Help: Generate model, view and controller pattern code

Recommend this page to a friend!
  Info   View files View files (8)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStar 58%Total: 4,269 All time: 693 This week: 171Up
Version License Categories
codehelp 1.0FreewareDatabases, Code Generation, Design Pa...
Description Author

This class can generate the code that implements the model, view and controller design pattern.

It can generate a page controller page script and model and view classes to create, edit and display records of data entities that are stored in a database.

The class may also generate an SQL script to create the table definition to store the entity records in a MySQL Database.

Picture of Roberto Martinez
Name: Roberto Martinez <contact>
Classes: 4 packages by
Country: Mexico Mexico
Age: 54
All time rank: 2843 in Mexico Mexico
Week rank: 587 Down10 in Mexico Mexico Down

Details
README codehelp This class helps me with the code for simple pages like catalogs. It uses some restrictions for building de classes in the Page Controller pattern. You have to copy the php code to 1 file and the mysql instruction can be copied to mysql. (check the output.php) Assumptions *********** - It uses an id field autonumeric - It uses a prefix for field name construction - It generate a browse table for search in the field1 (not the id) Files included ************** codehelp.class.php - The class db.php - To open the database header.php - Formatting header footer.php - To close the page sample.php - Simple application output.php - Code you should get from sample.php (output.php can run if it has the database, check db.php) style.css - Style sheet Readme.txt - this file -------------------------------------------------------------------------------- codehelp -------------------------------------------------------------------------------- $name name of the class and controller $db name of the database $prefix for the fieldnames $details (array) for fields in mysql and forms in html -------------------------------------------------------------------------------- codehelp($name) constructor setdb($db, $prefix) assigns database name and a prefix for fieldnames addDetails ($var, $fieldtype, $pk, $display, $vartype ) insert values for var - variable and fieldname, fieldtype - to build sql pk - 1 for primary key 0 for otherwise display - Label for html vartype - no for not editable (usualy for pk), text for input in html generateSQLSchema() outputs the instruction for mysql to create the table generatePageController() outputs the code for the page controller (this is not a class) generateModelClass() outputs the code for the model used by the view generateViewClass() outputs the code for the view used by the page controller Other functions are private -------------------------------------------------------------------------------- The outputed code by the functions (except the schema) can be in one .php file (not so good but less files) and you can add a header/footer.php (included with the package) to do the rest of the job The classes are -------------------------------------------------------------------------------- whateverModel -------------------------------------------------------------------------------- $id $field1 ... ... $field2 -------------------------------------------------------------------------------- Note: you can add a constructor for default inputs. setData() to fill the model select($id) get the record insert() adds new record update() change record result() to be used by the view for browsing -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- whateverView -------------------------------------------------------------------------------- var $model -------------------------------------------------------------------------------- whateverView($model) constructor to add model show() outputs non editable html edit($action) outputs html with inputs for edition action - 1 for update other for insert browse($result) outputs a table with a link for the id -------------------------------------------------------------------------------- Hope you like it Roberto Martinez robermar@yahoo.com
  Files folder image Files  
File Role Description
Plain text file codehelp.class.php Class The class
Accessible without login Plain text file db.php Aux. code to open the database
Accessible without login Plain text file footer.php Aux. footer for sample
Accessible without login Plain text file header.php Aux. header for sample
Accessible without login Plain text file output.php Output Page Controller Result
Accessible without login Plain text file readme.txt Doc. Instructions and considerations
Accessible without login Plain text file sample.php Example To use the class
Accessible without login Plain text file style.css Data Style sheet for sample

 Version Control Unique User Downloads Download Rankings  
 0%
Total:4,269
This week:0
All time:693
This week:171Up
User Ratings User Comments (1)
 All time
Utility:75%StarStarStarStar
Consistency:75%StarStarStarStar
Documentation:67%StarStarStarStar
Examples:67%StarStarStarStar
Tests:-
Videos:-
Overall:58%StarStarStar
Rank:1524
 
Excellent
13 years ago (kishore kumar)
80%StarStarStarStarStar