FilAntunes Posted December 18, 2009 Share Posted December 18, 2009 HI! I'm looking for an application/script that generates PHP code automatically. I want to create classes just for manipulating a MySQL database, i dont need the HTML, i just need the PHP classes for manipulating the database. Class example: require database.php class tableclients { //fields function insert(...) {} function delete(...) {} function update(...) {} function select(...) {} . . . } I have a database with too many tables and a script/application that can create all the classes with data validation is appreciated. Does anyone knows a way to generate all of this code automatically. Thanks Sorry about my english. Quote Link to comment https://forums.phpfreaks.com/topic/185549-php-mysql-oop-code-generator/ Share on other sites More sharing options...
ngreenwood6 Posted December 18, 2009 Share Posted December 18, 2009 I dont know why you would want something to do that for you when it is simple enough to do yourself. Not to mention the fact that you arent going to know if the validation is meeting what you need to validate. I do not know of any software out there that can do this and as far as I know there is no such thing. My suggestion is to write your own classes to manage your database. Quote Link to comment https://forums.phpfreaks.com/topic/185549-php-mysql-oop-code-generator/#findComment-979620 Share on other sites More sharing options...
FilAntunes Posted December 18, 2009 Author Share Posted December 18, 2009 I dont know why you would want something to do that for you when it is simple enough to do yourself. Not to mention the fact that you arent going to know if the validation is meeting what you need to validate. I do not know of any software out there that can do this and as far as I know there is no such thing. My suggestion is to write your own classes to manage your database. I have so many tables. The validation that i'm talking is to validate fields, maxlength, datatype, nulls, and manipulating all errors of database consistency . Quote Link to comment https://forums.phpfreaks.com/topic/185549-php-mysql-oop-code-generator/#findComment-979622 Share on other sites More sharing options...
mikesta707 Posted December 18, 2009 Share Posted December 18, 2009 There are many database classes already made if thats what you are after. Just do a google search for a php database class. As far as a generator, I don't know if they exist, and a generator that just makes 1 class seems kind of pointless to make anyways. Quote Link to comment https://forums.phpfreaks.com/topic/185549-php-mysql-oop-code-generator/#findComment-979624 Share on other sites More sharing options...
trq Posted December 18, 2009 Share Posted December 18, 2009 Sounds like your looking for an Orm of sorts. Take a look at http://www.doctrine-project.org Quote Link to comment https://forums.phpfreaks.com/topic/185549-php-mysql-oop-code-generator/#findComment-979626 Share on other sites More sharing options...
ngreenwood6 Posted December 18, 2009 Share Posted December 18, 2009 ok so why dont you just create a class yourself? imagine if programmer out there just tried to have something done for them automatically. we would have NO good programmers. every programmer out there that i know has gone through some tedious work to validate fields. you could make a simple database class that you could pass values to to check. <?php class db{ function __construc(){ mysql_connect('host','user','pass'); mysql_select_db('db'); } function validate($array){ switch($array[0]){ case 'integer': if(is_numeric($array[1])) return true; case 'email': return eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $array[1]); } } } //making use of the class $db = new db(); //initialize a number $number = 23; //check that it is a number $error = $db->validate(array('integer',$number)); //check the error if($error == true){ echo 'there was an error'; } else { echo 'your good to go'; } See how easy that was and you could just extend that validate method or create one for each type of validation you needed. Then you could also create methods in that class for inserting and updating data. Quote Link to comment https://forums.phpfreaks.com/topic/185549-php-mysql-oop-code-generator/#findComment-979630 Share on other sites More sharing options...
FilAntunes Posted December 18, 2009 Author Share Posted December 18, 2009 Sounds like your looking for an Orm of sorts. Take a look at http://www.doctrine-project.org Thanks, I think it does what I need. It does much more of what I need. Requires time to understand how it works. I will explore it. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/185549-php-mysql-oop-code-generator/#findComment-979657 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.