nvd_ai Posted December 29, 2010 Share Posted December 29, 2010 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, Quote Link to comment https://forums.phpfreaks.com/topic/222867-any-object-relational-interface-between-php-and-mysqleg-php-code-generator/ Share on other sites More sharing options...
requinix Posted December 29, 2010 Share Posted December 29, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/222867-any-object-relational-interface-between-php-and-mysqleg-php-code-generator/#findComment-1152409 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.