当前位置: 首页>>代码示例>>PHP>>正文


PHP Item::validate方法代码示例

本文整理汇总了PHP中Item::validate方法的典型用法代码示例。如果您正苦于以下问题:PHP Item::validate方法的具体用法?PHP Item::validate怎么用?PHP Item::validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Item的用法示例。


在下文中一共展示了Item::validate方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: doValidate

 /**
  * This function performs the validation work for complex object models.
  *
  * In addition to checking the current object, all related objects will
  * also be validated.  If all pass then <code>true</code> is returned; otherwise
  * an aggreagated array of ValidationFailed objects will be returned.
  *
  * @param      array $columns Array of column names to validate.
  * @return     mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
  */
 protected function doValidate($columns = null)
 {
     if (!$this->alreadyInValidation) {
         $this->alreadyInValidation = true;
         $retval = null;
         $failureMap = array();
         // We call the validate method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aItem !== null) {
             if (!$this->aItem->validate($columns)) {
                 $failureMap = array_merge($failureMap, $this->aItem->getValidationFailures());
             }
         }
         if ($this->aUser !== null) {
             if (!$this->aUser->validate($columns)) {
                 $failureMap = array_merge($failureMap, $this->aUser->getValidationFailures());
             }
         }
         if (($retval = ShoppingCartPeer::doValidate($this, $columns)) !== true) {
             $failureMap = array_merge($failureMap, $retval);
         }
         $this->alreadyInValidation = false;
     }
     return !empty($failureMap) ? $failureMap : true;
 }
开发者ID:rayku,项目名称:rayku,代码行数:37,代码来源:BaseShoppingCart.php

示例2: doValidate

 /**
  * This function performs the validation work for complex object models.
  *
  * In addition to checking the current object, all related objects will
  * also be validated.  If all pass then <code>true</code> is returned; otherwise
  * an aggreagated array of ValidationFailed objects will be returned.
  *
  * @param      array $columns Array of column names to validate.
  * @return     mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
  */
 protected function doValidate($columns = null)
 {
     if (!$this->alreadyInValidation) {
         $this->alreadyInValidation = true;
         $retval = null;
         $failureMap = array();
         // We call the validate method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aEmpresa !== null) {
             if (!$this->aEmpresa->validate($columns)) {
                 $failureMap = array_merge($failureMap, $this->aEmpresa->getValidationFailures());
             }
         }
         if ($this->aItem !== null) {
             if (!$this->aItem->validate($columns)) {
                 $failureMap = array_merge($failureMap, $this->aItem->getValidationFailures());
             }
         }
         if (($retval = DocumentoPeer::doValidate($this, $columns)) !== true) {
             $failureMap = array_merge($failureMap, $retval);
         }
         if ($this->collHistoricoDocumentos !== null) {
             foreach ($this->collHistoricoDocumentos as $referrerFK) {
                 if (!$referrerFK->validate($columns)) {
                     $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
                 }
             }
         }
         $this->alreadyInValidation = false;
     }
     return !empty($failureMap) ? $failureMap : true;
 }
开发者ID:Esleelkartea,项目名称:legedia-ESLE,代码行数:44,代码来源:BaseDocumento.php

示例3: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $item = new Item();
     $detil_item = new DetilItem();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Item'], $_POST['DetilItem'])) {
         $item->attributes = $_POST['Item'];
         $detil_item->attributes = $_POST['DetilItem'];
         if ($item->validate() & $detil_item->validate()) {
             $connection = Yii::app()->db;
             $transaction = $connection->beginTransaction();
             try {
                 if ($item->save()) {
                     $detil_item->setAttribute('ID_ITEM', $item->ID_ITEM);
                     $detil_item->setAttribute('TANGGAL_INPUT', date('Y-m-d H:i:s'));
                     if ($detil_item->save()) {
                         $transaction->commit();
                         Yii::app()->user->setFlash('info', MyFormatter::alertSuccess('<strong>Selamat!</strong> Data telah berhasil disimpan.'));
                         $this->redirect(array('view', 'id' => $item->ID_ITEM));
                     }
                 }
             } catch (Exception $e) {
                 $transaction->rollback();
                 Yii::app()->user->setFlash('info', MyFormatter::alertDanger('<strong>Error!</strong> Data gagal untuk disimpan.' . $e->getMessage()));
             }
         }
     }
     $this->render('create', array('item' => $item, 'detil_item' => $detil_item));
 }
开发者ID:bangphe,项目名称:klinik,代码行数:34,代码来源:ItemController.php

示例4: actionCreateImage

 public function actionCreateImage($grid_cart = 'N')
 {
     $model = new Item();
     $price_tiers = PriceTier::model()->getListPriceTier();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (Yii::app()->user->checkAccess('item.create')) {
         if (isset($_POST['Item'])) {
             $model->attributes = $_POST['Item'];
             $qty = isset($_POST['Item']['quantity']) ? $_POST['Item']['quantity'] : 0;
             $unit_price = isset($_POST['Item']['unit_price']) ? $_POST['Item']['unit_price'] : 0;
             $model->quantity = $qty;
             $model->unit_price = $unit_price;
             $category_name = $_POST['Item']['category_id'];
             $publisher_name = $_POST['Item']['publisher_id'];
             $author_name = $_POST['Item']['author_id'];
             $publisher_id = Publisher::model()->savePublisher($publisher_name);
             if ($publisher_id !== null) {
                 $model->publisher_id = $publisher_id;
             }
             $author_id = Author::model()->saveAuthor($author_name);
             if ($author_id !== null) {
                 $model->author_id = $author_id;
             }
             //Saving new category to `category` table
             $category_id = Category::model()->saveCategory($category_name);
             if ($category_id !== null) {
                 $model->category_id = $category_id;
             }
             if ($model->validate()) {
                 $transaction = Yii::app()->db->beginTransaction();
                 try {
                     if ($model->save()) {
                         if (isset($_POST['Item']['count_interval'])) {
                             Item::model()->saveItemCounSchedule($model->id);
                         }
                         // Saving Item Price Tier to `item_price_tier`
                         ItemPriceTier::model()->saveItemPriceTier($model->id, $price_tiers);
                         $this->addImages($model, $transaction);
                         $transaction->commit();
                         if ($grid_cart == 'N') {
                             Yii::app()->user->setFlash(TbHtml::ALERT_COLOR_SUCCESS, 'Item : <strong>' . $model->name . '</strong> have been saved successfully!');
                             $this->redirect(array('createImage'));
                         } elseif ($grid_cart == 'S') {
                             Yii::app()->wshoppingCart->addItem($model->id);
                             $this->redirect(array('wholeSale/index'));
                         } elseif ($grid_cart == 'R') {
                             Yii::app()->receivingCart->addItem($model->id);
                             $this->redirect(array('receivingItem/index'));
                         }
                     }
                 } catch (Exception $e) {
                     $transaction->rollback();
                     //print_r($e);
                     Yii::app()->user->setFlash(TbHtml::ALERT_COLOR_WARNING, 'Oop something wrong : <strong>' . $e);
                 }
             }
         }
     } else {
         //throw new CHttpException(403, 'You are not authorized to perform this action');
         $this->redirect(array('site/ErrorException', 'err_no' => 403));
     }
     if (Yii::app()->request->isAjaxRequest) {
         $cs = Yii::app()->clientScript;
         $cs->scriptMap = array('jquery.js' => false, 'bootstrap.js' => false, 'jquery.min.js' => false, 'bootstrap.min.js' => false, 'bootstrap.notify.js' => false, 'bootstrap.bootbox.min.js' => false);
         //Yii::app()->clientScript->scriptMap['*.js'] = false;
         echo CJSON::encode(array('status' => 'render', 'div' => $this->renderPartial('_form_image', array('model' => $model, 'price_tiers' => $price_tiers), true, true)));
         Yii::app()->end();
     } else {
         $this->render('create_image', array('model' => $model, 'price_tiers' => $price_tiers));
     }
 }
开发者ID:soklux,项目名称:bakou-pos-apsara,代码行数:72,代码来源:ItemController.php

示例5: manageEntries

 function manageEntries()
 {
     // Delete entries in bulk
     if ($_POST['action'] == 'delete' && count($_POST['entry_check']) > 0) {
         if ($this->delete('entry')) {
             $this->showList("Portfolio entries successfully deleted");
             return;
         }
     }
     // If an individual entry is specified, edit it (and/or validate and process it)
     // Otherwise, just show the full list
     if (empty($_GET['entry'])) {
         $this->showList();
     } else {
         $itemID = intval($_GET['entry']);
         if (isset($_POST['submit_check'])) {
             // If the form was submitted...
             $item = new Item($_POST);
             if ($form_errors = $item->validate()) {
                 $this->editIndividual($itemID, $form_errors);
             } else {
                 $item->process();
             }
         } else {
             $this->editIndividual($itemID);
             // If not, just edit the entry
         }
     }
 }
开发者ID:andrewheiss,项目名称:WP-Portfolio,代码行数:29,代码来源:portfolio.php

示例6: doValidate

 /**
  * This function performs the validation work for complex object models.
  *
  * In addition to checking the current object, all related objects will
  * also be validated.  If all pass then <code>true</code> is returned; otherwise
  * an aggreagated array of ValidationFailed objects will be returned.
  *
  * @param      array $columns Array of column names to validate.
  * @return     mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
  */
 protected function doValidate($columns = null)
 {
     if (!$this->alreadyInValidation) {
         $this->alreadyInValidation = true;
         $retval = null;
         $failureMap = array();
         // We call the validate method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aBook !== null) {
             if (!$this->aBook->validate($columns)) {
                 $failureMap = array_merge($failureMap, $this->aBook->getValidationFailures());
             }
         }
         if ($this->aItemRelatedByPackageId !== null) {
             if (!$this->aItemRelatedByPackageId->validate($columns)) {
                 $failureMap = array_merge($failureMap, $this->aItemRelatedByPackageId->getValidationFailures());
             }
         }
         if (($retval = ItemPeer::doValidate($this, $columns)) !== true) {
             $failureMap = array_merge($failureMap, $retval);
         }
         if ($this->collItemsRelatedById !== null) {
             foreach ($this->collItemsRelatedById as $referrerFK) {
                 if (!$referrerFK->validate($columns)) {
                     $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
                 }
             }
         }
         if ($this->collSectionHasItems !== null) {
             foreach ($this->collSectionHasItems as $referrerFK) {
                 if (!$referrerFK->validate($columns)) {
                     $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
                 }
             }
         }
         $this->alreadyInValidation = false;
     }
     return !empty($failureMap) ? $failureMap : true;
 }
开发者ID:therealchiko,项目名称:getchabooks,代码行数:51,代码来源:BaseItem.php

示例7: saveOrder

 public function saveOrder()
 {
     $inputShipFrom = Input::get('shipFrom');
     $inputShipFrom = $this->jsonToInputArray($inputShipFrom);
     $inputshipTo = Input::get('shipTo');
     $inputshipTo = $this->jsonToInputArray($inputshipTo);
     $inputItem = Input::get('itemDetail');
     $inputItem = $this->jsonToInputArray($inputItem);
     $inputCompany = Input::get('companyInfo');
     $inputCompany = $this->jsonToInputArray($inputCompany);
     $result = array('errors' => '', 'result' => '');
     $foundErrors = false;
     //validate ship from info.
     $shipFrom = new ShipFrom();
     if ($shipFrom->validate($inputShipFrom) === false) {
         $foundErrors = true;
         $messages = $shipFrom->messages();
         if (count($messages)) {
             foreach ($messages as $message) {
                 $result['errors'] .= "<li>{$message}</li>";
             }
         }
     }
     //validate ship to information
     $shipTo = new ShipTo();
     if ($shipTo->validate($inputshipTo) === false) {
         $foundErrors = true;
         $messages = $shipTo->messages();
         if (count($messages)) {
             foreach ($messages as $message) {
                 $result['errors'] .= "<li>{$message}</li>";
             }
         }
     }
     //validate item information
     $item = new Item();
     if ($item->validate($inputItem) === false) {
         $foundErrors = true;
         $messages = $item->messages();
         if (count($messages)) {
             foreach ($messages as $message) {
                 $result['errors'] .= "<li>{$message}</li>";
             }
         }
     }
     //validate company information
     $company = new Company();
     if ($company->validate($inputCompany) === false) {
         $foundErrors = true;
         $messages = $company->messages();
         if (count($messages)) {
             foreach ($messages as $message) {
                 $result['errors'] .= "<li>{$message}</li>";
             }
         }
     }
     if ($foundErrors == true) {
         echo json_encode($result);
         return;
     }
     $data = array('shipFrom' => $inputShipFrom, 'shipTo' => $inputshipTo, 'item' => $inputItem, 'company' => $inputCompany);
     $action = Input::get('action');
     if ($action == 'update') {
         $orderId = Input::get('order_id');
         if (Order::update($orderId, $data) == true) {
             $result['result'] = 'success';
         } else {
             $result['errors'] = "<li>There was a problem with record update.Please try later.</li>";
         }
     } else {
         //create new order
         $newOrderId = Order::insert($data);
         if (is_numeric($newOrderId) && $newOrderId > 0) {
             $result['result'] = 'success';
         }
     }
     echo json_encode($result);
 }
开发者ID:yousafmalik786,项目名称:shipping-crud,代码行数:78,代码来源:OrderController.php

示例8: actionCreate

 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Item('create');
     $img = new ItemImg('create');
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     $action = 'item';
     if (isset($_POST['Item'])) {
         $model->attributes = $_POST['Item'];
         $model->sn = 'YC' . date('Ymd') . mt_rand(10000, 99999);
         if ($_POST['Item']['props']) {
             foreach ($_POST['Item']['props'] as $key => $value) {
                 $p = ItemProp::model()->findByPk($key);
                 if ($p->type == 'multiCheck') {
                     $values = implode($value, ',');
                     $p_arr[] = $key . ':' . $values;
                     foreach ($value as $kk => $vv) {
                         $v = PropValue::model()->findByPk($vv);
                         $value_name[] = $v->value_name;
                     }
                     $value_names = implode($value_name, ',');
                     $v_arr[] = $p->prop_name . ':' . $value_names;
                 } elseif ($p->type == 'optional') {
                     $p_arr[] = $key . ':' . $value;
                     $v = PropValue::model()->findByPk($value);
                     $v_arr[] = $p->prop_name . ':' . $v->value_name;
                 } elseif ($p->type == 'input') {
                     //如果是文本框输入的话 不纳入搜索
                     //也就不纳入到props里 只保存到prop_names里
                     $p_arr[] = $key . ':' . $value;
                     $v_arr[] = $p->prop_name . ':' . $value;
                 }
             }
             $props = implode($p_arr, ';');
             $model->props = $props;
             $props_name = implode($v_arr, ';');
             $model->props_name = $props_name;
         }
         if ($model->validate() && $img->validate()) {
             //                print_r($_POST);
             //                exit;
             if ($model->save()) {
                 if ($_POST['ItemImg']) {
                     for ($i = 0; $i <= 4; $i++) {
                         $img->isNewRecord = true;
                         $img->attributes = $_POST['ItemImg'];
                         $img->item_id = $model->item_id;
                         $img->position = $i;
                         $img->create_time = time();
                         // file handling
                         $imageUploadFile = CUploadedFile::getInstance($img, 'url' . $i);
                         if ($imageUploadFile !== null) {
                             // only do if file is really uploaded
                             $imageFileExt = $imageUploadFile->extensionName;
                             $save_path = dirname(Yii::app()->basePath) . '/upload/' . $action . '/image/';
                             if (!file_exists($save_path)) {
                                 mkdir($save_path, 0777, true);
                             }
                             $ymd = date("Ymd");
                             $save_path .= $ymd . '/';
                             if (!file_exists($save_path)) {
                                 mkdir($save_path, 0777, true);
                             }
                             $img_prefix = date("YmdHis") . '_' . rand(10000, 99999);
                             $imageFileName = $img_prefix . '.' . $imageFileExt;
                             $img->url = $ymd . '/' . $imageFileName;
                             $save_path .= $imageFileName;
                             $img->save();
                             $imageUploadFile->saveAs($save_path);
                         }
                     }
                 }
                 $this->redirect(array('view', 'id' => $model->item_id));
             }
         }
     }
     $this->render('create', array('model' => $model, 'img' => $img));
 }
开发者ID:yinhe,项目名称:yincart,代码行数:82,代码来源:ItemController1.php

示例9: _saveItem

 /**
  * If item object is given then updates it else inserts a new item
  * object in the database
  * @param object $item (Optional)
  * @return array
  */
 protected function _saveItem($item = null)
 {
     if (!$item) {
         $item = new Item(array());
     }
     $item->name = RequestMethods::post("name");
     $item->description = RequestMethods::post("description");
     $item->price = RequestMethods::post("price");
     $item->tax = RequestMethods::post("tax", 0.0);
     $item->user_id = $this->user->id;
     $item->period = RequestMethods::post("period", 30);
     if ($item->validate()) {
         $item->save();
         return array("success" => true, "item" => $item);
     }
     return array("success" => false, "errors" => $item->errors);
 }
开发者ID:SwiftDeal,项目名称:detectr,代码行数:23,代码来源:plan.php

示例10: _saveTests

 protected function _saveTests($package, $sorted)
 {
     $items = RequestMethods::post("items", array());
     $i = array();
     foreach ($items as $key => $value) {
         $i[$value] = $value;
     }
     $found = array_diff_key($sorted, $i);
     foreach ($found as $f) {
         unset($sorted[$f->test_id]);
         $f->delete();
     }
     $save = array_diff_key($i, $sorted);
     foreach ($save as $key => $value) {
         $item = new Item(array("package_id" => $package->id, "test_id" => $value, "organization_id" => $this->organization->id));
         if ($item->validate()) {
             $item->save();
             $sorted[$item->test_id] = $item;
         }
     }
     return $sorted;
 }
开发者ID:HLitmus,项目名称:WebApp,代码行数:22,代码来源:promotion.php


注:本文中的Item::validate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。