當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Proxy::save方法代碼示例

本文整理匯總了PHP中Proxy::save方法的典型用法代碼示例。如果您正苦於以下問題:PHP Proxy::save方法的具體用法?PHP Proxy::save怎麽用?PHP Proxy::save使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Proxy的用法示例。


在下文中一共展示了Proxy::save方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: createProxies

 private function createProxies()
 {
     $json = $this->loadProxyJson();
     foreach ($json as $entry) {
         $country = Country::findFirst(array("code = '{$entry->country}'"));
         if (!$country) {
             $country = new Country();
             $country->code = strtoupper($entry->country);
             $country->name = $entry->country;
             $country->save();
         }
         $proxy = Proxy::findFirst(array("address = '{$entry->url}'"));
         if (!$proxy) {
             $proxy = new Proxy();
             $proxy->countryId = $country->id;
             $proxy->address = $entry->url;
             $proxy->save();
             echo '<br />Proxy created: ' . $entry->url;
         } else {
             echo '<br />Proxy exists...';
         }
     }
 }
開發者ID:sweetdevel,項目名稱:pingaroo,代碼行數:23,代碼來源:DebugController.php

示例2: createAction

 /**
  * Creates a product based on the data entered in the "new" action
  */
 public function createAction()
 {
     if (!parent::isValidRequest(new ProxyValidation())) {
         return parent::redirect('proxy/new');
     }
     try {
         $address = trim($this->request->get('address'));
         $existingProxy = Proxy::findFirst(array('conditions' => 'address = ?0', 'bind' => array($address)));
         if ($existingProxy) {
             $this->flash->notice('Proxy address allready exists.');
             return parent::redirect('proxy/new');
         } else {
             $proxy = new Proxy();
             $proxy->countryId = $this->request->get('countryId');
             $proxy->address = $address;
             $proxy->save();
             $this->flash->success('Proxy created succesfully.');
         }
     } catch (Exception $ex) {
         $this->flash->error('An error occured when trying to create the new proxy.');
     }
     return $this->redirect('proxy');
     #$this->view->disable();
 }
開發者ID:sweetdevel,項目名稱:pingaroo,代碼行數:27,代碼來源:ProxyController.php


注:本文中的Proxy::save方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。