本文整理匯總了PHP中Documents::validate方法的典型用法代碼示例。如果您正苦於以下問題:PHP Documents::validate方法的具體用法?PHP Documents::validate怎麽用?PHP Documents::validate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Documents
的用法示例。
在下文中一共展示了Documents::validate方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: actionDelZnoSubject
public function actionDelZnoSubject($num)
{
$model = new Documents('ZNO');
$subjects = array();
$valid = true;
if (isset($_GET["Documents"])) {
$model->attributes = $_GET["Documents"];
$model->validate();
}
if (isset($_GET["Documentsubject"])) {
unset($_GET["Documentsubject"][$num]);
foreach ($_GET["Documentsubject"] as $i => $obj) {
$item = new Documentsubject();
$item->attributes = $obj;
if ($i == $num) {
$item->deleted = 1;
}
if ($item->deleted == 0) {
$valid = $item->validate() && $valid;
}
$subjects[] = $item;
}
}
$this->renderPartial('_form', array('model' => $model, 'subjects' => $subjects));
}
示例2: actionAppendBenefit
public function actionAppendBenefit()
{
$model = new PersonBenefits();
$documents = array();
$valid = true;
if (isset($_GET["PersonBenefits"])) {
$model->attributes = $_GET["PersonBenefits"];
if (isset($_GET["Documents"])) {
foreach ($_GET["Documents"] as $i => $obj) {
$item = new Documents();
$item->attributes = $obj;
$valid = $valid && $item->validate();
$documents[] = $item;
}
}
}
if (!$valid) {
echo CJSON::encode(array("result" => "suceess", "data" => $this->renderPartial('_form', array('model' => $model, 'documents' => $documents), true)));
} else {
/* save all new records */
$flag = $transaction = Yii::app()->db->getCurrentTransaction();
if ($transaction === null) {
$transaction = Yii::app()->db->beginTransaction();
}
try {
if ($model->save()) {
foreach ($documents as $doc) {
$doc->PersonID = $model->PersonID;
if ($doc->save()) {
if (empty($doc->idDocuments)) {
throw new Exception("idDocuments is empty!");
}
$rel = new PersonBenefitDocument();
$rel->DocumentID = $doc->getPrimaryKey();
$rel->PersonBenefitID = $model->idPersonBenefits;
$rel->save();
}
}
}
$transaction->commit();
$person = Person::model()->findByPk($model->PersonID);
echo CJSON::encode(array("result" => "success", "data" => $this->renderPartial("_benefits", array('models' => $person->benefits, 'personid' => $model->PersonID), true)));
} catch (Exception $e) {
if ($flag !== null) {
$transaction->rollback();
}
echo CJSON::encode(array("result" => "suceess", "data" => $e->getMessage()));
}
}
}