Interessant lectura:
http://verraes.net/2013/04/crud-is-an-anti-pattern/
http://www.codeofaninja.com/2013/05/crud-with-php-jquery.html
Són les inicials de Create, Retrieve, Update and Delete
BREAD Són les inicials de Browse Read Edit Add and Delete similar a CRUD però afegint la opció listing: Vegeu un exemple:
https://github.com/the-control-group/voyager/blob/4a90a278d196174644ed063525b4b20921e72f6c/src/Http/Controllers/VoyagerBreadController.php
Recursos:
Extret de:
http://verraes.net/2013/04/crud-is-an-anti-pattern/
NOTA: En aquest exemple és veu CRUD com la idea que tot en un model es pot descriure simplement amb els verbs: create, read, update, delete lo que està molt clarament relacionat amb les operations SQL de base de dades. En aquest apart s'utilitza el terme expressiu per aportar un visió alternativa on oferir més verbs com per exemple: pay, hire, promote. La idea és centrar-se en l'usuari i no tant en la base de dades i construir aplicacions que expressin millor el que l'usuari està intentant fer
CRUD thinking:
<?php $order->setStatus('paid'); $order->setPaidAmount(120); $order->setPaidCurrency('EUR'); $order->setCustomer($customer);
Un alternativa ex crear un mètode més expressiu:
<?php $order->pay();
Internament les operacions seran les mateixes. Encara es poden fer més millores (Replace values that belong together with a Value Object)
<?php $money = new Money(120, new Currency('EUR')); $order->setPaidMoney($money);
I podem encapsular la operació:
<?php $order->pay($customer, $money);
Fins i tot podem
<?php $customer->pay($order, $money);
Però aleshores estem acoplant els objectes order i customer però depèn el context pot no ser un gran problema (per exemple amb injecció de dependències es podria gestionar bé aquest coupling)
Vegeu també Laravel command
The acronym CRUD refers to all of the major functions that are implemented in relational database applications. Each letter in the acronym can map to a standard SQL statement and HTTP method:
Operation | SQL | HTTP |
---|---|---|
Create | INSERT | POST |
Read (Retrieve) | SELECT | GET |
Update (Modify) | UPDATE | PUT / PATCH |
Delete (Destroy) | DELETE | DELETE |
Utilitzar tots els mètodes HTTP és el que es considera RESTful.
Tot i que sovint utilitzem una base de dades com a capa de persistència (persistence layer) existeixen altres opcions com object database,XML database, flat text files ...
See Sleeping owl
Consulteu GroceryCrud
Recursos:
http://develoteca.com/5-sistemas-crud-para-mis-aplicaciones-web-jquery-php-javascript-asp/
jQuery EasyUI jTable jqxGrid extJS utilitzat a Proxmox
http://angularjs4u.com/demos/10-angularjs-crud-app-demos/
Resources:
Vegeu ng-admin
Editor is a Create, Read, Update and Delete (CRUD) plug-in for DataTables that provides the ability to easily add, edit and delete rows on a database that is displayed by a DataTable. Editor provides a clean API that allows form creation and manipulation to let the end user modify enter the required data, and a well defined server interaction protocol. This simple example shows a table with five fields, each of which can be edited as plain text.
http://editor.datatables.net/release/DataTables/extras/Editor/examples/index.html
datatables també té el plugin:
http://code.google.com/p/jquery-datatables-editable/
Recursos: