本文整理汇总了PHP中delete_records函数的典型用法代码示例。如果您正苦于以下问题:PHP delete_records函数的具体用法?PHP delete_records怎么用?PHP delete_records使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了delete_records函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process_form
function process_form()
{
global $CFG, $page;
unlink($this->imagepath);
delete_records('lightboxgallery_image_meta', 'gallery', $this->gallery->id, 'image', $this->image);
redirect($CFG->wwwroot . '/mod/lightboxgallery/view.php?l=' . $this->gallery->id . '&page=' . $page . '&editing=1');
}
示例2: delete
/**
* Deletes this outcome from the database.
* @param string $source from where was the object deleted (mod/forum, manual, etc.)
* @return boolean success
*/
function delete($source = null)
{
if (!empty($this->courseid)) {
delete_records('grade_outcomes_courses', 'outcomeid', $this->id, 'courseid', $this->courseid);
}
return parent::delete($source);
}
示例3: send_message
/**
* Processes the message (sends by email).
* @param object $message the message to be sent
*/
function send_message($message)
{
//send an email
//if fails saved as read message
//first try to get preference
$usertoemail = get_user_preferences('message_processor_email_email', '', $message->useridto);
//if fails use user profile default
if ($usertoemail == NULL) {
$userto = get_record('user', 'id', $message->useridto);
$usertoemail = $userto->email;
}
$userfrom = get_record('user', 'id', $message->useridfrom);
if (email_to_user($usertoemail, $userfrom->email, $message->subject, $message->fullmessage, $message->fullmessagehtml)) {
/// Move the entry to the other table
$message->timeread = time();
$messageid = $message->id;
unset($message->id);
//if there is no more processor that want to process this can move message
if (count_records('message_working', array('unreadmessageid' => $messageid)) == 0) {
if (insert_record('message_read', $message)) {
delete_records('message', 'id', $messageid);
}
}
} else {
//delete what we've processed and check if can move message
if (count_records('message_working', 'unreadmessageid', $messageid) == 0) {
if (insert_record('message_read', $message)) {
delete_records('message', 'id', $messageid);
}
}
}
return true;
}
示例4: deletepost_submit
function deletepost_submit(Pieform $form, $values)
{
global $SESSION, $postid, $goto;
delete_records('blocktype_wall_post', 'id', $postid);
$SESSION->add_ok_msg(get_string('deletepostsuccess', 'blocktype.wall'));
redirect($goto);
}
示例5: deletefontform_submit
function deletefontform_submit(Pieform $form, $values)
{
global $SESSION;
$fontname = $values['font'];
$result = delete_records('skin_fonts', 'name', $fontname);
if ($result == false) {
$SESSION->add_error_msg(get_string('cantdeletefont', 'skin'));
} else {
// Check to see if the font is being used in a skin. If it is remove it from
// the skin's viewskin data
$skins = get_records_array('skin');
if (is_array($skins)) {
foreach ($skins as $skin) {
$options = unserialize($skin->viewskin);
foreach ($options as $key => $option) {
if (preg_match('/font_family/', $key) && $option == $fontname) {
require_once get_config('docroot') . 'lib/skin.php';
$skinobj = new Skin($skin->id);
$viewskin = $skinobj->get('viewskin');
$viewskin[$key] = 'Arial';
// the default font
$skinobj->set('viewskin', $viewskin);
$skinobj->commit();
}
}
}
}
// Also delete all the files in the appropriate folder and the folder itself...
$fontpath = get_config('dataroot') . 'skins/fonts/' . $fontname;
recurse_remove_dir($fontpath);
$SESSION->add_ok_msg(get_string('fontdeleted', 'skin'));
}
redirect('/admin/site/fonts.php');
}
示例6: xmldb_block_task_list_upgrade
function xmldb_block_task_list_upgrade($oldversion = 0)
{
$result = true;
if ($result and $oldversion < 2007011501) {
/// Define field format to be added to block_task_list
$table = new XMLDBTable('block_task_list');
$field = new XMLDBField('format');
$field->setAttributes(XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'name');
/// Launch add field format
$result = $result and add_field($table, $field);
}
if ($result and $oldversion < 2007011503) {
/// Manually remove bad capabilities
$result = $result and delete_records('capabilities', 'name', 'block/tast_list:manage');
$result = $result and delete_records('capabilities', 'name', 'block/tast_list:checkofftasks');
}
if ($result and $oldversion < 2007011505) {
//TODO: The info field might be able to be removed, as it doesn't seem to be used anywhere, but in the meantime, change it to allow nulls
/// Changing nullability of field info on table block_task_list to allow null
$table = new XMLDBTable('block_task_list');
$field = new XMLDBField('info');
$field->setAttributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, 'checked');
/// Launch change of nullability for field info
$result = $result && change_field_notnull($table, $field);
}
return $result;
}
示例7: postinst
public static function postinst($prevversion)
{
// Add blocktype category called 'survey' if it doesn't exists...
ensure_record_exists('blocktype_category', (object) array('name' => 'survey'), (object) array('name' => 'survey'));
if ($prevversion == 0) {
// 1. Convert MyLearning artefacts to Survey artefacts (mhr_artefact table)...
convert_artefacts_to_survey('multipleintelligences');
convert_artefacts_to_survey('learningstyles');
// 2. Install survey artefact blocktype named survey and later correctly convert block instances used in views...
install_survey_blocktype();
// 3. Convert block instances used in views (mhr_block_instance table)...
convert_blocks_used_in_views('multipleintelligences');
convert_blocks_used_in_views('learningstyles');
// 4. Delete multipleintelligences and learningstyles blocks from mhr_blocktype_installed* tables...
delete_records('blocktype_installed_viewtype', 'blocktype', 'multipleintelligences');
delete_records('blocktype_installed_category', 'blocktype', 'multipleintelligences');
delete_records('blocktype_installed_viewtype', 'blocktype', 'learningstyles');
delete_records('blocktype_installed_category', 'blocktype', 'learningstyles');
delete_records('blocktype_installed', 'artefactplugin', 'learning');
// 5. Delete learning artefact from mhr_artefact_installed* tables...
delete_records('artefact_installed_type', 'plugin', 'learning');
delete_records('artefact_installed', 'name', 'learning');
// 6. Recursive delete learning folder from htdocs/artefact/learning...
recursive_folder_delete(get_config('docroot') . 'artefact/learning/');
}
}
示例8: forumng_delete_instance
function forumng_delete_instance($id, $ociskip = true)
{
require_once dirname(__FILE__) . '/forum.php';
try {
$forum = forum::get_from_id($id, forum::CLONE_DIRECT);
// avoid deleting OCI specific forum if running in upload block
if ($ociskip) {
global $restore;
if (isset($restore) && $restore->restoreto == 0 && strpos($_SERVER['HTTP_REFERER'], 'blocks/versions/upload.php') !== false) {
if ($forum->get_name() == get_string('newunitforumname', 'createcourse')) {
//Unit forum
echo ' found forumng ' . $forum->get_id() . ' ' . $forum->get_name();
return true;
}
}
}
$forum->delete_all_data();
if (forum::search_installed()) {
$cm = $forum->get_course_module();
ousearch_document::delete_module_instance_data($cm);
}
} catch (Exception $e) {
return false;
}
return delete_records('forumng', 'id', $id);
}
示例9: nanogong_delete_instance
/**
* Given an ID of an instance of this module,
* this function will permanently delete the instance
* and any data that depends on it.
*
* @param int $id Id of the module instance
* @return boolean Success/Failure
**/
function nanogong_delete_instance($id)
{
global $CFG;
if (!($nanogong = get_record("nanogong", "id", "{$id}"))) {
return false;
}
$result = true;
# Delete any dependent records here #
if (!delete_records("nanogong", "id", "{$nanogong->id}")) {
$result = false;
}
if ($nanogong_messages = get_records("nanogong_message", "nanogongid", "{$nanogong->id}")) {
global $CFG;
foreach ($nanogong_messages as $nanogong_message) {
$soundfile = $CFG->dataroot . $nanogong_message->path;
if (file_exists($soundfile)) {
unlink($soundfile);
}
}
}
if (substr($CFG->release, 0, 3) == "1.9") {
nanogong_grade_item_delete($nanagong);
}
if (!delete_records("nanogong_message", "nanogongid", "{$nanogong->id}")) {
$result = false;
}
return $result;
}
示例10: restore_data
public static function restore_data($data, $restore)
{
$linknamestatus = $linkurlstatus = false;
foreach ($data as $datum) {
switch ($datum->name) {
case 'linkname':
// We just want to know that it is there
$linknamestatus = true;
break;
case 'linkurl':
$content = $datum->value;
$result = restore_decode_content_links_worker($content, $restore);
if ($result != $content) {
$datum->value = addslashes($result);
if (debugging() and !defined('RESTORE_SILENTLY')) {
echo '<br /><hr />' . s($content) . '<br />changed to<br />' . s($result) . '<hr /><br />';
}
$linkurlstatus = update_record('pagemenu_link_data', $datum);
} else {
$linkurlstatus = true;
}
break;
default:
debugging('Deleting unknown data type: ' . $datum->name);
// Not recognized
delete_records('pagemenu_link_data', 'id', $datum->id);
break;
}
}
return $linkurlstatus and $linknamestatus;
}
示例11: delete_record
/**
* レコード削除 + 表示順を再構築
*/
public static function delete_record($record)
{
if (!delete_records('sharing_cart', 'id', $record->id)) {
return FALSE;
}
self::renumber($record->user);
return TRUE;
}
示例12: delete_repository
function delete_repository($id)
{
if (delete_records("door_repository", "id", $id)) {
return true;
} else {
return false;
}
}
示例13: friend_user_delete
function friend_user_delete($object_type, $event, $object)
{
if (!empty($object->ident) && $object_type == "user" && $event == "delete") {
delete_records('friends', 'owner', $object->ident);
delete_records('friends', 'friend', $object->ident);
}
return $object;
}
示例14: elis_cron
/**
* Run scheduled tasks according to a cron spec.
*/
function elis_cron()
{
global $CFG;
require $CFG->dirroot . '/elis/core/lib/tasklib.php';
$timenow = time();
// get all tasks that are (over-)due
$tasks = get_recordset_select('elis_scheduled_tasks', 'nextruntime <= ' . $timenow, 'nextruntime ASC');
if (empty($tasks)) {
return;
}
while ($task = rs_fetch_next_record($tasks)) {
$starttime = microtime();
mtrace("Running {$task->callfunction}({$task->taskname}) from {$task->plugin}...");
if ($task->enddate !== null && $task->enddate < $timenow) {
mtrace('* Cancelling task: past end date');
delete_records('elis_scheduled_tasks', 'id', $task->id);
continue;
}
// FIXME: check for blocking tasks
// FIXME: check if task is locked
// See if some other cron has already run the function while we were
// doing something else -- if so, skip it.
$nextrun = get_field('elis_scheduled_tasks', 'nextruntime', 'id', $task->id);
if ($nextrun > $timenow) {
mtrace('* Skipped (someone else already ran it)');
continue;
}
// calculate the next run time
$newtask = new stdClass();
$newtask->id = $task->id;
$newtask->lastruntime = time();
$newtask->nextruntime = cron_next_run_time($newtask->lastruntime, (array) $task);
// see if we have any runs left
if ($task->runsremaining !== null) {
$newtask->runsremaining = $task->runsremaining - 1;
if ($newtask->runsremaining <= 0) {
mtrace('* Cancelling task: no runs left');
delete_records('elis_scheduled_tasks', 'id', $task->id);
} else {
update_record('elis_scheduled_tasks', $newtask);
}
} else {
update_record('elis_scheduled_tasks', $newtask);
}
// load the file and call the function
if ($task->callfile) {
$callfile = $CFG->dirroot . $task->callfile;
if (!is_readable($callfile)) {
mtrace('* Skipped (file not found)');
continue;
}
require_once $callfile;
}
call_user_func(unserialize($task->callfunction), $task->taskname);
$difftime = microtime_diff($starttime, microtime());
mtrace("* {$difftime} seconds");
}
}
示例15: delete_records
function delete_records($id)
{
if (!delete_records('game_queries', 'attemptid', $id)) {
error("Can't delete from game_queries attemptid={$id}");
}
if (!delete_records('game_cross', 'id', $id)) {
error("Can't delete from game_cross id={$id}");
}
}