Last active
August 29, 2015 14:07
-
-
Save tai-sho/01e2aa45da6b15bedb19 to your computer and use it in GitHub Desktop.
CakePHP2.xでモデルの空配列を作る関数
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
App::uses('Model', 'Model'); | |
class AppModel extends Model { | |
/** | |
* モデルの空配列を返します。 | |
* @return array モデルの空配列 | |
*/ | |
public function getModelArray() { | |
//カラムタイプの配列からキーのみを取得 | |
$keys = array_keys($this->getColumnTypes()); | |
//配列を空文字で埋める | |
$arr[$this->alias] = array_fill_keys($keys,''); | |
return $arr; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment