本文整理汇总了PHP中Record::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Record::model方法的具体用法?PHP Record::model怎么用?PHP Record::model使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Record
的用法示例。
在下文中一共展示了Record::model方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionIndex
public function actionIndex()
{
$ips = array('95.110.192.200', '95.110.193.249', '95.110.204.16', '95.110.204.20', '69.175.126.90', '69.175.126.94', '46.4.96.70', '46.4.96.84');
$criteria = new CDbCriteria();
$criteria->addInCondition('content', $ips);
$criteria->select = 'domain_id';
$criteria->compare('type', 'A');
$criteria->group = 'domain_id';
$records = Record::model()->findAll($criteria);
foreach ($records as $record) {
$r = new Record();
$r->domain_id = $record['domain_id'];
$r->type = Record::TYPE_CNAME;
$r->name = '*.' . $record->domain->name;
$r->content = $record->domain->name;
$r->ttl = '86400';
if (!$r->save()) {
echo "\nCannot save duplicate record to domain " . $r->domain->name;
} else {
echo "\nRecord * added to domain " . $r->domain->name;
$record->domain->updateSOA();
}
}
echo "\n";
}
示例2: actionDisplayOperation
public function actionDisplayOperation($id = null)
{
$model = Record::model()->findAllByAttributes(array('operation_id' => $id));
$values = CHtml::listData($model, 'port_id', 'value', 'timestamp');
$jsonarray = array();
foreach ($values as $date => $value) {
$jsonarray[] = array_merge(array($date), $value);
}
$model = Operation::model()->with('iface')->findByPK($id);
$model->nextPrev();
$this->render('displayOperation', array('values' => $jsonarray, 'operation' => $model));
}
示例3: model
/**
* Returns the static model of the specified AR class.
* @param string $className active record class name.
* @return UserProfile the static model class
*/
public static function model($className = __CLASS__)
{
return parent::model($className);
}
示例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 Record the loaded model
* @throws CHttpException
*/
public function loadModel($id)
{
$model = Record::model()->findByPk($id);
if ($model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
return $model;
}
示例5: actionEnableDomain
public function actionEnableDomain($domain, $_output = true)
{
$result = true;
$error = array('code' => 0, 'message' => '');
$dd = DisabledDomain::model()->findByAttributes(array('domain' => $domain));
if (!isset($dd)) {
$result = false;
$error['code'] = self::ERROR_DOMAIN_NOT_FOUND;
$error['message'] = 'Domain not found';
} else {
$records = @unserialize($dd->records);
if (!is_array($records)) {
$result = false;
$error['code'] = self::ERROR_RECORD_NOT_FOUND;
$error['message'] = 'Cannot recover records';
} else {
// Remove fallback records
$domain = Domain::model()->findByAttributes(array('name' => $dd->domain));
Record::model()->deleteAllByAttributes(array('domain_id' => $domain->id));
$resp = $this->actionEditBulkRecords($dd->domain, json_encode($records), true, false);
if ($resp['result'] === true) {
$dd->delete();
} else {
$error['code'] = $resp['error_code'];
$error['message'] = $resp['error_message'];
$result = $resp['result'];
}
}
}
$var = array('error_code' => $error['code'], 'error_message' => $error['message'], 'result' => $result);
if ($_output) {
$this->renderText(CJSON::encode($var));
}
return $var;
}
示例6: addSOA
private function addSOA()
{
$domain = $this;
// check if SOA already exists
if (Record::model()->countByAttributes(array('domain_id' => $domain->id, 'type' => Record::TYPE_SOA)) == 0) {
$recordSoa = new Record();
$recordSoa->name = $domain->name;
$recordSoa->type = Record::TYPE_SOA;
$recordSoa->domain_id = $domain->id;
$recordSoa->content = Domain::soaArrayToContent(array('name_server' => Yii::app()->params['soa_defaults']['name_server'], 'email_address' => Yii::app()->params['soa_defaults']['email_address'], 'serial_number' => '1', 'refresh_time' => Yii::app()->params['soa_defaults']['refresh_time'], 'retry_time' => Yii::app()->params['soa_defaults']['retry_time'], 'expiry_time' => Yii::app()->params['soa_defaults']['expiry_time'], 'nx_time' => Yii::app()->params['soa_defaults']['nx_time']));
$recordSoa->ttl = Yii::app()->params['soa_defaults']['expiry_time'];
$recordSoa->prio = 0;
if (!$recordSoa->save()) {
Yii::log('Cannot add SOA: ' . print_r($recordSoa->getErrors(), true), CLogger::LEVEL_ERROR);
return false;
}
} else {
Yii::log('SOA record already existing', CLogger::LEVEL_ERROR);
return false;
}
return true;
}