CRUD for MySQL and PHP [closed]

Posted on

CRUD for MySQL and PHP [closed] – Here in this article, we will share some of the most common and frequently asked about PHP problem in programming with detailed answers and code samples. There’s nothing quite so frustrating as being faced with PHP errors and being unable to figure out what is preventing your website from functioning as it should like php and mysql . If you have an existing PHP-based website or application that is experiencing performance issues, let’s get thinking about CRUD for MySQL and PHP [closed].

I have to make some database requests with PHP on a MySQL database.

Question : What is the best (simpliest) framework to get thing done right CRUD (Create Read Update Delete)?

I also have to populate the database, what is a good tool to do that. The only one I know is SqlMyAdmin, wich does not look good. An online tool would be great.

Your experience is valuable: tell me what do you use and why ?


I have taken a look at CodeIgniter, looks nice, what do you think… overkill ?

Solution :

For lots of operations (especially CRUD, which work out of the box once you’ve written the schema files), the ORM Framework Doctrine is really great.

If you want to go farther than just DB access, you might take a look at the PHP FRamework symfony, which provides an admin generator (there is even a screencast about that one).
(And has great documentation, such as the jobeet tutorial)
(BTW, symfony uses Doctrine as ORM ^^ )

But maybe it’s a bit overkill (and requires a too big learning curve) if you need something simple…

To load data to MySQL, what about LOAD DATA INFILE, which (quote from the docs) “reads rows from a text file into a table at a very high speed”.

I recommend GroceryCRUD because of the good engineering and documentation

  1. Copy files into your web folder
  2. Configure MySQL database
  3. Specify MySQL table name

=> You get a paginated JqueryUI table with create/edit/delete buttons.

create/edit opens a form page based on the MySQL table schema. For example, a boolean, a varchar and a text get turned into a form with active/inactive radio buttons, a text field and a wysiwyg html editor.

Note: GroceryCRUD is built on CodeIgniter so you will have a copy living in your admin directory. You don’t have to use it for building your main site.

Security Advisory: Any library can have undiscovered security vulnerabilities, so it is recommended to minimize exposure by protecting your copy of GroceryCRUD with BaseAuth and permitting SSL access only.

I’d second Pascal’s comment re Symfony (I would uprate but not enough credit :-() – Symfony has a great admin generator, and once you get your head around the app->module->actions concept, it’s straightforward and the documentation is fantastic, even if it is sometimes easier to search Google for it πŸ˜‰

Failing that, CakePHP is a lot better now than it used to be back in the early days, and you can get going with the minimum of fuss, particularly with their scaffolding which will help you set up a basic CRUD-style setup. Their documentation is also pretty awesome and very easy to read πŸ™‚

If solutions such as Doctrine, CAKE, CodeIgniter, etc. seem like overkill for what you’re trying to do, I’d recommend a one-file PHP script I built that lets you CRUD hierarchical data in MySQL:

http://coding.pressbin.com/109/PHP-One-file-CRUD-front-end-for-hierarchical-MySQL-data/

Why do not you try to code it from scratch as CRUD is a common task of programming.
There are lots of good tutorials:

1>PHP PDO + Bootstrap Twitter: http://www.lizardgrid.com/blog/php-crud-tutorial-part-1/

2>JQuery + PHP: http://www.codeofaninja.com/2013/05/crud-with-php-jquery.html

I am currently testing JqGrid (a Jquery Table Library).

I have tried Grocery CRUD: looks nice, but its Datatables theme (which has column filtering ability) won’t work with server-side processing, that’s why I dropped it.

You may have a look at Cygnite Framework

It does basic code generation. Controller, model, views, layout, pagination, form component, required field validation, with bootstrap template etc. all these generate with simple command. You may alter the code based on your need.

Here is the tutorial- Generate CRUD application within 2 Min

Worth looking.

I’d say that totally depends on what you need to do.

You do know phpMyAdmin, right? You can import from a lot of formats with that tool.

Or do you want to develop an application with simple CRUD operations? Then a framework like Symfony or Zend Framework would be the right thing to be looking for.

I developed this script which reverse engineers from a MySQL database a set of stored procedures that list all the rows of a table, a single row based on the primary key, updates/inserts based on the primary key and deletes based on the primary key. It assumes that you already have your tables created with the primary keys setup per table and it generates the MySQL stored procedures for you. I have found that this is more efficient than similar types of solutions developed in PHP.

Something like http://www.notorm.com/ might be more appropriate than Symfony. Whilst I like Symfony and have used it to great effect, it is not simple.

Likewise with Codeignitor I would argue that any full stack framework (Laravel, Zend, Wii etc . . ) would not fit the remit of “simple”.

Leave a Reply

Your email address will not be published. Required fields are marked *