Бърз начин за настройка на CRUD с Code Igniter?

Чудя се дали Code Igniter има нещо еквивалентно на малка рамка, която създадох, и как може да се нарече. Създадох малка рамка, която създава изглед на списък и изглед за редактиране за всяка таблица на mysql база данни. По-долу е показан примерен код за това как мога да настроя CMS за манипулиране на таблица от база данни:

// CODE FOR LIST VIEW - http://mysite.com/admin/user.php
// This code will output an html table of records from db table t_user.
// The html table will have controls that allow user to search, delete, and paginate
// You can click on each record to edit the record
<?php
include('class/framework.php');
$template = new ListView();
$template->data_object = new DB($mysql_table_name = 't_user');
$template->setCol($col = 'user_name', $label = 'User Name');
$template->setCol($col = 'email', $label = 'Email'); 
$template->setCol($col = 'last_login', $label = 'Last Time Logged In', $format='Y-m-d H:i:s');
$tempate->run();
?>

// CODE FOR EDIT VIEW - http://mysite.com/admin/user.edit.php
// This code will output an html form that adds, edits, deletes
// and validates a record from t_user
<?php
include('class/framework.php');
$template = new EditView();
$template->data_object = new DB($mysql_table_name = 't_user'):

$f = new Field($col = 'user_id', $type = 'hidden');
$template->field[] = $f;

$f = new Field($col = 'email', $type = 'text');
$f->arr_validate = array('is_email', 'is_required');
$template->field[] = $f;

$f = new Field($col = 'phone', $type = 'text');
$f->arr_validate = array('is_phone', 'is_required');
$template->field[] = $f;

$f = new Field($col = 'password', $type = 'password');
$template->field[] = $f;

$f = new Field($col = 'bio', $type = 'wysiwyg');
$template->field[] = $f;

$f = new Field($col = 'pic', $type = 'image');
$template->field[] = $f;


$template->run();
?>

И това е... не е нужно да пиша нито един ред html, css или javascript код. Цялото валидиране се извършва за мен, докато попълня $f->arr_validate. Възможността за търсене, сортиране, пагиниране, редактиране, изтриване и т.н... се прави само с кода по-горе.

Има ли нещо в Code Igniter, което постига нещо подобно? Ако няма такова нещо извън кутията, просто го кажете.


person John    schedule 31.10.2011    source източник


Отговори (2)


Това, което търсите, е известно като CRUD, за разлика от CMS.

C - Създаване R - Четене U - Актуализиране D - Изтриване

Горещо препоръчвам Grocery Crud за тази цел. Страхотен е и много лесен за настройка. Включва функциите, които търсите, като пагинация и търсене и др.

person Ben Swinburne    schedule 01.11.2011

Най-популярната CI CMS (поне доколкото знам) е PyroCMS

person Louis    schedule 31.10.2011