本文整理汇总了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()));
}
}
}