本文整理匯總了PHP中Program::validate方法的典型用法代碼示例。如果您正苦於以下問題:PHP Program::validate方法的具體用法?PHP Program::validate怎麽用?PHP Program::validate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Program
的用法示例。
在下文中一共展示了Program::validate方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: actionInsertProgram
public function actionInsertProgram()
{
Yii::app()->user->returnUrl = Yii::app()->request->urlReferrer;
if ($_POST) {
// $cek = DatabaseUmum::cekExist("program","nama_program",$_POST['namaTP']); // cek menggunakan component DatabaseUmum
$cek = DatabaseUmum::cekExist2('program', 'nama_program', 'tahun_anggaran', $_POST['namaTP'], $_POST['tahunTP']);
if ($cek <= 0) {
$program = new Program();
$program->nama_program = $_POST['namaTP'];
$program->kode_program = $_POST['kodeTP'];
$program->target = $_POST['targetTP'];
$program->tahun_anggaran = $_POST['tahunTP'];
$program->id_rekaman = 0;
if ($program->validate()) {
$program->save();
// echo $program->nama_program;
$this->redirect(array('index'));
} else {
Yii::app()->user->setFlash('error', 'Maaf, simpan Program gagal. Mohon periksa kembali data yang anda inputkan');
$this->redirect(array('/errPage/errDB'));
}
} else {
Yii::app()->user->setFlash('error', 'Maaf, simpan Program gagal. Data sudah ada');
$this->redirect(array('/errPage/errDB'));
}
} else {
$this->actionIndex();
}
}