0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【CakePHP】ModelのbeforeSave()では引数を指定する(備忘録)

Posted at

beforeSave()では引数を指定しよう

ModelのbeforeSave()でpasswordの暗号化とか、よくやりますよね。

User.php
    public function beforeSave(){
        /* 処理 */
        return true;
    }

そしたらこんなエラーが。

Strict (2048): Declaration of MODEL::beforeSave() should be compatible with Model::beforeSave($options = Array)[APP/Model/User.php, line 4]

$options = array()
を引数に指定してあげるとエラー直ります。

User.php
    public function beforeSave($options = array()){
        /* 処理 */
        return true;
    }

はい備忘録。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?