Discussion on DB to PHP class generator


dhavalpandya does not currently provide support for this item.

12 comments found.

Could you please tell me if this utility creates a PHP file that bridges between 2 individual PHP files? I need a registration/sign up utility to insert its username and password field data to a separate login PHP file utility. Please explain? If you are capable of what I asking for, I would love to hire you to help with this project if this is not the utility for this sort of thing. I’m new to PHP .

I am simply trying to avoid double logins for the enduser.


Could you please explain how can we select all records from the database?

Is there a way to loop through all records?


Hi Gejadze,

We can fetch all the tables from the database and then loop through all the returned records to get the table names.

I hope I address your queries. feel free to clarify your queries if any.

Thanks, Dhaval

Hi robanderson,

This utility automatically creates PHP class from your database tables, it generates getter and setter methods for each fields, insert, updates and delete methods for your database tables.

however your requirement is somewhat different from this utility, I can fulfill your requirement by developing a new utility.

My understanding regarding your requirement is something like, you want utility that can get the user data from one database table and you want to utilize that data somewhere else. please correct me if I am wrong.

I would require further information from you to implement utility, please get in touch with me if you want to develop the utility,

Thanks, Dhaval

Can you add a feature which allows you to choose which database on the server you want to create classes for?

For example we enter the root mysql info and then select the database we want instead of defining it?



this is what I meant: in generator.php

function num_rows($id = ’*’){
$sql \”SELECT $id FROM $table\”;
$result $thisdbquery;
$”.”num_rows = mysql_num_rows($result1);
return $”.”num_rows;

function select_all($”.”limit = ’’) {
$sql \”SELECT * FROM $table \”.$”.”limit.\” \”;
$result $thisdbquery;
$”.”output = array();
while ($”.”row = mysql_fetch_assoc($result1)){
$”.”output[] = $”.”row;
return $”.”output;


$test = new test();
$total = $test->num_rows();
$db_array = $test->select_all();
foreach($db_array as $key => $row){
echo $row[‘column1’].” – ”. $row[‘column2’].”\n”;
echo “Total”.$total.” Records Found”;

Thanks Gejadze,

I will update the code to add method that select and return all records from the table. if you need updated code, please let me know.

Regards, Dhaval

Can you please provide usage example? I don’t understand how to use these functions that were created in the class?


You can use the generated class by just creating object of the class and call the methods through the object. Like,
$usrObj = new $user(); //creates object of the class
$id = 1; // set the value of the record that you want
$userInfor = $usrObj->select($id); //fetch and return information of
the user record

in this way you can call other methods too,

let me know if you still need further help,

Regards, Dhaval

doesn’t seem to work for php > 5.3

ereg is deprecated

can u fix this

Hi nandananushil1,

Kindly change to permission of “generated_classes” folder to 0777 using following command

chmod 0777 ./generated_classes/

once rights to generate file on the folder is given, you can create your class from table.

Let me know if I can help you out further.

Thanks, Dhaval

hello, nice script. is there any full example which you can provide , your generate classes. as we have to see what is the classes standard , for a particular table.

i thinks this script is similar to this these two screen to screen shot is 100% similar but developer is different.

he is a thief stealing peoples free scripts and the selling it here .. he should be reported to evanto and banned ..

Hi I need to create a table from my wordpress that automatically update an contains this information: post tittle / autor / custom field / last comment / date / time / then display on a custom page is that posible with this…thank you