MySQL 和 PHP 的 CRUD

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1148388/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 01:14:15  来源:igfitidea点击:

CRUD for MySQL and PHP

phpmysqlcrud

提问by menardmam

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

我必须在 MySQL 数据库上使用 PHP 发出一些数据库请求。

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

问题:什么是正确完成工作的最佳(最简单)框架 CRUD(创建读取更新删除)?

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.

我还必须填充数据库,有什么好工具可以做到这一点。我知道的唯一一个是 SqlMyAdmin,它看起来不太好。一个在线工具会很棒。

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 ?

我看了一下 CodeIgniter,看起来不错,你觉得怎么样...矫枉过正?

采纳答案by Pascal MARTIN

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

对于许多操作(尤其是 CRUD,一旦您编写了架构文件就可以立即使用),ORM Framework Doctrine真的很棒。

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 ^^ )

如果您想要的不仅仅是 DB 访问,您可以查看 PHP FRamework symfony,它提供了一个管理生成器(甚至还有一个关于该生成器的截屏视频)。(并且有很好的文档,例如jobeet 教程)(顺便说一句,symfony 使用 Doctrine 作为 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".

要将数据加载到 MySQL,那么LOAD DATA INFILE 呢,它(引用自文档)“以非常高的速度将文本文件中的行读取到表中”。

回答by cmc

I recommend GroceryCRUDbecause of the good engineering and documentation

我推荐GroceryCRUD因为它有很好的工程和文档

  1. Copy files into your web folder
  2. Configure MySQL database
  3. Specify MySQL table name
  1. 将文件复制到您的网络文件夹中
  2. 配置 MySQL 数据库
  3. 指定 MySQL 表名

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

=> 你会得到一个带有创建/编辑/删除按钮的分页 JqueryUI 表。

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.

create/edit 打开一个基于 MySQL 表架构的表单页面。例如,一个布尔值、一个 varchar 和一个文本被转换成一个带有活动/非活动单选按钮、一个文本字段和一个所见即所得的 html 编辑器的表单。

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.

注意:GroceryCRUD 是建立在 CodeIgniter 之上的,所以你的管理目录中会有一个副本。您不必使用它来构建您的主站点。

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.

安全建议:任何库都可能存在未被发现的安全漏洞,因此建议通过使用 BaseAuth 保护您的 GroceryCRUD 副本并仅允许 SSL 访问来最大程度地减少暴露。

回答by richsage

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 ;-)

我想第二个 Pascal 对 Symfony 的评论(我会升级但没有足够的信用:-() - Symfony 有一个很棒的管理生成器,一旦你了解了 app->module->actions 概念,它就很简单,而且文档太棒了,即使有时在谷歌搜索它更容易;-)

Failing that, CakePHPis 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 :-)

如果做不到这一点,CakePHP现在比过去要好得多,而且您可以毫不费力地开始工作,尤其是他们的脚手架,这将帮助您设置基本的 CRUD 样式设置。他们的文档也非常棒而且很容易阅读:-)

回答by Cuong

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

为什么不尝试从头开始编写代码,因为 CRUD 是编程的常见任务。有很多不错的教程:

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

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

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

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

回答by Jess Stone

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

我目前正在测试JqG​​rid(一个 Jquery 表库)。

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.

我尝试过Grocery CRUD:看起来不错,但它的 Datatables 主题(具有列过滤能力)不适用于服务器端处理,这就是我放弃它的原因。

回答by appbird

You may have a look at Cygnite Framework

你可以看看Cygnite 框架

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

这是教程 -在 2 分钟内生成 CRUD 应用程序

Worth looking.

值得一看。

回答by jawns317

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:

如果 Doctrine、CAKE、CodeIgniter 等解决方案对于您尝试做的事情来说似乎有点过分,我会推荐我构建的单文件 PHP 脚本,它可以让您在 MySQL 中 CRUD 分层数据:

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

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

回答by Dub Class Dubclass

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.

http://www.notorm.com/这样的东西可能比 Symfony 更合适。虽然我喜欢 Symfony 并使用它取得了很好的效果,但它并不简单。

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

同样,对于 Codeignitor,我认为任何全栈框架(Laravel、Zend、Wii 等)都不适合“简单”的职权范围。

回答by Neo

A fairly straight forward and effortless crud system i found is https://github.com/usmanato360/crud360its very easy to setup and there are loads of advanced features. It is unlike traditional crud systems that generate model classes etc.. it is just a single class that takes care of everything dynamically.

我发现一个相当直接和轻松的 crud 系统是https://github.com/usmanato360/crud360,它非常容易设置,并且有很多高级功能。它与生成模型类等的传统 crud 系统不同。它只是一个动态处理所有事情的单个类。

回答by Ronan Cashell

I developed this scriptwhich 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.

我开发了这个脚本,它从 MySQL 数据库反向工程一组存储过程,列出表的所有行,基于主键的单行,基于主键的更新/插入和基于主键的删除。它假设您已经使用每个表设置的主键创建了表,并为您生成 MySQL 存储过程。我发现这比用 PHP 开发的类似类型的解决方案更有效。