UrlsでCRUD

revision 2577

Urlsを使った一番単純なCRUDの作り方。
デフォのtemplateを使うので、それぞれURL直打ち

project.xml

<project rhacover="1.4.1" version="1.0.0" name="sample" xmlns="http://rhaco.org" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://rhaco.org http://media.rhaco.org/project.xsd">
	<database name="sample">
		<table name="products" class="product" admin="true">
			<column name="id" />
			<column name="name" />
		</table>
	</database>
</project>


index.php
<?php
include("__init__.php");
Rhaco::import("generic.Urls");
Rhaco::import("model.Product");

$redirect = Rhaco::url("index.php/read");
$object = new Product();

$parser = Urls::parser(array(
			"^create"=>array("method"=>"create","args"=>array($object,$redirect)),
			"^read"=>array("method"=>"read","args"=>$object),
			"^update/([\d]+)"=>array("method"=>"update","args"=>array($object,$redirect)),
			"^delete/([\d]+)"=>array("method"=>"drop","args"=>array($object,$redirect)),
			"^detail/([\d]+)"=>array("method"=>"detail","args"=>$object),
			));
$parser->write();
?>



Create: 〜/index.php/create
Read: 〜/index.php/read
Update: 〜/index.php/update/1
Delete: 〜/index.php/delete/1


1 Responses

  1. Kuboon Says:
    2008/02/01 02:56:06

    アプリパス/resources/templates/generic/テーブル名_form.html を置いておくと読んでくれますね!便利!

Leave a Reply



Commented

なんか新鮮だったから答えてみる。

> http://twitter.com/hwittern/status/1795240927

1,sesion_startはどんな時に使う?

PHPのどこがダメ?

> http://okyuu.com/ja/question/6067

キリ番

http://d.hatena.ne.jp/flashingwind/20090417

キリ番ゲット掲示板とかもあったなー。

WEBシステムは

データの out in out

いや、なんとなく。

conveyorが

> http://wassr.jp/user/yuco/statuses/DGqs3mNzhE

conveyorがよく動かないのは使用の敷居を(ry