METHOD_CREATE
METHOD_CREATE
リソースメソッド - create(POST, INSERT)
リソースクライアント
リソースの’メソッド’、'URI', 引数(Values)、およびオプションを指定してリソースを操作します。 オプションはキャッシュ、ページング処理、コールバック関数によるポストプロセス、作成時の二重動作禁止のための トークン処理などがあります。 Example. キャッシュの使用
$options['cache']['key'] = 'cacheid_foo'; //省略できます
$options['cache']['life'] = 30;
$resoruce->read($params, $options)->set('user', 'object');
//または
$user = $resoruce->read($params, $options)->getBody();
Example. 二重実行防止にはPOE(Post Once Exactly)オプションを指定します
//二重送信されたものを一度しか実行しない
$options['poe'] = true;
$resource->create($values, $options)->request();
$_ro : \BEAR_Ro_Prototype
リソースオブジェクト
create(array $params) : \BEAR_Ro_Prototype
リソース作成
リソースを作成します。 $params 'uri' string URI 'values' array 引数 'options' array オプション
array | $params | リクエストパラメータ |
read(array $params) : \BEAR_Ro_Prototype
リソース読み込み
リソースを読み込みます。 $params 'uri' string URI 'values' array 引数 'options' array オプション $params['options'] 'cache' 'id' string キャッシュID 'cache' 'life' int キャッシュ時間(秒)
array | $params | 引数 |
update(array $params) : \BEAR_Ro_Prototype
リソース更新
リソースを更新します。
リソースを読み込みます。 $params 'uri' string URI 'values' array 引数 'options' array オプション $params['options'] 'cache' 'id' string キャッシュID 'cache' 'life' int キャッシュ時間(秒)
array | $params | 引数 |
delete(array $params) : \BEAR_Ro_Prototype
リソース削除
リソースを削除します。
$params 'uri' string URI 'values' array 引数 'options' array オプション
array | $params | 引数 |
request(string $method, string $uri, array $values = array(), array $options = array()) : \BEAR_Ro_Prototype
リソース操作
リソースの操作情報を保持するオブジェクト(BEAR_Ro_Prototype)を取得します。 同クラスのcreate(), read(), update(), delete()から呼ばれるリソース操作クラスです。
Example 1.リソース読み込み
$params['uri'] = 'user/profile';
$params['values'] = array('id'=>1);
$resource = BEAR::dependency('BEAR_Resource');
$profileObject = $resource->read($params)->getRo();
$profileValues = $resource->read($params)->getBody();
// objectとしてテンプレートにset
$profileObject = $resource->read($params)->set('profile', 'object');
string | $method | メソッド(create | read | update | delete) |
string | $uri | URI |
array | $values | 引数 |
array | $options | オプション |
_exception(string $msg, array $config = array()) : \BEAR_Exception
例外の作成
string | $msg | 例外メッセージ |
array | $config | 例外config |