Jump to content

any Object-Relational interface between PHP and Mysql?(e.g., PHP code generator)


Recommended Posts

Hi,

I am having a hard time writing SQL queries in PHP.

Well, writing the sql query is not difficult. What makes is difficult is to debug the code in case of even simple errors. This is particularly true in case where multiple tables are involved in nested and join queries. Besides the query itself, iterating over the results to access the fields of retrieved results is a repetitive and boring task which in my opinion can be simply automatized using a code generator.

 

Now I am wondering if there is any PHP code generator capable of generating both the query code and the code to iterate over the retrieved data. PHPMyAdmin generates the query part for PHP which you can copy-paste in your PHP file. But What I mean is more of a object-relational interface between PHP and MySQL.

 

For instance there is CodeSmith that generates code for ASP.NET and MS-SQL. It takes a database connection and for each database simply generates the CRUD (Create, Read, Update, Delete) functions, and some more. I am wondering if such thing exists for PHP and Mysql?

 

Thanks, 

That kind of thing is generally provided by a framework. They're often called "models" (named after the MVC design pattern).

 

Your problem is looking at the results? Output the query you need to test with any dynamic values (eg, ID numbers, names, etc), or use a debugger, and copy/paste the query into phpMyAdmin. Assuming you have the same database, user, and password, you'll get back the same rows there that you would get in PHP.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.