本文整理汇总了PHP中Domain::getErrors方法的典型用法代码示例。如果您正苦于以下问题:PHP Domain::getErrors方法的具体用法?PHP Domain::getErrors怎么用?PHP Domain::getErrors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Domain
的用法示例。
在下文中一共展示了Domain::getErrors方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionAddDomain
/**
* Adds a domain to the database
*
* @param string $name The name of the domain
* @param string type The type of the domain. Can be:<br/>
* MASTER
* NATIVE
* @param int $template_id An optional template ID to be loaded in the domain
* @return array {result:boolean,error_code:int,error_message:string} A json encoded array containing:
* result: true if the domain has been created, false otherwise
* error_code: the code of the error. 0 means no error
* error_message: the explanation of the error
*/
public function actionAddDomain($name, $type = Domain::TYPE_MASTER, $template_id = '')
{
$result = true;
$error = array('code' => 0, 'message' => '');
$domain = new Domain();
$domain->name = $name;
$domain->type = $type;
try {
if (!$domain->save()) {
$error['code'] = self::ERROR_VALIDATION_CODE;
$error['message'] = $domain->getErrors();
$result = false;
} else {
// If there is a template, let's load it and insert:
if ($template_id != '') {
$records = Yii::app()->db->createCommand()->select()->from('zone_templ_records')->where('zone_templ_id = :id', array(':id' => $template_id))->queryAll();
$record_results = array();
foreach ($records as $record) {
$record['name'] = str_replace(array('[ZONE]', '[SERIAL]'), array($name, '1'), $record['name']);
$record['content'] = str_replace(array('[ZONE]', '[SERIAL]'), array($name, '1'), $record['content']);
$record_results[] = $this->actionAddRecord($name, $record['name'], $record['type'], $record['content'], empty($record['ttl']) ? 3600 : $record['ttl'], empty($record['prio']) ? 0 : $record['prio'], false, false);
}
$domain->updateSOA();
$all_ok = true;
foreach ($record_results as $record_result) {
if ($record_result['result'] !== true) {
$all_ok = false;
}
}
if ($all_ok) {
$result = true;
} else {
$result = false;
$error['code'] = self::ERROR_TEMPLATE_CODE;
$error['message'] = $record_results;
}
}
}
} catch (CDbException $e) {
if ($e->getCode() == 23000) {
// Domain already existing
$error['code'] = self::ERROR_DOMAIN_ALREADY_EXISTING_CODE;
$error['message'] = "Domain already existing";
} else {
$error['code'] = $e->getCode();
$error['message'] = $e->getMessage();
}
$result = false;
}
$var = array('error_code' => $error['code'], 'error_message' => $error['message'], 'result' => $result);
$this->renderText(CJSON::encode($var));
return $var;
}