本文整理汇总了PHP中get_records函数的典型用法代码示例。如果您正苦于以下问题:PHP get_records函数的具体用法?PHP get_records怎么用?PHP get_records使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_records函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: specialization
/**
* Make sure that several settings are set
* for the rest of the class to use.
*
* Items that are set:
* course
* title
* config->taskorder
* config->display
* baseurl
* tasks
*
* @uses $CFG
* @return void
**/
function specialization()
{
global $CFG, $COURSE;
// Set the course
$this->course = $COURSE;
// Set title
if (isset($this->config->title)) {
$this->title = format_text($this->config->title, FORMAT_HTML);
} else {
if (isset($CFG->block_task_list_title)) {
$this->title = format_text($CFG->block_task_list_title, FORMAT_HTML);
}
}
if (!isset($this->config->taskorder)) {
$this->config->taskorder = '';
}
if (!isset($this->config->categorywordwrap)) {
$this->config->categorywordwrap = 45;
}
if (!isset($this->config->display) or $this->course->format != 'page') {
$this->config->display = 'normal';
}
// Get the tasks
if (!($this->tasks = get_records('block_task_list', 'instanceid', $this->instance->id))) {
$this->tasks = array();
}
}
示例2: question_cwqpfs_to_update
function question_cwqpfs_to_update($categories = null)
{
global $CFG;
$tofix = array();
$result = true;
//any cats with questions picking from subcats?
if (!($cwqpfs = get_records_sql_menu("SELECT DISTINCT qc.id, 1 " . "FROM {$CFG->prefix}question q, {$CFG->prefix}question_categories qc " . "WHERE q.qtype='random' AND qc.id = q.category AND " . sql_compare_text('q.questiontext') . " = '1'"))) {
return array();
} else {
if ($categories === null) {
$categories = get_records('question_categories');
}
$categorychildparents = array();
foreach ($categories as $id => $category) {
$categorychildparents[$category->course][$id] = $category->parent;
}
foreach ($categories as $id => $category) {
if (FALSE !== array_key_exists($category->parent, $categorychildparents[$category->course])) {
//this is not a top level cat
continue;
//go to next category
} else {
$tofix += question_cwqpfs_check_children($id, $categories, $categorychildparents[$category->course], $cwqpfs);
}
}
}
return $tofix;
}
示例3: choice_get_response_data
function choice_get_response_data($choice, $cm, $groupmode)
{
global $CFG, $USER;
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
/// Get the current group
if ($groupmode > 0) {
$currentgroup = groups_get_activity_group($cm);
} else {
$currentgroup = 0;
}
/// Initialise the returned array, which is a matrix: $allresponses[responseid][userid] = responseobject
$allresponses = array();
/// First get all the users who have access here
/// To start with we assume they are all "unanswered" then move them later
$allresponses[0] = get_users_by_capability($context, 'mod/choice:choose', 'u.id, u.picture, u.firstname, u.lastname, u.idnumber', 'u.firstname ASC', '', '', $currentgroup, '', false, true);
/// Get all the recorded responses for this choice
$rawresponses = get_records('choice_answers', 'choiceid', $choice->id);
/// Use the responses to move users into the correct column
if ($rawresponses) {
foreach ($rawresponses as $response) {
if (isset($allresponses[0][$response->userid])) {
// This person is enrolled and in correct group
$allresponses[0][$response->userid]->timemodified = $response->timemodified;
$allresponses[$response->optionid][$response->userid] = clone $allresponses[0][$response->userid];
unset($allresponses[0][$response->userid]);
// Remove from unanswered column
}
}
}
return $allresponses;
}
示例4: webquest_upgrade
function webquest_upgrade($oldversion)
{
/// This function does anything necessary to upgrade
/// older versions to match current functionality
$status = true;
global $CFG;
if ($oldversion < 2007081222) {
require_once $CFG->dirroot . '/backup/lib.php';
//make the change into each course
$courses = get_records("course");
foreach ($courses as $course) {
$newdir = "{$course->id}/{$CFG->moddata}/webquest";
if (make_upload_directory($newdir)) {
$olddir = "{$CFG->dataroot}/{$course->id}/{$CFG->moddata}/webquest/submissions";
//chec k if the old directory exists
if (is_dir($olddir)) {
$status = backup_copy_file($olddir, $CFG->dataroot . "/" . $newdir);
}
if ($status) {
fulldelete($olddir);
}
}
}
}
return $status;
}
示例5: print_filter
function print_filter(&$mform)
{
global $CFG;
$filter_categories = optional_param('filter_categories', 0, PARAM_INT);
$reportclassname = 'report_' . $this->report->type;
$reportclass = new $reportclassname($this->report);
if ($this->report->type != 'sql') {
$components = cr_unserialize($this->report->components);
$conditions = $components['conditions'];
$categorieslist = $reportclass->elements_by_conditions($conditions);
} else {
$categorieslist = array_keys(get_records('course'));
}
$courseoptions = array();
$courseoptions[0] = get_string('choose');
if (!empty($categorieslist)) {
$categories = get_records_select('course_categories', 'id in (' . implode(',', $categorieslist) . ')');
foreach ($categories as $c) {
$courseoptions[$c->id] = format_string($c->name);
}
}
$select =& $mform->addElement('select', 'filter_categories', get_string('category'), $courseoptions);
$select->setMultiple(true);
$mform->setType('filter_categories', PARAM_INT);
}
示例6: scheduler_backup_one_mod
/**
*
*/
function scheduler_backup_one_mod($bf, $preferences, $scheduler)
{
global $CFG;
if (is_numeric($scheduler)) {
$scheduler = get_record('scheduler', 'id', $scheduler);
}
$status = true;
//Start mod
$status = $status && fwrite($bf, start_tag('MOD', 3, true));
//Print scheduler data
fwrite($bf, full_tag('ID', 4, false, $scheduler->id));
fwrite($bf, full_tag('MODTYPE', 4, false, 'scheduler'));
fwrite($bf, full_tag('NAME', 4, false, $scheduler->name));
fwrite($bf, full_tag('DESCRIPTION', 4, false, $scheduler->description));
fwrite($bf, full_tag('TEACHER', 4, false, $scheduler->teacher));
fwrite($bf, full_tag('SCALE', 4, false, $scheduler->scale));
fwrite($bf, full_tag('STAFFROLENAME', 4, false, $scheduler->staffrolename));
fwrite($bf, full_tag('SCHEDULERMODE', 4, false, $scheduler->schedulermode));
fwrite($bf, full_tag('REUSEGUARDTIME', 4, false, $scheduler->reuseguardtime));
fwrite($bf, full_tag('DEFAULTSLOTDURATION', 4, false, $scheduler->defaultslotduration));
fwrite($bf, full_tag('ALLOWNOTIFICATIONS', 4, false, $scheduler->allownotifications));
fwrite($bf, full_tag('TIMEMODIFIED', 4, false, $scheduler->timemodified));
//if we've selected to backup users info, then execute backup_scheduler_slots and appointments
if ($preferences->mods['scheduler']->userinfo) {
$scheduler_slots = get_records('scheduler_slots', 'schedulerid', $scheduler->id, 'id');
$status = $status && backup_scheduler_slots($bf, $preferences, $scheduler->id, $scheduler_slots);
$status = $status && backup_scheduler_appointments($bf, $preferences, $scheduler_slots);
}
//End mod
$status = $status && fwrite($bf, end_tag('MOD', 3, true));
return $status;
}
示例7: remote_connect
/**
* Create connection to an RQP server of required type if it does not already exist
*
* If the global array $remote_connections does not already have an entry for this
* server type then it randomly goes through the existing servers and tries to connect
* using rqp_connect(). The connection is then added to the $remote_connections array.
* If the function fails to connect to any server it returns false.
* @param string $typeid The type of the RQP server
* @return boolean Indicates success or failure
*
* @todo flag dead servers
*/
function remote_connect($typeid)
{
global $remote_connections;
if (!array_key_exists($typeid, $remote_connections)) {
// get the available servers
if (!($servers = get_records('question_rqp_servers', 'typeid', $typeid))) {
// we don't have a server for this question type
return false;
}
// put them in a random order
shuffle($servers);
// go through them and try to connect to each until we are successful
foreach ($servers as $server) {
if ($remote_connections[$typeid] = rqp_connect($server->url)) {
break;
// we have a connection
} else {
// We have a dead server here, should somehow flag that
}
}
}
// check that we did get a connection
if (!$remote_connections[$typeid]) {
unset($remote_connections[$typeid]);
return false;
}
return true;
}
示例8: validation
function validation($data, $files)
{
global $db, $CFG;
$errors = parent::validation($data, $files);
if (!in_array($data['operator'], $this->allowedops)) {
$errors['operator'] = get_string('error_operator', 'block_configurable_reports');
}
$columns = $db->MetaColumns($CFG->prefix . 'user');
$usercolumns = array();
foreach ($columns as $c) {
$usercolumns[$c->name] = $c->name;
}
if ($profile = get_records('user_info_field')) {
foreach ($profile as $p) {
$usercolumns['profile_' . $p->shortname] = 'profile_' . $p->shortname;
}
}
if (!in_array($data['field'], $usercolumns)) {
$errors['field'] = get_string('error_field', 'block_configurable_reports');
}
if (!is_numeric($data['value']) && preg_match('/^(<|>)[^(<|>)]/i', $data['operator'])) {
$errors['value'] = get_string('error_value_expected_integer', 'block_configurable_reports');
}
return $errors;
}
示例9: backup_slideshow_captions
function backup_slideshow_captions($bf, $preferences, $slideshow)
{
global $CFG;
$status = true;
$slideshow_captions = get_records("slideshow_captions", "slideshow", $slideshow->instance);
//If there is captions
if ($slideshow_captions) {
//Write start tag
$status = fwrite($bf, start_tag("CAPTIONS", 4, true));
//Iterate over each caption
foreach ($slideshow_captions as $sli_cap) {
//Start caption
$status = fwrite($bf, start_tag("CAPTION", 5, true));
//Print caption contents
fwrite($bf, full_tag("ID", 6, false, $sli_cap->id));
fwrite($bf, full_tag("SLIDESHOW", 6, false, $sli_cap->slideshow));
fwrite($bf, full_tag("IMAGE", 6, false, $sli_cap->image));
fwrite($bf, full_tag("TITLE", 6, false, $sli_cap->title));
fwrite($bf, full_tag("CAPTION", 6, false, $sli_cap->caption));
//End submission
$status = fwrite($bf, end_tag("CAPTION", 5, true));
}
//Write end tag
$status = fwrite($bf, end_tag("CAPTIONS", 4, true));
}
return $status;
}
示例10: backup_chat_messages
function backup_chat_messages($bf, $preferences, $chat)
{
global $CFG;
$status = true;
$chat_messages = get_records("chat_messages", "chatid", $chat, "id");
//If there is messages
if ($chat_messages) {
//Write start tag
$status = fwrite($bf, start_tag("MESSAGES", 4, true));
//Iterate over each message
foreach ($chat_messages as $cha_mes) {
//Start message
$status = fwrite($bf, start_tag("MESSAGE", 5, true));
//Print message contents
fwrite($bf, full_tag("ID", 6, false, $cha_mes->id));
fwrite($bf, full_tag("USERID", 6, false, $cha_mes->userid));
fwrite($bf, full_tag("GROUPID", 6, false, $cha_mes->groupid));
fwrite($bf, full_tag("SYSTEM", 6, false, $cha_mes->system));
fwrite($bf, full_tag("MESSAGE_TEXT", 6, false, $cha_mes->message));
fwrite($bf, full_tag("TIMESTAMP", 6, false, $cha_mes->timestamp));
//End submission
$status = fwrite($bf, end_tag("MESSAGE", 5, true));
}
//Write end tag
$status = fwrite($bf, end_tag("MESSAGES", 4, true));
}
return $status;
}
示例11: backup_adobeconnect_meeting_groups
function backup_adobeconnect_meeting_groups($bf, $preferences, $adobeconnectid)
{
global $CFG;
// Set status to false because there must be at least one meeting instance
$status = false;
// Go through all of the meeting instances and backup each group's meeting
if ($meetgroups = get_records("adobeconnect_meeting_groups", 'instanceid', $adobeconnectid)) {
if ($meetgroups) {
//Write start tag
$status = fwrite($bf, start_tag("MEETINGGROUPS", 4, true));
//Iterate over each meeting instance
foreach ($meetgroups as $meetgroup) {
//Start of meeting group instance
$status = fwrite($bf, start_tag("MEETINGGROUP", 5, true));
fwrite($bf, full_tag("ID", 6, false, $meetgroup->id));
fwrite($bf, full_tag("INSTANCEID", 6, false, $meetgroup->instanceid));
fwrite($bf, full_tag("MEETINGSCOID", 6, false, $meetgroup->meetingscoid));
fwrite($bf, full_tag("GROUPID", 6, false, $meetgroup->groupid));
//End of meeting group instance
$status = fwrite($bf, end_tag("MEETINGGROUP", 5, true));
}
//Write end tag
$status = fwrite($bf, end_tag("MEETINGGROUPS", 4, true));
}
}
return $status;
}
示例12: backup_book_chapters
function backup_book_chapters($bf, $preferences, $book)
{
global $CFG;
$status = true;
//Print book's chapters
if ($chapters = get_records('book_chapters', 'bookid', $book->id, 'id')) {
//Write start tag
$status = fwrite($bf, start_tag('CHAPTERS', 4, true));
foreach ($chapters as $ch) {
//Start chapter
fwrite($bf, start_tag('CHAPTER', 5, true));
//Print chapter data
fwrite($bf, full_tag('ID', 6, false, $ch->id));
fwrite($bf, full_tag('PAGENUM', 6, false, $ch->pagenum));
fwrite($bf, full_tag('SUBCHAPTER', 6, false, $ch->subchapter));
fwrite($bf, full_tag('TITLE', 6, false, $ch->title));
fwrite($bf, full_tag('CONTENT', 6, false, $ch->content));
fwrite($bf, full_tag('HIDDEN', 6, false, $ch->hidden));
fwrite($bf, full_tag('TIMECREATED', 6, false, $ch->timecreated));
fwrite($bf, full_tag('TIMEMODIFIED', 6, false, $ch->timemodified));
fwrite($bf, full_tag('IMPORTSRC', 6, false, $ch->importsrc));
//End chapter
$status = fwrite($bf, end_tag('CHAPTER', 5, true));
}
//Write end tag
$status = fwrite($bf, end_tag('CHAPTERS', 4, true));
}
return $status;
}
示例13: backup_map_locations
function backup_map_locations($bf, $preferences, $map)
{
global $CFG;
$status = true;
$map_locations = get_records("map_locations", "mapid", $map, "id");
//If there is locations
if ($map_locations) {
//Write start tag
$status = fwrite($bf, start_tag("LOCATIONS", 4, true));
//Iterate over each answer
foreach ($map_locations as $map_location) {
//Start answer
$status = fwrite($bf, start_tag("LOCATION", 5, true));
//Print location contents
fwrite($bf, full_tag("ID", 6, false, $map_location->id));
fwrite($bf, full_tag("USERID", 6, false, $map_location->userid));
fwrite($bf, full_tag("TITLE", 6, false, $map_location->title));
fwrite($bf, full_tag("SHOWCODE", 6, false, $map_location->showcode));
fwrite($bf, full_tag("LATITUDE", 6, false, $map_location->latitude));
fwrite($bf, full_tag("LONGITUDE", 6, false, $map_location->longitude));
fwrite($bf, full_tag("ADDRESS", 6, false, $map_location->address));
fwrite($bf, full_tag("CITY", 6, false, $map_location->city));
fwrite($bf, full_tag("STATE", 6, false, $map_location->state));
fwrite($bf, full_tag("COUNTRY", 6, false, $map_location->country));
fwrite($bf, full_tag("TEXT", 6, false, $map_location->text));
fwrite($bf, full_tag("TIMEMODIFIED", 6, false, $map_location->timemodified));
//End answer
$status = fwrite($bf, end_tag("LOCATION", 5, true));
}
//Write end tag
$status = fwrite($bf, end_tag("LOCATIONS", 4, true));
}
return $status;
}
示例14: block_exabis_eportfolio_print_extcomments
function block_exabis_eportfolio_print_extcomments($itemid)
{
$stredit = get_string('edit');
$strdelete = get_string('delete');
$comments = get_records("block_exabeporitemcomm", "itemid", $itemid, 'timemodified DESC');
if (!$comments) {
return;
}
foreach ($comments as $comment) {
$user = get_record('user', 'id', $comment->userid);
echo '<table cellspacing="0" class="forumpost blogpost blog" width="100%">';
echo '<tr class="header"><td class="picture left">';
print_user_picture($comment->userid, SITEID, $user->picture);
echo '</td>';
echo '<td class="topic starter"><div class="author">';
$fullname = fullname($user, $comment->userid);
$by = new object();
$by->name = $fullname;
$by->date = userdate($comment->timemodified);
print_string('bynameondate', 'forum', $by);
echo '</div></td></tr>';
echo '<tr><td class="left side">';
echo '</td><td class="content">' . "\n";
echo format_text($comment->entry);
echo '</td></tr></table>' . "\n\n";
}
}
示例15: glossary_rss_feeds
function glossary_rss_feeds()
{
global $CFG;
$status = true;
//Check CFG->enablerssfeeds
if (empty($CFG->enablerssfeeds)) {
debugging("DISABLED (admin variables)");
//Check CFG->glossary_enablerssfeeds
} else {
if (empty($CFG->glossary_enablerssfeeds)) {
debugging("DISABLED (module configuration)");
//It's working so we start...
} else {
//Iterate over all glossaries
if ($glossaries = get_records("glossary")) {
foreach ($glossaries as $glossary) {
if (!empty($glossary->rsstype) && !empty($glossary->rssarticles) && $status) {
$filename = rss_file_name('glossary', $glossary);
// RSS file
//First let's make sure there is work to do by checking existing files
if (file_exists($filename)) {
if ($lastmodified = filemtime($filename)) {
if (!glossary_rss_newstuff($glossary, $lastmodified)) {
continue;
}
}
}
//Ignore hidden forums
if (!instance_is_visible('glossary', $glossary)) {
if (file_exists($filename)) {
@unlink($filename);
}
continue;
}
mtrace("Updating RSS feed for " . format_string($glossary->name, true) . ", ID: {$glossary->id}");
//Get the XML contents
$result = glossary_rss_feed($glossary);
//Save the XML contents to file
if (!empty($result)) {
$status = rss_save_file("glossary", $glossary, $result);
}
//Some debug...
if (debugging()) {
if (empty($result)) {
echo "ID: {$glossary->id}-> (empty) ";
} else {
if (!empty($status)) {
echo "ID: {$glossary->id}-> OK ";
} else {
echo "ID: {$glossary->id}-> FAIL ";
}
}
}
}
}
}
}
}
return $status;
}