本文整理汇总了PHP中delete_records_select函数的典型用法代码示例。如果您正苦于以下问题:PHP delete_records_select函数的具体用法?PHP delete_records_select怎么用?PHP delete_records_select使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了delete_records_select函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: delete_states
function delete_states($stateslist)
{
/// The default question type does not have any tables of its own
// therefore there is nothing to delete
delete_records_select('question_flash_states', "stateid IN ({$stateslist})");
return true;
}
示例2: delete_module_instance_data
/**
* Static function. Deletes all data relating to a module instance.
* @param object $cm Course-module object (must have at least ->id and ->course)
*/
function delete_module_instance_data($cm)
{
global $CFG;
$where = 'courseid=' . $cm->course . ' AND coursemoduleid=' . $cm->id;
delete_records_select('block_ousearch_occurrences', 'documentid IN (SELECT id FROM ' . $CFG->prefix . 'block_ousearch_documents WHERE ' . $where . ')');
delete_records_select('block_ousearch_documents', $where);
}
示例3: remove_friend
function remove_friend($username, $friendusername)
{
if (!($userids = get_records_select('user', "username = '" . addslashes($username) . "' OR username = '" . addslashes($friendusername) . "'", '', 'username,id'))) {
return;
}
$userid = $userids[$username]->id;
$friendid = $userids[$friendusername]->id;
delete_records_select('user_friend', "(userid = {$userid} AND friendid = {$friendid}) OR (userid = {$friendid} AND friendid = {$userid})");
}
示例4: cleanup
public function cleanup($semestersid)
{
// Clean up All the referral logs
$semester = get_record('block_courseprefs_semesters', 'id', $semestersid);
delete_records('block_student_referrals', 'semestersid', $semestersid);
// Clean up all the teacher referral options on a section
$sections = get_records('block_courseprefs_sections', 'semestersid', $semestersid);
delete_records_select('block_teacher_referral_opt', 'sectionsid IN (' . implode(',', array_keys($sections)) . ')');
return get_string('cleanup_hook', 'block_student_gradeviewer', $semester);
}
示例5: pagemenu_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 pagemenu_delete_instance($id)
{
$result = true;
if ($links = get_records('pagemenu_links', 'pagemenuid', $id, '', 'id')) {
$linkids = implode(',', array_keys($links));
$result = delete_records_select('pagemenu_link_data', "linkid IN({$linkids})");
if ($result) {
$result = delete_records('pagemenu_links', 'pagemenuid', $id);
}
}
if ($result) {
$result = delete_records('pagemenu', 'id', $id);
}
return $result;
}
示例6: xmldb_quiz_upgrade
function xmldb_quiz_upgrade($oldversion = 0)
{
global $CFG, $THEME, $db;
$result = true;
/// And upgrade begins here. For each one, you'll need one
/// block of code similar to the next one. Please, delete
/// this comment lines once this file start handling proper
/// upgrade code.
if ($result && $oldversion < 2007022800) {
/// Ensure that there are not existing duplicate entries in the database.
$duplicateunits = get_records_select('question_numerical_units', "id > (SELECT MIN(iqnu.id)\n FROM {$CFG->prefix}question_numerical_units iqnu\n WHERE iqnu.question = {$CFG->prefix}question_numerical_units.question AND\n iqnu.unit = {$CFG->prefix}question_numerical_units.unit)", '', 'id');
if ($duplicateunits) {
delete_records_select('question_numerical_units', 'id IN (' . implode(',', array_keys($duplicateunits)) . ')');
}
/// Define index question-unit (unique) to be added to question_numerical_units
$table = new XMLDBTable('question_numerical_units');
$index = new XMLDBIndex('question-unit');
$index->setAttributes(XMLDB_INDEX_UNIQUE, array('question', 'unit'));
/// Launch add index question-unit
$result = $result && add_index($table, $index);
}
if ($result && $oldversion < 2007070200) {
/// Changing precision of field timelimit on table quiz to (10)
$table = new XMLDBTable('quiz');
$field = new XMLDBField('timelimit');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'timemodified');
/// Launch change of precision for field timelimit
$result = $result && change_field_precision($table, $field);
}
if ($result && $oldversion < 2007072200) {
require_once $CFG->dirroot . '/mod/quiz/lib.php';
// too much debug output
$db->debug = false;
quiz_update_grades();
$db->debug = true;
}
// Separate control for when overall feedback is displayed, independant of the question feedback settings.
if ($result && $oldversion < 2007072600) {
// Adjust the quiz review options so that overall feedback is displayed whenever feedback is.
$result = $result && execute_sql('UPDATE ' . $CFG->prefix . 'quiz SET review = ' . sql_bitor(sql_bitand('review', sql_bitnot(QUIZ_REVIEW_OVERALLFEEDBACK)), sql_bitor(sql_bitand('review', QUIZ_REVIEW_FEEDBACK & QUIZ_REVIEW_IMMEDIATELY) . ' * 65536', sql_bitor(sql_bitand('review', QUIZ_REVIEW_FEEDBACK & QUIZ_REVIEW_OPEN) . ' * 16384', sql_bitand('review', QUIZ_REVIEW_FEEDBACK & QUIZ_REVIEW_CLOSED) . ' * 4096'))));
// Same adjustment to the defaults for new quizzes.
$result = $result && set_config('quiz_review', $CFG->quiz_review & ~QUIZ_REVIEW_OVERALLFEEDBACK | ($CFG->quiz_review & QUIZ_REVIEW_FEEDBACK & QUIZ_REVIEW_IMMEDIATELY) << 16 | ($CFG->quiz_review & QUIZ_REVIEW_FEEDBACK & QUIZ_REVIEW_OPEN) << 14 | ($CFG->quiz_review & QUIZ_REVIEW_FEEDBACK & QUIZ_REVIEW_CLOSED) << 12);
}
//===== 1.9.0 upgrade line ======//
return $result;
}
示例7: removefriend_submit
function removefriend_submit(Pieform $form, $values)
{
global $USER, $SESSION, $id;
$loggedinid = $USER->get('id');
$user = get_record('usr', 'id', $id);
// friend db record
$f = new StdClass();
$f->ctime = db_format_timestamp(time());
// notification info
$n = new StdClass();
$n->url = profile_url($USER, false);
$n->users = array($user->id);
$lang = get_user_language($user->id);
$displayname = display_name($USER, $user);
$n->urltext = $displayname;
delete_records_select('usr_friend', '(usr1 = ? AND usr2 = ?) OR (usr2 = ? AND usr1 = ?)', array($id, $loggedinid, $id, $loggedinid));
$n->subject = get_string_from_language($lang, 'removedfromfriendslistsubject', 'group');
if (isset($values['reason']) && !empty($values['reason'])) {
$n->message = get_string_from_language($lang, 'removedfromfriendslistmessage', 'group', $displayname) . $values['reason'];
} else {
$n->message = get_string_from_language($lang, 'removedfromfriendslistmessage', 'group', $displayname);
}
require_once 'activity.php';
activity_occurred('maharamessage', $n);
handle_event('removefriend', array('user' => $loggedinid, 'friend' => $id));
$SESSION->add_ok_msg(get_string('friendformremovesuccess', 'group', display_name($id)));
$offset = param_integer('offset', 0);
switch (param_alpha('returnto', 'myfriends')) {
case 'find':
$goto = 'user/find.php';
break;
case 'view':
$goto = profile_url($user, false);
break;
default:
$goto = 'user/myfriends.php';
break;
}
$goto .= strpos($goto, '?') ? '&offset=' . $offset : '?offset=' . $offset;
$goto = get_config('wwwroot') . $goto;
redirect($goto);
}
示例8: xmldb_block_php_report_upgrade
/**
* ELIS(TM): Enterprise Learning Intelligence Suite
* Copyright (C) 2008-2012 Remote Learner.net Inc http://www.remote-learner.net
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package elis
* @subpackage php_reports
* @author Remote-Learner.net Inc
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2008-2012 Remote Learner.net Inc http://www.remote-learner.net
*
*/
function xmldb_block_php_report_upgrade($oldversion = 0)
{
global $CFG, $THEME, $db;
$result = true;
if ($result && $oldversion < 2011040600) {
/// Define table php_report_schedule to be created
$table = new XMLDBTable('php_report_schedule');
/// Adding fields to table php_report_schedule
$table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$table->addFieldInfo('report', XMLDB_TYPE_CHAR, '63', null, XMLDB_NOTNULL, null, null, null, null);
$table->addFieldInfo('config', XMLDB_TYPE_TEXT, 'medium', null, XMLDB_NOTNULL, null, null, null, null);
/// Adding keys to table php_report_schedule
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
/// Adding indexes to table php_report_schedule
$table->addIndexInfo('report_idx', XMLDB_INDEX_NOTUNIQUE, array('report'));
/// Launch create table for php_report_schedule
$result = $result && create_table($table);
/// Define field userid to be added to php_report_schedule
$table = new XMLDBTable('php_report_schedule');
$field = new XMLDBField('userid');
$field->setAttributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null, 'id');
/// Launch add field userid
$result = $result && add_field($table, $field);
/// Define index userid_idx (not unique) to be added to php_report_schedule
$table = new XMLDBTable('php_report_schedule');
$index = new XMLDBIndex('userid_idx');
$index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('userid'));
/// Launch add index userid_idx
$result = $result && add_index($table, $index);
}
if ($result && $oldversion < 2011042900) {
$query = "name " . sql_ilike() . " 'php_report%'";
$result = $result && delete_records_select('user_preferences', $query);
}
return $result;
}
示例9: main_upgrade
//.........这里部分代码省略.........
modify_database('', "ALTER TABLE `prefix_course` ADD UNIQUE KEY category_sortorder(category,sortorder)");
execute_sql("ALTER TABLE `{$CFG->prefix}user` DROP INDEX {$CFG->prefix}user_deleted_idx;", false);
execute_sql("ALTER TABLE `{$CFG->prefix}user` DROP INDEX {$CFG->prefix}user_confirmed_idx;", false);
execute_sql("ALTER TABLE `{$CFG->prefix}user` DROP INDEX {$CFG->prefix}user_firstname_idx;", false);
execute_sql("ALTER TABLE `{$CFG->prefix}user` DROP INDEX {$CFG->prefix}user_lastname_idx;", false);
execute_sql("ALTER TABLE `{$CFG->prefix}user` DROP INDEX {$CFG->prefix}user_city_idx;", false);
execute_sql("ALTER TABLE `{$CFG->prefix}user` DROP INDEX {$CFG->prefix}user_country_idx;", false);
execute_sql("ALTER TABLE `{$CFG->prefix}user` DROP INDEX {$CFG->prefix}user_lastaccess_idx;", false);
modify_database("", "ALTER TABLE `prefix_user` ADD INDEX prefix_user_deleted_idx (deleted)");
modify_database("", "ALTER TABLE `prefix_user` ADD INDEX prefix_user_confirmed_idx (confirmed)");
modify_database("", "ALTER TABLE `prefix_user` ADD INDEX prefix_user_firstname_idx (firstname)");
modify_database("", "ALTER TABLE `prefix_user` ADD INDEX prefix_user_lastname_idx (lastname)");
modify_database("", "ALTER TABLE `prefix_user` ADD INDEX prefix_user_city_idx (city)");
modify_database("", "ALTER TABLE `prefix_user` ADD INDEX prefix_user_country_idx (country)");
modify_database("", "ALTER TABLE `prefix_user` ADD INDEX prefix_user_lastaccess_idx (lastaccess)");
}
if ($oldversion < 2004111700) {
// one more index for email (for sorting)
execute_sql("ALTER TABLE `{$CFG->prefix}user` DROP INDEX {$CFG->prefix}user_email_idx;", false);
modify_database('', 'ALTER TABLE `prefix_user` ADD INDEX prefix_user_email_idx (email);');
}
if ($oldversion < 2004112200) {
// new 'enrol' field for enrolment tables
table_column('user_students', '', 'enrol', 'varchar', '20', '', '', 'not null');
table_column('user_teachers', '', 'enrol', 'varchar', '20', '', '', 'not null');
execute_sql("ALTER TABLE `{$CFG->prefix}user_students` ADD INDEX enrol (enrol);");
execute_sql("ALTER TABLE `{$CFG->prefix}user_teachers` ADD INDEX enrol (enrol);");
}
if ($oldversion < 2004112400) {
/// Delete duplicate enrolments
/// and then tell the database course,userid is a unique combination
if ($users = get_records_select("user_students", "userid > 0 GROUP BY course, userid " . "HAVING count(*) > 1", "", "max(id) as id, userid, course ,count(*)")) {
foreach ($users as $user) {
delete_records_select("user_students", "userid = '{$user->userid}' " . "AND course = '{$user->course}' AND id <> '{$user->id}'");
}
}
flush();
modify_database('', 'ALTER TABLE prefix_user_students DROP INDEX courseuserid;');
modify_database('', 'ALTER TABLE prefix_user_students ADD UNIQUE INDEX courseuserid(course,userid);');
/// Delete duplicate teacher enrolments
/// and then tell the database course,userid is a unique combination
if ($users = get_records_select("user_teachers", "userid > 0 GROUP BY course, userid " . "HAVING count(*) > 1", "", "max(id) as id, userid, course ,count(*)")) {
foreach ($users as $user) {
delete_records_select("user_teachers", "userid = '{$user->userid}' " . "AND course = '{$user->course}' AND id <> '{$user->id}'");
}
}
flush();
modify_database('', 'ALTER TABLE prefix_user_teachers DROP INDEX courseuserid;');
modify_database('', 'ALTER TABLE prefix_user_teachers ADD UNIQUE INDEX courseuserid(course,userid);');
}
if ($oldversion < 2004112900) {
table_column('user', '', 'policyagreed', 'integer', '1', 'unsigned', '0', 'not null', 'confirmed');
}
if ($oldversion < 2004121400) {
table_column('groups', '', 'password', 'varchar', '50', '', '', 'not null', 'description');
}
if ($oldversion < 2004121500) {
modify_database('', "CREATE TABLE prefix_dst_preset (\n id int(10) NOT NULL auto_increment,\n name char(48) default '' NOT NULL,\n \n apply_offset tinyint(3) default '0' NOT NULL,\n \n activate_index tinyint(1) default '1' NOT NULL,\n activate_day tinyint(1) default '1' NOT NULL,\n activate_month tinyint(2) default '1' NOT NULL,\n activate_time char(5) default '03:00' NOT NULL,\n \n deactivate_index tinyint(1) default '1' NOT NULL,\n deactivate_day tinyint(1) default '1' NOT NULL,\n deactivate_month tinyint(2) default '2' NOT NULL,\n deactivate_time char(5) default '03:00' NOT NULL,\n \n last_change int(10) default '0' NOT NULL,\n next_change int(10) default '0' NOT NULL,\n current_offset tinyint(3) default '0' NOT NULL,\n \n PRIMARY KEY (id))");
}
if ($oldversion < 2004122800) {
execute_sql("DROP TABLE {$CFG->prefix}message", false);
execute_sql("DROP TABLE {$CFG->prefix}message_read", false);
execute_sql("DROP TABLE {$CFG->prefix}message_contacts", false);
modify_database('', "CREATE TABLE `prefix_message` (\n `id` int(10) unsigned NOT NULL auto_increment,\n `useridfrom` int(10) NOT NULL default '0',\n `useridto` int(10) NOT NULL default '0',\n `message` text NOT NULL,\n `timecreated` int(10) NOT NULL default '0',\n `messagetype` varchar(50) NOT NULL default '',\n PRIMARY KEY (`id`),\n KEY `useridfrom` (`useridfrom`),\n KEY `useridto` (`useridto`)\n ) TYPE=MyISAM COMMENT='Stores all unread messages';");
modify_database('', "CREATE TABLE `prefix_message_read` (\n `id` int(10) unsigned NOT NULL auto_increment,\n `useridfrom` int(10) NOT NULL default '0',\n `useridto` int(10) NOT NULL default '0',\n `message` text NOT NULL,\n `timecreated` int(10) NOT NULL default '0',\n `timeread` int(10) NOT NULL default '0',\n `messagetype` varchar(50) NOT NULL default '',\n `mailed` tinyint(1) NOT NULL default '0',\n PRIMARY KEY (`id`),\n KEY `useridfrom` (`useridfrom`),\n KEY `useridto` (`useridto`)\n ) TYPE=MyISAM COMMENT='Stores all messages that have been read';");
modify_database('', "CREATE TABLE `prefix_message_contacts` (\n `id` int(10) unsigned NOT NULL auto_increment,\n `userid` int(10) unsigned NOT NULL default '0',\n `contactid` int(10) unsigned NOT NULL default '0',\n `blocked` tinyint(1) unsigned NOT NULL default '0',\n PRIMARY KEY (`id`),\n UNIQUE KEY `usercontact` (`userid`,`contactid`)\n ) TYPE=MyISAM COMMENT='Maintains lists of relationships between users';");
示例10: cron_daily
/**
* Daily cron. It executes at settlement time (default is 00:05).
*
* @access private
*/
function cron_daily()
{
global $CFG, $SITE;
require_once $CFG->dirroot . '/enrol/authorize/authorizenetlib.php';
$oneday = 86400;
$timenow = time();
$onepass = $timenow - $oneday;
$settlementtime = authorize_getsettletime($timenow);
$timediff30 = $settlementtime - 30 * $oneday;
// Delete orders that no transaction was made.
$select = "(status='" . AN_STATUS_NONE . "') AND (timecreated<'{$timediff30}')";
delete_records_select('enrol_authorize', $select);
// Pending orders are expired with in 30 days.
$select = "(status='" . AN_STATUS_AUTH . "') AND (timecreated<'{$timediff30}')";
execute_sql("UPDATE {$CFG->prefix}enrol_authorize SET status='" . AN_STATUS_EXPIRE . "' WHERE {$select}", false);
// Delete expired orders 60 days later.
$timediff60 = $settlementtime - 60 * $oneday;
$select = "(status='" . AN_STATUS_EXPIRE . "') AND (timecreated<'{$timediff60}')";
delete_records_select('enrol_authorize', $select);
// XXX TODO SEND EMAIL to 'enrol/authorize:uploadcsv'
// get_users_by_capability() does not handling user level resolving
// After user resolving, get_admin() to get_users_by_capability()
$adminuser = get_admin();
$select = "status IN(" . AN_STATUS_UNDERREVIEW . "," . AN_STATUS_APPROVEDREVIEW . ") AND (timecreated<'{$onepass}') AND (timecreated>'{$timediff60}')";
$count = count_records_select('enrol_authorize', $select);
if ($count) {
$a = new stdClass();
$a->count = $count;
$a->course = $SITE->shortname;
$subject = get_string('pendingechecksubject', 'enrol_authorize', $a);
$a = new stdClass();
$a->count = $count;
$a->url = $CFG->wwwroot . '/enrol/authorize/uploadcsv.php';
$message = get_string('pendingecheckemail', 'enrol_authorize', $a);
@email_to_user($adminuser, $adminuser, $subject, $message);
}
// Daily warning email for pending orders expiring.
if (empty($CFG->an_emailexpired)) {
return;
// not enabled
}
// Pending orders count will be expired.
$timediffem = $settlementtime - (30 - intval($CFG->an_emailexpired)) * $oneday;
$select = "(status='" . AN_STATUS_AUTH . "') AND (timecreated<'{$timediffem}') AND (timecreated>'{$timediff30}')";
$count = count_records_select('enrol_authorize', $select);
if (!$count) {
return;
}
// Email to admin
$a = new stdClass();
$a->pending = $count;
$a->days = $CFG->an_emailexpired;
$a->course = $SITE->shortname;
$subject = get_string('pendingorderssubject', 'enrol_authorize', $a);
$a = new stdClass();
$a->pending = $count;
$a->days = $CFG->an_emailexpired;
$a->course = $SITE->fullname;
$a->enrolurl = "{$CFG->wwwroot}/{$CFG->admin}/enrol_config.php?enrol=authorize";
$a->url = $CFG->wwwroot . '/enrol/authorize/index.php?status=' . AN_STATUS_AUTH;
$message = get_string('pendingordersemail', 'enrol_authorize', $a);
email_to_user($adminuser, $adminuser, $subject, $message);
// Email to teachers
if (empty($CFG->an_emailexpiredteacher)) {
return;
// email feature disabled for teachers.
}
$sorttype = empty($CFG->an_sorttype) ? 'ttl' : $CFG->an_sorttype;
$sql = "SELECT e.courseid, e.currency, c.fullname, c.shortname,\n COUNT(e.courseid) AS cnt, SUM(e.amount) as ttl\n FROM {$CFG->prefix}enrol_authorize e\n INNER JOIN {$CFG->prefix}course c ON c.id = e.courseid\n WHERE (e.status = " . AN_STATUS_AUTH . ")\n AND (e.timecreated < {$timediffem})\n AND (e.timecreated > {$timediff30})\n GROUP BY e.courseid\n ORDER BY {$sorttype} DESC";
for ($rs = get_recordset_sql($sql); $courseinfo = rs_fetch_next_record($rs);) {
$lastcourse = $courseinfo->courseid;
$context = get_context_instance(CONTEXT_COURSE, $lastcourse);
if ($paymentmanagers = get_users_by_capability($context, 'enrol/authorize:managepayments')) {
$a = new stdClass();
$a->course = $courseinfo->shortname;
$a->pending = $courseinfo->cnt;
$a->days = $CFG->an_emailexpired;
$subject = get_string('pendingorderssubject', 'enrol_authorize', $a);
$a = new stdClass();
$a->course = $courseinfo->fullname;
$a->pending = $courseinfo->cnt;
$a->currency = $courseinfo->currency;
$a->sumcost = $courseinfo->ttl;
$a->days = $CFG->an_emailexpired;
$a->url = $CFG->wwwroot . '/enrol/authorize/index.php?course=' . $lastcourse . '&status=' . AN_STATUS_AUTH;
$message = get_string('pendingordersemailteacher', 'enrol_authorize', $a);
foreach ($paymentmanagers as $paymentmanager) {
email_to_user($paymentmanager, $adminuser, $subject, $message);
}
}
}
rs_close($rs);
}
示例11: xmldb_core_upgrade
//.........这里部分代码省略.........
create_table($table);
// new table collection_view
$table = new XMLDBTable('collection_view');
$table->addFieldInfo('view', XMLDB_TYPE_INTEGER, 10, false, XMLDB_NOTNULL);
$table->addFieldInfo('collection', XMLDB_TYPE_INTEGER, 10, false, XMLDB_NOTNULL);
$table->addFieldInfo('displayorder', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL);
$table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('view'));
$table->addKeyInfo('viewfk', XMLDB_KEY_FOREIGN, array('view'), 'view', array('id'));
$table->addKeyInfo('collectionfk', XMLDB_KEY_FOREIGN, array('collection'), 'collection', array('id'));
create_table($table);
// Drop unique constraint on token column of view_access
$table = new XMLDBTable('view_access');
$index = new XMLDBIndex('tokenuk');
$index->setAttributes(XMLDB_INDEX_UNIQUE, array('token'));
drop_index($table, $index);
$index = new XMLDBIndex('tokenix');
$index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('token'));
add_index($table, $index);
}
if ($oldversion < 2010081001) {
if ($data = check_upgrades('artefact.plans')) {
upgrade_plugin($data);
}
if ($data = check_upgrades('blocktype.plans/plans')) {
upgrade_plugin($data);
}
}
if ($oldversion < 2010081100) {
if ($data = check_upgrades('blocktype.navigation')) {
upgrade_plugin($data);
}
}
if ($oldversion < 2010082000) {
delete_records_select('config', "field IN ('usersrank', 'groupsrank', 'viewsrank')");
}
if ($oldversion < 2010091300) {
// Cron job missing from installs post 2010041900
if (!record_exists('cron', 'callfunction', 'cron_check_for_updates')) {
$cron = new StdClass();
$cron->callfunction = 'cron_check_for_updates';
$cron->minute = rand(0, 59);
$cron->hour = rand(0, 23);
$cron->day = '*';
$cron->month = '*';
$cron->dayofweek = '*';
insert_record('cron', $cron);
}
}
if ($oldversion < 2010091500) {
// Previous version of 2010040800 upgrade created the submittedtime
// column not null (see bug #638550)
$table = new XMLDBTable('view');
$field = new XMLDBField('submittedtime');
$field->setAttributes(XMLDB_TYPE_DATETIME, null, null);
change_field_notnull($table, $field);
// Our crappy db is full of redundant data (submittedtime depends on
// submittedhost or submittedgroup) so it's easy to correct this.
execute_sql("\n UPDATE {view} SET submittedtime = NULL\n WHERE submittedtime IS NOT NULL AND submittedgroup IS NULL AND submittedhost IS NULL");
}
if ($oldversion < 2010100702) {
// Add general notification cleanup cron
if (!record_exists('cron', 'callfunction', 'cron_clean_internal_activity_notifications')) {
$cron = new StdClass();
$cron->callfunction = 'cron_clean_internal_activity_notifications';
$cron->minute = 45;
$cron->hour = 22;
示例12: turnitintool_delete_records_select
/**
* Abstracted version of delete_records_select() to work with Moodle 1.8 through 2.0
*
* @param string $table The Database Table
* @param string $select the select SQL query
* @return boolean
*/
function turnitintool_delete_records_select($table, $select = '', $params = null)
{
global $DB;
if (is_callable(array($DB, 'delete_records_select'))) {
return $DB->delete_records_select($table, $select, $params);
} else {
return delete_records_select($table, $select);
}
}
示例13: bulk_delete
public static function bulk_delete($artefactids)
{
if (empty($artefactids)) {
return;
}
$idstr = join(',', array_map('intval', $artefactids));
db_begin();
delete_records_select('artefact_internal_profile_email', 'artefact IN (' . $idstr . ')');
parent::bulk_delete($artefactids);
db_commit();
}
示例14: delete_question
/**
* Deletes a question from the question-type specific tables
*
* @return boolean Success/Failure
* @param object $question The question being deleted
*/
function delete_question($questionid)
{
global $CFG;
$success = true;
$extra_question_fields = $this->extra_question_fields();
if (is_array($extra_question_fields)) {
$question_extension_table = array_shift($extra_question_fields);
$success = $success && delete_records($question_extension_table, $this->questionid_column_name(), $questionid);
}
$extra_answer_fields = $this->extra_answer_fields();
if (is_array($extra_answer_fields)) {
$answer_extension_table = array_shift($extra_answer_fields);
$success = $success && delete_records_select($answer_extension_table, "answerid IN (SELECT qa.id FROM {$CFG->prefix}question_answers qa WHERE qa.question = {$questionid})");
}
$success = $success && delete_records('question_answers', 'question', $questionid);
return $success;
}
示例15: quiz_reset_userdata
/**
* Actual implementation of the rest coures functionality, delete all the
* quiz attempts for course $data->courseid, if $data->reset_quiz_attempts is
* set and true.
*
* Also, move the quiz open and close dates, if the course start date is changing.
* @param $data the data submitted from the reset course.
* @return array status array
*/
function quiz_reset_userdata($data)
{
global $CFG, $QTYPES;
// TODO: this should use the delete_attempt($attempt->uniqueid) function in questionlib.php
// require_once($CFG->libdir.'/questionlib.php');
$componentstr = get_string('modulenameplural', 'quiz');
$status = array();
/// Delete attempts.
if (!empty($data->reset_quiz_attempts)) {
$stateslistsql = "SELECT s.id\n FROM {$CFG->prefix}question_states s\n INNER JOIN {$CFG->prefix}quiz_attempts qza ON s.attempt=qza.uniqueid\n INNER JOIN {$CFG->prefix}quiz q ON qza.quiz=q.id\n WHERE q.course={$data->courseid}";
$attemptssql = "SELECT a.uniqueid\n FROM {$CFG->prefix}quiz_attempts a, {$CFG->prefix}quiz q\n WHERE q.course={$data->courseid} AND a.quiz=q.id";
$quizessql = "SELECT q.id\n FROM {$CFG->prefix}quiz q\n WHERE q.course={$data->courseid}";
if ($states = get_records_sql($stateslistsql)) {
//TODO: not sure if this works
$stateslist = implode(',', array_keys($states));
foreach ($QTYPES as $qtype) {
$qtype->delete_states($stateslist);
}
}
delete_records_select('question_states', "attempt IN ({$attemptssql})");
delete_records_select('question_sessions', "attemptid IN ({$attemptssql})");
delete_records_select('question_attempts', "id IN ({$attemptssql})");
// remove all grades from gradebook
if (empty($data->reset_gradebook_grades)) {
quiz_reset_gradebook($data->courseid);
}
delete_records_select('quiz_grades', "quiz IN ({$quizessql})");
$status[] = array('component' => $componentstr, 'item' => get_string('gradesdeleted', 'quiz'), 'error' => false);
delete_records_select('quiz_attempts', "quiz IN ({$quizessql})");
$status[] = array('component' => $componentstr, 'item' => get_string('attemptsdeleted', 'quiz'), 'error' => false);
}
/// updating dates - shift may be negative too
if ($data->timeshift) {
shift_course_mod_dates('quiz', array('timeopen', 'timeclose'), $data->timeshift, $data->courseid);
$status[] = array('component' => $componentstr, 'item' => get_string('openclosedatesupdated', 'quiz'), 'error' => false);
}
return $status;
}