Link to home
Start Free TrialLog in
Avatar of yarekGmail
yarekGmail

asked on

php code generator

Hello experts,
It is the Nth time I have to write versyy similar code to update/edit/remove records from tables using php/phpmyadmin/mysql.

My tables has some 1toMany relations and manyToMany relations
(like users, books , userbooks tables)

Is there a generator for these kind of things ? How could I speed up this "boring" and "repetitive" task ?

reagrds
Avatar of nanharbison
nanharbison
Flag of United States of America image

You can do this in PHPMyAdmin, which then provides the code that you can copy and paste if you need to use it for multiple records.
Avatar of rinfo
rinfo

Have you considered writting a databasehelper class used in say dotnet.
There helper basically are class that returns say a datatable, or datareader when parameters are set for query ,params, connection.
Something like  datatable dt = GetDatatable(qry);
Getdatatable in defined in a class which uses default connection and return a datatable.
The above example can be extended to include storeproc, params etc.
Think about this if you are a good php programmer i am sure you can write such a class in php after all this iis how config.php is prevelent in php
Just thought of this, find a database class where you just plug in a few things, like this one:
http://www.micahcarrick.com/php-mysql-database-class.html
ASKER CERTIFIED SOLUTION
Avatar of nanharbison
nanharbison
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Sounds like you should be using a framework like cakephp or yii.
Personally I use cakephp which has a very handy shell script called BAKE for baking all my CRUD functionality. The nice thing about cakephp as opposed to a code generator like phpmaker is that the code is very easy to work with after it has been generated, especially if you take the time to really learn the framework.
Perhaps you could use some kind of "pre-canned" functions.  I usually write a "row_getter" and a "row_putter" for my tables.  These are kept in a common script and I can call the methods from any place in my programming that makes sense.