cakephp2.doc_033
R e i - D r e a m
for Laravel
TOP > CakePHP2 > Controller関連(変数等)
Guest
login

最終投稿日:2019年11月20日

Controller関連(変数等)
CakePHP2.x
定数

    ROOT                        WEBROOT までの絶対パス(/home/xxxxx/cake236)
    WEBROOT_DIR                 WEBROOT(cake236)
    CAKE_CORE_INCLUDE_PATH      ライブラリまでの絶対パス(/home/xxxxx/cake236/lib)


変数

    //Controller 名取得
    $this->name;
    //Action 名取得
    $this->action;

    //View ファイル「.ctp」を変更
    $this->ext = '.html';

    //プレフィックス確認
    $this->request->params['prefix'];
    //GETリクエスト値取得
    $this->request->query["hoge"];
    //POSTリクエスト取得
    $this->request->data["hoge"];
    
    //バリデートエラー取得
    $this->[Model]->validationErrors;
    
    //Layout の変更
    $this->layout = 'hogeLayout';
    //View のレンダリングをしない
    $this->autoRender = false;

関数

    //version を確認
    Configure::version();
    
    // 前のURLをフルパスで取得
    $this->referer();
    // 前のURLを相対URLで取得
    $this->referer(null, true);
    // リファラが取れない場合はeditアクションのURLを返す
    $this->referer(array('controller'=>'users','action'=>'edit'));

    //リダイレクト
    $this->redirect(array("controller"=>"hoge","action"=>"foo"));
    //リダイレクト
    $this->redirect([絶対パス]);


    < Session >
        セッションを使用する場合はコンポーネントとして宣言する

            public $components = array("Session");


        セッションの登録

            $this->Session->write("hoge","foo");
            $this->Session->write(array("hoge"=>"1","foo"=>"2"));

        セッションの読み込み

            $result = $this->Session->read("hoge");

            ※[hoge]が存在しない場合は null を返す

        セッションの削除

            $this->Session->delete("hoge");
            //全てのセッションを削除
            $this->Session->destroy();

        セッションの確認

            //bool が返る
            $this->Session->check("hgoe");
            
レンズモード 【新規購入限定用】
ログインしてコメントを残そう!!


きっぷる
きっぷる