本文整理汇总了PHP中Domain::insert方法的典型用法代码示例。如果您正苦于以下问题:PHP Domain::insert方法的具体用法?PHP Domain::insert怎么用?PHP Domain::insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Domain
的用法示例。
在下文中一共展示了Domain::insert方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionAdd
public function actionAdd()
{
$msgDomain = "";
$request = Yii::app()->getRequest();
if (!empty($_POST)) {
$name = trim($request->getPost("name"));
$admin = trim($request->getPost("admin"));
$username = trim($request->getPost("username"));
$password = trim($request->getPost("password"));
$provider = trim($request->getPost("provider"));
$status = trim($request->getPost("status"));
if ($name == "") {
$msgDomain = "域名名称选项不能留空";
} else {
if (strlen($name) > 64) {
$msgDomain = "输入不能大于64个字符";
}
}
if ($msgDomain == "") {
$domain = array('name' => $name, 'admin' => $admin, 'username' => $username, 'password' => $password, 'provider' => $provider, 'status' => $status);
try {
$res = new Domain();
$res->_attributes = $domain;
$res->insert();
$this->redirect(array('list'));
} catch (CDbException $re) {
throw CDbException($re);
}
}
}
$this->render('add', array('r' => Yii::app()->request->baseUrl . '/', 'msgDomain' => $msgDomain));
}
示例2: process_page
function process_page($app, $action, &$var)
{
$var['domain_count'] = Domain::count();
$var['user_count'] = User::count();
$var['domains'] = Domain::list_all();
// perform requested actions
switch ($app->action) {
case 'edit_domain':
$var['domain_name'] = Domain::list_by_id($var['domain_id'])->get_name();
break;
case 'insert_new_domain':
$domain = new Domain();
$domain->set_name($var['domain_name']);
if ($domain->insert()) {
$app->reload();
} else {
$app->action = 'new_domain';
}
break;
case 'update_edit_domain':
$domain = Domain::list_by_id($var['domain_id']);
$domain->set_name($var['domain_name']);
if ($domain->update()) {
$app->reload();
} else {
$app->action = 'edit_domain';
}
break;
case 'delete_domain':
$domain = Domain::list_by_id($var['domain_id']);
if ($domain->delete()) {
$app->reload();
}
break;
}
}