本文整理汇总了PHP中Slug::dbinsert方法的典型用法代码示例。如果您正苦于以下问题:PHP Slug::dbinsert方法的具体用法?PHP Slug::dbinsert怎么用?PHP Slug::dbinsert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Slug
的用法示例。
在下文中一共展示了Slug::dbinsert方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: param
// Slug edit form...:
// Make sure we got a slug_ID:
param('slug_ID', 'string', true);
break;
case 'create':
// Create new slug...
$edited_Slug = new Slug();
// Check that this action request is not a CSRF hacked request:
$Session->assert_received_crumb('slug');
// Check that current user has permission to create slugs:
$current_User->check_perm('slugs', 'edit', true);
// load data from request
if ($edited_Slug->load_from_Request()) {
// We could load data from form without errors:
// Insert in DB:
$edited_Slug->dbinsert();
$Messages->add(T_('New slug created.'), 'success');
// Redirect so that a reload doesn't write to the DB twice:
header_redirect('?ctrl=slugs', 303);
// Will EXIT
// We have EXITed already at this point!!
}
$action = 'new';
break;
case 'update':
// Update slug...
// Check that this action request is not a CSRF hacked request:
$Session->assert_received_crumb('slug');
// Check that current user has permission to edit slugs:
$current_User->check_perm('slugs', 'edit', true);
// Make sure we got an slug_ID:
示例2: elseif
/**
* Get the item tinyslug. If not exists -> create new
*
* @return string|boolean tinyslug on success, false otherwise
*/
function get_tinyslug()
{
global $preview;
$tinyslug_ID = $this->tiny_slug_ID;
if ($tinyslug_ID != NULL) {
// the tiny slug for this item was already created
$SlugCache =& get_SlugCache();
$Slug =& $SlugCache->get_by_ID($tinyslug_ID, false, false);
return $Slug === false ? false : $Slug->get('title');
} elseif ($this->ID > 0 && !$preview) {
// create new tiny Slug for this item
// Note: This may happen only in case of posts created before the tiny slug was introduced
global $DB;
load_funcs('slugs/model/_slug.funcs.php');
$Slug = new Slug();
$Slug->set('title', getnext_tinyurl());
$Slug->set('itm_ID', $this->ID);
$Slug->set('type', 'item');
$DB->begin();
if (!$Slug->dbinsert()) {
// Slug dbinsert failed
$DB->rollback();
return false;
}
$this->set('tiny_slug_ID', $Slug->ID);
// Update Item preserving mod date:
if (!$this->dbupdate(false)) {
// Item dbupdate failed
$DB->rollback();
return false;
}
$DB->commit();
// update last tinyurl value on database
// Note: This doesn't have to be part of the above transaction, no problem if it doesn't succeed to update, or if override a previously updated value.
global $Settings;
$Settings->set('tinyurl', $Slug->get('title'));
$Settings->dbupdate();
return $Slug->get('title');
}
return false;
}