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


PHP Data::save方法代码示例

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


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

示例1: afterSave

 public function afterSave()
 {
     parent::afterSave();
     if (count($this->data) == 0) {
         foreach (Sector::model()->findAll() as $sector) {
             $data = new Data();
             $data->metric_id = $this->id;
             $data->sector_id = $sector->id;
             $data->save();
         }
     }
 }
开发者ID:nizsheanez,项目名称:kur.ru,代码行数:12,代码来源:Metric.php

示例2: wizard

 public static function wizard($step = NULL)
 {
     // save the widget
     $widgetData = array();
     $widgetJson = json_encode($widgetData);
     $widget = new Widget();
     $widget->widget_name = 'note widget';
     $widget->widget_type = 'note';
     $widget->widget_provider = 'note';
     $widget->widget_source = $widgetJson;
     $widget->dashboard_id = Auth::user()->dashboards()->first()->id;
     $widget->position = '{"size_x":3,"size_y":3,"col":1,"row":1}';
     $widget->save();
     // save an empty data line
     $text = new Data();
     $text->widget_id = $widget->id;
     $text->data_object = '';
     $text->date = Carbon::now()->toDateString();
     $text->save();
     return Redirect::route('dashboard.dashboard')->with('success', 'Note widget added.');
 }
开发者ID:neraunzaran,项目名称:fruit-dashboard,代码行数:21,代码来源:NoteHelper.php

示例3: User

 // 登出
 case 'lo':
     $m = new User();
     $m->logout();
     break;
     //注册
 //注册
 case 'rg':
     $m = new User();
     $m->register();
     break;
     // 保存
 // 保存
 case 'sv':
     $m = new Data();
     $m->save();
     break;
     // 验证流程图是否存在
 // 验证流程图是否存在
 case 'cn':
     $m = new Data();
     $m->checkName();
     break;
     // 获取文件列表
 // 获取文件列表
 case 'fl':
     $m = new Data();
     $m->getFileList();
     break;
     // 获取单个文件内容
 // 获取单个文件内容
开发者ID:Perrywzp,项目名称:myflow-php,代码行数:31,代码来源:index.php

示例4: save

 public function save()
 {
     return Data::save($this);
 }
开发者ID:vincium,项目名称:bourg-la-reine,代码行数:4,代码来源:Model.php

示例5: postAddElement

 /**
  * @param $e
  */
 public function postAddElement($e)
 {
     $searchEntry = new Data($e->getTarget());
     $searchEntry->save();
 }
开发者ID:Gerhard13,项目名称:pimcore,代码行数:8,代码来源:Module.php

示例6: GetSEOState

 /**
  * 
  */
 private function GetSEOState($taskID)
 {
     $dataProvider = new CActiveDataProvider(SiteUrl::model(), array('pagination' => false));
     echo '資料庫共' . $dataProvider->totalItemCount . '筆資料' . "\r\n";
     $i = 0;
     foreach ($dataProvider->getData() as $record) {
         $site = $record->site;
         $id = $record->SiteID;
         // if($i>=5)
         // {
         // 	break;
         // }
         //移除前面的http:// (若有的話)
         $site = preg_replace('#^https?://#', '', $site);
         $site = preg_replace('#^http?://#', '', $site);
         //系統延遲
         $pagerank = 0;
         $now = new DateTime();
         try {
             $pagerank = \SEOstats\Services\Google::getPageRank($site);
             if (!is_numeric($pagerank)) {
                 $pagerank = null;
             }
         } catch (Exception $e) {
             $pagerank = null;
         }
         usleep(rand(1000, 3000));
         //下面這行是採用Google API提供之資料
         //$googleIds = \SEOstats\Services\Google::getSiteindexTotal($site);
         //下面這行是採用網頁搜尋結果資料
         if ($i % 2 == 1) {
             usleep(rand(500, 1000));
             $googleIds = $this->GetGoogleSearch("site:{$site}");
         } else {
             $googleIds = $this->GetGoogleSearch("site:{$site}");
         }
         sleep(3);
         if (is_null($googleIds)) {
             //用另外種管道重抓一次
             usleep(rand(5000, 10000));
             echo '[log]' . $site . "使用重抓索引資料;/r/n";
             $googleIds = \SEOstats\Services\Google::getSiteindexTotal($site);
         }
         if ($i % 2 == 1) {
             usleep(rand(500, 1000));
             $googleLinks = $this->GetGoogleSearch("link:{$site}");
         } else {
             $googleLinks = $this->GetGoogleSearch("link:{$site}");
         }
         //如果抓不到資料就換個管道
         if (is_null($googleLinks)) {
             //用另外種管道重抓一次
             usleep(rand(5000, 10000));
             echo '[log]' . $site . "使用API重抓頁面數資料;/r/n";
             $googleLinks = \SEOstats\Services\Google::getBacklinksTotal($site);
         }
         usleep(rand(1010, 15020));
         //echo("[log]".$now->format( 'Y-m-d H:i:s' )."搜尋".$site."有".$googleLinks.'項結果 '."\r\n");
         //取得社群分享數據
         $seostats = new \SEOstats\SEOstats();
         $seostats->setUrl("http://{$site}");
         $fb = Social::getFacebookShares();
         //print_r($fb);
         usleep(rand(4000, 10000));
         //
         //設定抓取的檔案類型
         //
         $fileTypeList = array('pdf', 'doc', 'docx', 'ppt', 'pptx', 'ps', 'eps');
         $fileCount = array();
         $error_statues = 0;
         foreach ($fileTypeList as $key => $value) {
             usleep(rand(5000, 10000));
             if ($error_statues == 0) {
                 $fileCount[$value] = $this->GetGoogleSearch("site:{$site}" . ' filetype:' . $value);
             }
             if (is_null($fileCount[$value])) {
                 $fileCount[$value] = \SEOstats\Services\Google::getSiteFileTypeTotal($site, $value);
                 //表示系統被Google封鎖了。
                 if (is_null($fileCount[$value])) {
                     $fileCount[$value] = 0;
                     $error_statues++;
                 }
             }
         }
         usleep(rand(4000, 10000));
         //取得網站資訊,包含網站一些設定資訊。
         $info = $this->get_url_info($site);
         $model = new Data();
         $model->attributes = array('SiteID' => $id, 'GoogleData' => $googleIds, 'google_backlink' => $googleLinks, 'filetime' => $info['filetime'] = !-1 ? date("Y-m-d H:i:s", $info['filetime']) : null, 'robot' => $this->remoteFileExists("{$site}/robots.txt"), 'sitemap' => $this->remoteFileExists("{$site}/sitemap.xml"), 'Time' => $now->format('Y-m-d H:i:s'), 'Facebook' => $fb['total_count'], 'FB_share_count' => $fb['share_count'], 'FB_like_count' => $fb['like_count'], 'FB_comment_count' => $fb['comment_count'], 'FB_commentsbox_count' => $fb['commentsbox_count'], 'FB_click_count' => $fb['click_count'], 'TwitterShares' => Social::getTwitterShares(), 'LinkedInShares' => Social::getLinkedInShares(), 'pdf' => $fileCount['pdf'], 'doc' => $fileCount['doc'], 'docx' => $fileCount['docx'], 'ppt' => $fileCount['ppt'], 'pptx' => $fileCount['pptx'], 'ps' => $fileCount['ps'], 'eps' => $fileCount['eps'], 'YY' => $now->format('Y'), 'MM' => $now->format('m'), 'DD' => $now->format('d'), 'TaskID' => $taskID, 'google_page_rank' => $pagerank);
         //Yii::app()->end();
         if ($model->save()) {
             $i++;
         } else {
             print "網址: {$site} 出現錯誤";
             print_r($model->getErrors());
         }
         usleep(rand(100, 400));
//.........这里部分代码省略.........
开发者ID:wishnoblog,项目名称:SitePageRank,代码行数:101,代码来源:RunController.php

示例7: syncChildren

 protected function syncChildren($thingName, $member, $parent)
 {
     if (!isset($parent[$member])) {
         throw new DumbassDeveloperException($member . " is not a child member of given parent");
     }
     $channel = Channel::Shopify;
     $children = $parent[$member];
     $parentThing = Thing::loadByAltId($parent["id"]);
     foreach ($children as $child) {
         $id = $child['id'];
         $thingChild = null;
         try {
             $thingChild = Thing::loadByAltId($id);
         } catch (InstanceNotFoundException $ex) {
             //create a thing for the top level product
             $thingChild = new Thing();
             $thingChild->setAltid($id);
             $thingChild->setName($thingName);
             $thingChild->setChannel($channel);
             $thingChild->setThing($parentThing);
             //set the parent of the child thing
             $thingChild->save();
         }
         //all data associated to the child
         $thingData_raw = $thingChild->getData();
         //indexed numerically
         //make array indexed by key
         $thingDatas = array();
         //indexed by key
         foreach ($thingData_raw as $thingData) {
             $thingDatas[$thingData->getKey()] = $thingData;
         }
         foreach ($child as $key => $value) {
             //create a new data if not exist in thingData
             if (!isset($thingDatas[$key])) {
                 $data = new Data();
                 $data->setKey($key);
                 $data->setValue($value);
                 $data->setThing($thingChild);
                 $data->save();
             } else {
                 $dbData = $thingDatas[$key];
                 if ($dbData->getValue() != $value) {
                     $dbData->setValue($value);
                     $dbData->save();
                 }
             }
         }
     }
 }
开发者ID:rajtrivedi2001,项目名称:shopify_app,代码行数:50,代码来源:request.php

示例8: Data

        return false;
    }
    $text_open = $app->request->getPost('text_open');
    $text_closed = $app->request->getPost('text_closed');
    $text_secret_key = $app->request->getPost('text_secret_key');
    if (!$text_open || !$text_closed || !$text_secret_key) {
        $app->response->redirect("?message=empty_fields")->sendHeaders();
        return false;
    }
    $data['user_id'] = $app->session->get('user_id');
    $data['text_open'] = $text_open;
    $data['text_closed'] = $app->crypt->encryptBase64($text_closed, $text_secret_key);
    $data['salt'] = Users::generateSalt();
    $data['text_secret_key'] = Users::sha1Rounds($app->config->app->static_salt . $text_secret_key . $data['salt']);
    $d = new Data();
    $d->save($data);
    $app->response->redirect("?message=data_add_success")->sendHeaders();
});
$app->post('/ajax', function () use($app) {
    if (!$app->request->isAjax()) {
        $app->response->setStatusCode(404, "Not Found")->sendHeaders();
        return false;
    }
    if ($app->security->checkToken('token') === false) {
        $app->response->setStatusCode(501, "Token error")->sendHeaders();
        return false;
    }
    $action = $app->request->getPost('action');
    $data = $app->request->getPost('data');
    $filter = new \Phalcon\Filter();
    switch ($action) {
开发者ID:aodkrisda,项目名称:phalconPasswordManager,代码行数:31,代码来源:routes.php

示例9: data_save

 public function data_save($id, $key, $value)
 {
     $validation = new Phalcon\Validation();
     $validation->add('key', new PresenceOf(['message' => 'key is needed']));
     $validation->add('key', new StringLength(['max' => 200, 'messageMaximum' => 'The key is too long, we can not save it.']));
     $validation->add('value', new PresenceOf(['message' => 'value is needed']));
     $validation->add('value', new StringLength(['max' => 200, 'messageMaximum' => 'The value is too long, we can not save it.']));
     $messages = $validation->validate(['key' => $key, 'value' => $value]);
     foreach ($messages as $message) {
         throw new Exception($message, 102);
     }
     $data = $this->findData($id, $key);
     if ($data == null) {
         $data = new Data();
         $data->user_id = $id;
         $data->key = $key;
     }
     $data->key = $key;
     $data->value = $value;
     $data->date = date("y-m-d H:i:s", time());
     $success = $data->save();
     if ($success) {
         return 0;
     } else {
         foreach ($data->getMessages() as $message) {
             throw new Exception($message, 100);
         }
     }
 }
开发者ID:hyfjjjj,项目名称:HHA-Web,代码行数:29,代码来源:UserDataController.php

示例10: getEvents

 public static function getEvents($user, $widget)
 {
     switch ($widget->widget_type) {
         case 'google-spreadsheet-line-cell':
             Log::info("google-spreadsheet-line-cell - widget_id - " . $widget['id']);
             $widget_source = json_decode($widget['widget_source'], true);
             $spreadsheetId = $widget_source['googleSpreadsheetId'];
             $worksheetName = $widget_source['googleWorksheetName'];
             # setup Google stuff
             $client = GooglespreadsheetHelper::setGoogleClient();
             $access_token = GooglespreadsheetHelper::getGoogleAccessToken($client, $user);
             # init service
             $serviceRequest = new DefaultServiceRequest($access_token);
             ServiceRequestFactory::setInstance($serviceRequest);
             $spreadsheetService = new Google\Spreadsheet\SpreadsheetService();
             # get spreadsheet
             $spreadsheet = $spreadsheetService->getSpreadsheetById($spreadsheetId);
             $worksheetFeed = $spreadsheet->getWorksheets();
             # get worksheet
             $worksheet = $worksheetFeed->getByTitle($worksheetName);
             $listFeed = $worksheet->getListFeed();
             # get celldata (first line = header, second line = content)
             $listArray = array();
             $values = array();
             foreach ($listFeed->getEntries() as $entry) {
                 $values = $entry->getValues();
                 break;
                 # break, so we just the first line
             }
             $time = time();
             $data = new Data();
             $data->widget_id = $widget['id'];
             $data->data_object = json_encode($values);
             $data->date = date("Y-m-d", $time);
             $data->timestamp = date('Y-m-d H:i:s', $time);
             $data->save();
             $widget->widget_ready = true;
             $widget->save();
             break;
             # / case 'google-spreadsheet-line-cell'
         # / case 'google-spreadsheet-line-cell'
         case 'google-spreadsheet-line-column':
             Log::info("google-spreadsheet-line-column - widget_id - " . $widget['id']);
             $widget_source = json_decode($widget['widget_source'], true);
             $spreadsheetId = $widget_source['googleSpreadsheetId'];
             $worksheetName = $widget_source['googleWorksheetName'];
             # setup Google stuff
             $client = GooglespreadsheetHelper::setGoogleClient();
             $access_token = GooglespreadsheetHelper::getGoogleAccessToken($client, $user);
             # init service
             $serviceRequest = new DefaultServiceRequest($access_token);
             ServiceRequestFactory::setInstance($serviceRequest);
             $spreadsheetService = new Google\Spreadsheet\SpreadsheetService();
             # get spreadsheet
             $spreadsheet = $spreadsheetService->getSpreadsheetById($spreadsheetId);
             $worksheetFeed = $spreadsheet->getWorksheets();
             # get worksheet
             $worksheet = $worksheetFeed->getByTitle($worksheetName);
             # get feeddata (first line = header)
             $listFeed = $worksheet->getListFeed();
             foreach ($listFeed->getEntries() as $entry) {
                 $array = $entry->getValues();
                 $date = array_values($array)[0];
                 $value = array_values($array)[1];
                 # format date (from almost everything to Y-m-d)
                 $time = strtotime(trim(str_replace('.', '-', $date), '-'));
                 # have we saved data for this date?
                 $db_data = Data::where('widget_id', '=', $widget['id'])->where('date', '=', date("Y-m-d", $time));
                 if ($db_data->count() == 0) {
                     # nope, save it
                     $data = new Data();
                     $data->widget_id = $widget['id'];
                     $data->data_object = json_encode(array("value" => $value));
                     $data->date = date("Y-m-d", $time);
                     $data->timestamp = date('Y-m-d H:i:s', $time);
                     $data->save();
                 } else {
                     # yes, update it
                     $db_data->update(['data_object' => json_encode(array("value" => $value))]);
                 }
             }
             $widget->widget_ready = true;
             $widget->save();
             break;
             # / case 'google-spreadsheet-line-column'
         # / case 'google-spreadsheet-line-column'
         case 'google-spreadsheet-text-cell':
             Log::info("google-spreadsheet-text-cell - widget_id - " . $widget['id']);
             $widget_source = json_decode($widget['widget_source'], true);
             $spreadsheetId = $widget_source['googleSpreadsheetId'];
             $worksheetName = $widget_source['googleWorksheetName'];
             # setup Google stuff
             $client = GooglespreadsheetHelper::setGoogleClient();
             $access_token = GooglespreadsheetHelper::getGoogleAccessToken($client, $user);
             # init service
             $serviceRequest = new DefaultServiceRequest($access_token);
             ServiceRequestFactory::setInstance($serviceRequest);
             $spreadsheetService = new Google\Spreadsheet\SpreadsheetService();
             # get spreadsheet
             $spreadsheet = $spreadsheetService->getSpreadsheetById($spreadsheetId);
//.........这里部分代码省略.........
开发者ID:neraunzaran,项目名称:fruit-dashboard,代码行数:101,代码来源:GoogleSpreadsheetHelper.php

示例11: while

                                                             }
                                                         }
                                                     }
                                                     $contenu .= '<a class="button" href="?action=game">Retour à l\'accueil</a>';
                                                 } else {
                                                     if ($action == 'generate') {
                                                         for ($i = 0; $i < 100; $i++) {
                                                             $matrixCode = Matrix::generateMatrixRandom($listeCartes);
                                                             $code = Matrix::generateCode();
                                                             $code = Matrix::generateCode();
                                                             while ($dataFile[$code]) {
                                                                 $code = Matrix::generateCode();
                                                             }
                                                             $dataFile[$code] = $code . ':' . $matrixCode;
                                                         }
                                                         Data::save($dataFile);
                                                         echo 'Sauvegardé dans games.txt';
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
开发者ID:pierreboivin,项目名称:newgame5,代码行数:31,代码来源:index.php

示例12: saveDataAction

 /**
  * [saveDataAction description]
  * @return [type] [description]
  */
 public function saveDataAction()
 {
     Input::flash();
     $data = Input::all();
     $rules = array('dataname' => array('min:3', 'required'));
     // Build the custom messages array.
     $messages = array('dataname.min' => 'กรุณาระบุชื่อข้อมูลอย่างนี้อย :min ตัวอักษร.', 'dataname.required' => 'กรุณาระบุชื่อข้อมูล');
     // Create a new validator instance.
     $validator = Validator::make($data, $rules, $messages);
     if ($validator->passes()) {
         $data_content = trim($data['dataname']);
         $data_tablename = trim($data['table_name']);
         $data_obj = new Data();
         $rs_check = $data_obj->checkData($data_content);
         if ($rs_check) {
             $data_obj->data_name = $data_content;
             $data_obj->table_name = $data_tablename;
             $data_obj->save();
             return Redirect::to('data')->with('success', 'บันทึกสำเร็จ');
         } else {
             return Redirect::to('data-add')->with('warning', 'มีชื่อข้อมูลอยู่ในระบบแล้ว');
         }
     } else {
         // $errors = $validator->messages();
         return Redirect::to('data-add')->withErrors($validator);
     }
 }
开发者ID:nattaphat,项目名称:cuse2,代码行数:31,代码来源:DataController.php

示例13: propise_action

function propise_action()
{
    global $_, $conf;
    switch ($_['action']) {
        case 'propise_save_sensor':
            Action::write(function ($_, &$response) {
                require_once 'Sensor.class.php';
                $sensor = new Sensor();
                if (empty($_['labelSensor'])) {
                    throw new Exception("Le nom est obligatoire");
                }
                if (empty($_['uidSensor'])) {
                    throw new Exception("L'UID est obligatoire");
                }
                $sensor = !empty($_['id']) ? $sensor->getById($_['id']) : new Sensor();
                $sensor->label = $_['labelSensor'];
                $sensor->location = $_['locationSensor'];
                $sensor->uid = $_['uidSensor'];
                $sensor->save();
                //Reference device for other plugins
                $device = new Device();
                $device->label = $sensor->label;
                $device->plugin = 'propise';
                $device->type = Device::CAPTOR;
                $device->location = $sensor->location;
                $device->icon = 'fa-heartbeat';
                $device->setValue('humidity', 0);
                $device->setValue('temperature', 0);
                $device->setValue('light', 0);
                $device->setValue('mouvment', 0);
                $device->setValue('sound', 0);
                $device->state = 1;
                $device->uid = $sensor->id;
                $device->save();
                $response['message'] = 'Sonde enregistrée avec succès';
            }, array('propise' => 'c'));
            break;
        case 'propise_delete_sensor':
            Action::write(function ($_, $response) {
                require_once 'Sensor.class.php';
                $sensor = new Sensor();
                $sensor->delete(array('id' => $_['id']));
            }, array('propise' => 'd'));
            break;
        case 'propise_add_data':
            /*for($i=0;$i<60;$i++){
            		$_ = array(
            		'uid'=>'sensor-2',
            		'humidity'=>rand(0,100),
            		'temperature'=>rand(0,100),
            		'light'=>rand(0,100),
            		'mouvment'=>rand(0,1),
            		'sound'=>rand(0,1)
            		);*/
            require_once 'Sensor.class.php';
            require_once 'Data.class.php';
            $sensor = new Sensor();
            $data = new Data();
            $sensor = $sensor->load(array('uid' => $_['uid']));
            if ($sensor == null || $sensor->id == 0) {
                return;
            }
            $data->time = time();
            //$data->time = strtotime(date('Ymd H:').$i.':00');
            $data->humidity = $_['humidity'];
            $data->temperature = $_['temperature'];
            $data->light = $_['light'];
            $data->mouvment = $_['mouvment'];
            $data->sound = $_['sound'];
            $data->sensor = $sensor->id;
            $data->save();
            //}
            break;
        case 'propise_load_widget':
            require_once dirname(__FILE__) . '/../dashboard/Widget.class.php';
            Action::write(function ($_, &$response) {
                $widget = new Widget();
                $widget = $widget->getById($_['id']);
                $parameters = $widget->data();
                if (empty($parameters['sensor'])) {
                    $content = 'Choisissez une localisation en cliquant sur l \'icone <i class="fa fa-wrench"></i> de la barre du widget';
                } else {
                    global $conf;
                    require_once 'Data.class.php';
                    require_once 'Sensor.class.php';
                    $sensor = new Sensor();
                    $data = new Data();
                    $sensor = $sensor->getById($parameters['sensor']);
                    $datas = $data->loadAll(array('sensor' => $sensor->id), 'time DESC', 1);
                    $response['title'] = 'Sonde ' . $sensor->label . ' (' . $sensor->uid . ')';
                    $content = '
						<!-- CSS -->
						<style>
							.propise_view{
								background:#36B3E1;
								color:#ffffff;
								margin:0px;
								padding:10px;
								width:100%;
								list-style-type:none;
//.........这里部分代码省略.........
开发者ID:rikimaruneo,项目名称:yana-server,代码行数:101,代码来源:propise.plugin.php

示例14: postUpload

 public function postUpload($unique)
 {
     //disable php timeout and db query log
     DB::disableQueryLog();
     set_time_limit(0);
     $compare = Compare::where('unique', $unique)->first();
     if (!$compare || !Session::get('owner')) {
         return Redirect::to('compare/notfound');
     }
     $file = Input::file('csv');
     $data_set = array();
     $config = new LexerConfig();
     $config->setDelimiter("\t");
     $lexer = new Lexer($config);
     //setup the interpreter
     $interpreter = new Interpreter();
     $interpreter->unstrict();
     $interpreter->addObserver(function (array $row) use(&$data_set) {
         $data_set[] = $row[0];
     });
     //parse it!
     $lexer->parse($file, $interpreter);
     //loop through the data
     foreach ($data_set as $data_item) {
         $data = new Data();
         $data->compare_id = $unique;
         $data->owner_id = Session::get('owner');
         $data->hash = md5($data_item);
         $data->save();
     }
     return Redirect::back();
 }
开发者ID:richardhawthorn,项目名称:safe_data_compare,代码行数:32,代码来源:CompareController.php


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