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


PHP Data::model方法代码示例

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


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

示例1: FixSEOState

 /**
  * 修正取得資料,僅修正最後一筆。
  */
 private function FixSEOState()
 {
     //取得最後一筆Task
     $lastId = Yii::app()->db->createCommand('SELECT TaskID FROM task ORDER BY TaskID DESC LIMIT 1')->queryScalar();
     //取得網址
     $dataProvider = new CActiveDataProvider(SiteUrl::model(), array('pagination' => false));
     //echo '資料庫共'.$dataProvider->totalItemCount.'筆資料'."\r\n";
     $i = 0;
     foreach ($dataProvider->getData() as $record) {
         //逐一將DataID取出
         //print_r($record);
         $DataId = Yii::app()->db->createCommand("SELECT DataId FROM data WHERE `SiteID`= {$record->SiteID} AND `TaskID` = {$lastId} LIMIT 1")->queryScalar();
         //讀取資料
         $model = Data::model()->findByPk($DataId);
         if ($model === null) {
             continue;
         }
         //print_r($model);
         //$model->getAttributes(array('name', 'distance'));
         //僅檢查Google API部分
         if ($model->GoogleData == '0' or $model->GoogleData == '' or is_null($model->GoogleData) or empty($model->GoogleData)) {
             usleep(rand(500, 1000));
             $model->GoogleData = $this->GetGoogleSearch("site:{$record->site}");
             echo "[{$record->site} 修正索引部分],";
         }
         usleep(rand(1000, 3000));
         if ($model->google_backlink == '0' or $model->google_backlink == '' or is_null($model->google_backlink) or empty($model->google_backlink)) {
             usleep(rand(500, 1000));
             $model->google_backlink = $this->GetGoogleSearch("link:{$record->site}");
             echo "[{$record->site} 修正連結部分],";
         }
         //逐一檢查檔案是否取得資料。
         $fileTypeList = array('pdf', 'doc', 'docx', 'ppt', 'pptx', 'ps', 'eps');
         $fileCount = array();
         $error_statues = 0;
         foreach ($fileTypeList as $key => $value) {
             usleep(rand(5000, 10000));
             if ($model->{$value} == 0) {
                 $model->{$value} = $this->GetGoogleSearch("site:{$record->site}" . ' filetype:' . $value);
                 echo "[{$record->site} 修正檔案 {$value} 部分],";
                 if (is_null($model->{$value})) {
                     $model->{$value} = \SEOstats\Services\Google::getSiteFileTypeTotal($record->site, $value);
                     //表示系統被Google封鎖了。
                     if (is_null($model->{$value})) {
                         $model->{$value} = 0;
                         $error_statues++;
                     }
                 }
             }
         }
         if ($model->save()) {
             $i++;
         } else {
             print "網址: {$site} 出現錯誤";
             print_r($model->getErrors());
         }
         usleep(rand(100, 400));
     }
     Yii::app()->end();
 }
开发者ID:wishnoblog,项目名称:SitePageRank,代码行数:63,代码来源:RunController.php

示例2: actionData

 public function actionData($id = null, $metric = null)
 {
     if (isset($_POST['data'])) {
         foreach ($_POST['data'] as $id => $value) {
             $model = Data::model()->findByPk($id);
             $model->value = is_numeric($value) ? (int) $value : null;
             $model->save();
         }
         echo Sector::getJson();
     } else {
         $metricModel = Metric::model()->findByAttributes(array('name' => $metric));
         $metric_ids = CHtml::listData($metricModel->getMetricWithDescendants(), 'id', 'id');
         if ($metricModel->type == '1') {
             echo $this->renderPartial('dataForm', array('sector' => Sector::model()->findByPk($id), 'metric_ids' => $metric_ids));
         } elseif ($metricModel->type = '2') {
             foreach (Sector::model()->findByPk($id)->square->sectors as $sector) {
                 echo CHtml::tag('h3', array(), $sector->title);
                 echo $this->renderPartial('dataForm', array('sector' => $sector, 'metric_ids' => $metric_ids));
                 echo Chtml::hiddenField('sector_id', $id);
             }
         }
     }
 }
开发者ID:nizsheanez,项目名称:kur.ru,代码行数:23,代码来源:SaveController.php

示例3:

<?php

$data = Data::model()->metrics($metric_ids)->sectors($sector->id)->findAll();
foreach ($data as $item) {
    echo CHtml::label($item->metric->title, 'data[' . $item->id . ']');
    echo '<br />';
    echo CHtml::textField('data[' . $item->id . ']', $item->value);
    echo '<br />';
}
开发者ID:nizsheanez,项目名称:kur.ru,代码行数:9,代码来源:dataForm.php

示例4: loadModel

 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Data the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Data::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
开发者ID:wishnoblog,项目名称:SitePageRank,代码行数:15,代码来源:DataController.php

示例5:

<header class="header-image">
    <div class="headline">
        <div class="container">
            <h1><?php 
echo CHtml::encode(Yii::app()->name);
?>
<br><small>各單位系所網站資訊統計系統</small></h1>

			<br>
			<!-- Contextual button for informational alert messages -->

            <div class="row">
                <div class="counters col-md-4 col-sm-4">
                    <span class="counter">
                    <?php 
echo Data::model()->count() * 8;
?>
                    </span>
                    <h4>登錄資料筆數</h4>
                </div>
                <div class="counters col-md-4 col-sm-4">
                    <span class="counter"> <?php 
echo Group::model()->count();
?>
</span>
                    <h4>網站數</h4>
                </div>
                <div class="counters col-md-4 col-sm-4">
                    <span class="counter"> <?php 
echo SiteUrl::model()->count();
?>
开发者ID:wishnoblog,项目名称:SitePageRank,代码行数:31,代码来源:index.php


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