当前位置: 首页>>代码示例>>PHP>>正文


PHP get_record_sql函数代码示例

本文整理汇总了PHP中get_record_sql函数的典型用法代码示例。如果您正苦于以下问题:PHP get_record_sql函数的具体用法?PHP get_record_sql怎么用?PHP get_record_sql使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_record_sql函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: forgotpass_submit

function forgotpass_submit(Pieform $form, $values)
{
    global $SESSION;
    try {
        if (!($user = get_record_sql('SELECT * FROM {usr} WHERE LOWER(email) = ?', array(strtolower($values['emailusername']))))) {
            if (!($user = get_record_sql('SELECT * FROM {usr} WHERE LOWER(username) = ?', array(strtolower($values['emailusername']))))) {
                die_info(get_string('forgotpassnosuchemailaddressorusername'));
            }
        }
        $pwrequest = new StdClass();
        $pwrequest->usr = $user->id;
        $pwrequest->expiry = db_format_timestamp(time() + 86400);
        $pwrequest->key = get_random_key();
        $sitename = get_config('sitename');
        $fullname = display_name($user);
        email_user($user, null, get_string('forgotusernamepasswordemailsubject', 'mahara', $sitename), get_string('forgotusernamepasswordemailmessagetext', 'mahara', $fullname, $sitename, $user->username, get_config('wwwroot') . 'forgotpass.php?key=' . $pwrequest->key, get_config('wwwroot') . 'contact.php', $sitename), get_string('forgotusernamepasswordemailmessagehtml', 'mahara', $fullname, $sitename, $user->username, get_config('wwwroot') . 'forgotpass.php?key=' . $pwrequest->key, get_config('wwwroot') . 'forgotpass.php?key=' . $pwrequest->key, get_config('wwwroot') . 'contact.php', $sitename));
        insert_record('usr_password_request', $pwrequest);
    } catch (SQLException $e) {
        die_info(get_string('forgotpassemailsendunsuccessful'));
    } catch (EmailDisabledException $e) {
        die_info(get_string('forgotpassemaildisabled'));
    } catch (EmailException $e) {
        die_info(get_string('forgotpassemailsendunsuccessful'));
    }
    // Add a marker in the session to say that the user has registered
    $_SESSION['pwchangerequested'] = true;
    redirect('/forgotpass.php');
}
开发者ID:richardmansfield,项目名称:richardms-mahara,代码行数:28,代码来源:forgotpass.php

示例2: definition_after_data

 function definition_after_data()
 {
     global $CFG;
     parent::definition_after_data();
     $mform =& $this->_form;
     if ($association_id = $mform->getElementValue('association_id')) {
         if ($record = get_record(CLSTCURTABLE, 'id', $association_id)) {
             //cluster stuff
             if ($cluster_record = get_record(CLSTTABLE, 'id', $record->clusterid)) {
                 foreach ($this->cluster_fields as $id => $display) {
                     $element =& $mform->getElement('cluster' . $id);
                     $element->setValue($cluster_record->{$id});
                 }
             }
             //curriculum stuff
             $curriculum_sql = "SELECT cur.idnumber,\n                                          cur.name,\n                                          cur.description,\n                                          cur.reqcredits,\n                                   COUNT(curcrs.id) as numcourses\n                                   FROM {$CFG->prefix}crlm_curriculum cur\n                                   LEFT JOIN {$CFG->prefix}crlm_curriculum_course curcrs\n                                   ON curcrs.curriculumid = cur.id\n                                   WHERE cur.id = {$record->curriculumid}";
             if ($curriculum_record = get_record_sql($curriculum_sql)) {
                 foreach ($this->curriculum_fields as $id => $display) {
                     $element =& $mform->getElement('curriculum' . $id);
                     $element->setValue($curriculum_record->{$id});
                 }
             }
             //association stuff
             $autoenrol_element =& $mform->getElement('autoenrol');
             $autoenrol_element->setValue($record->autoenrol);
         }
     }
 }
开发者ID:remotelearner,项目名称:elis.cm,代码行数:28,代码来源:clustercurriculumeditform.class.php

示例3: deletepost_submit

function deletepost_submit(Pieform $form, $values)
{
    global $SESSION, $USER;
    $objectionable = get_record_sql("SELECT fp.id\n            FROM {interaction_forum_post} fp\n            JOIN {objectionable} o\n            ON (o.objecttype = 'forum' AND o.objectid = fp.id)\n            WHERE fp.id = ?\n            AND o.resolvedby IS NULL\n            AND o.resolvedtime IS NULL", array($values['post']));
    if ($objectionable !== false) {
        // Trigger activity.
        $data = new StdClass();
        $data->postid = $values['post'];
        $data->message = '';
        $data->reporter = $USER->get('id');
        $data->ctime = time();
        $data->event = DELETE_OBJECTIONABLE_POST;
        activity_occurred('reportpost', $data, 'interaction', 'forum');
    }
    update_record('interaction_forum_post', array('deleted' => 1), array('id' => $values['post']));
    $SESSION->add_ok_msg(get_string('deletepostsuccess', 'interaction.forum'));
    // Figure out which parent record to redirect us to. If the parent record is deleted,
    // keep moving up the chain until you find one that's not deleted.
    $postrec = new stdClass();
    $postrec->parent = $values['parent'];
    do {
        $postrec = get_record('interaction_forum_post', 'id', $postrec->parent, null, null, null, null, 'id, deleted, parent');
    } while ($postrec && $postrec->deleted && $postrec->parent);
    $redirecturl = get_config('wwwroot') . 'interaction/forum/topic.php?id=' . $values['topic'];
    if ($postrec && $postrec->parent) {
        $redirecturl .= '&post=' . $postrec->id;
    }
    redirect($redirecturl);
}
开发者ID:rboyatt,项目名称:mahara,代码行数:29,代码来源:deletepost.php

示例4: grade_get_grade_letter

function grade_get_grade_letter($course, $grade)
{
    global $CFG;
    $sql = "SELECT id, letter FROM {$CFG->prefix}grade_letter WHERE courseid={$course} AND grade_high >= {$grade} AND grade_low <= {$grade}";
    $temp = get_record_sql($sql);
    return $temp;
}
开发者ID:veritech,项目名称:pare-project,代码行数:7,代码来源:lib.php

示例5: getRecordDataById

 public static function getRecordDataById($type, $id)
 {
     $sql = 'SELECT c.id, c.name, c.ctime, c.description, cv.view AS viewid, c.owner
     FROM {collectio}n c
     LEFT OUTER JOIN {collection_view} cv ON cv.collection = c.id
     WHERE id = ? ORDER BY cv.displayorder asc LIMIT 1;';
     $record = get_record_sql($sql, array($id));
     if (!$record) {
         return false;
     }
     $record->name = str_replace(array("\r\n", "\n", "\r"), ' ', strip_tags($record->name));
     $record->description = str_replace(array("\r\n", "\n", "\r"), ' ', strip_tags($record->description));
     //  Created by
     if (intval($record->owner) > 0) {
         $record->createdby = get_record('usr', 'id', $record->owner);
         $record->createdbyname = display_name($record->createdby);
     }
     // Get all views included in that collection
     $sql = 'SELECT v.id, v.title
     FROM {view} v
     LEFT OUTER JOIN {collection_view} cv ON cv.view = v.id
     WHERE cv.collection = ?';
     $views = recordset_to_array(get_recordset_sql($sql, array($id)));
     if ($views) {
         $record_views = array();
         foreach ($views as $view) {
             if (isset($view->id)) {
                 $record_views[$view->id] = $view->title;
             }
         }
         $record->views = $record_views;
     }
     return $record;
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:34,代码来源:ElasticsearchType_collection.php

示例6: definition_after_data

 function definition_after_data()
 {
     global $CFG;
     parent::definition_after_data();
     $mform =& $this->_form;
     if ($association_id = $mform->getElementValue('association_id')) {
         if ($record = get_record(CLSTTRKTABLE, 'id', $association_id)) {
             if ($cluster_record = get_record(CLSTTABLE, 'id', $record->clusterid)) {
                 foreach ($this->cluster_fields as $id => $display) {
                     $element =& $mform->getElement('cluster' . $id);
                     $element->setValue($cluster_record->{$id});
                 }
             }
             $track_sql = "SELECT trk.*,\n                                     cur.name AS parcur,\n                                     (SELECT COUNT(*)\n                                      FROM {$CFG->prefix}crlm_track_class\n                                      WHERE trackid = trk.id ) as class\n                              FROM {$CFG->prefix}crlm_track trk\n                              JOIN {$CFG->prefix}crlm_curriculum cur\n                              ON trk.curid = cur.id\n                              WHERE trk.defaulttrack = 0\n                              AND trk.id = {$record->trackid}";
             if ($track_record = get_record_sql($track_sql)) {
                 foreach ($this->track_fields as $id => $display) {
                     $element =& $mform->getElement('track' . $id);
                     $element->setValue($track_record->{$id});
                 }
             }
             $autoenrol_element =& $mform->getElement('autoenrol');
             $autoenrol_element->setValue($record->autoenrol);
         }
     }
 }
开发者ID:remotelearner,项目名称:elis.cm,代码行数:25,代码来源:clustertrackeditform.class.php

示例7: user_has_voted

/**
 *  Checks if the user has voted. Returns true if the user has voted
 *  or false if hasn't.
 *
 *  @param String $pagename
 *  @param integer $version
 *  @param integer $wikiid
 *  @return Boolean
 */
function user_has_voted($pagename, $version, $wikiid)
{
    global $CFG, $USER;
    $count = get_record_sql('SELECT count(*) AS has_votes
								FROM ' . $CFG->prefix . 'wiki_votes
								WHERE pagename=\'' . addslashes($pagename) . '\' AND version=' . $version . ' AND dfwiki=' . $wikiid . ' AND username=\'' . $USER->username . '\'');
    return $count->has_votes >= 1;
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:17,代码来源:dblib.php

示例8: get_record_sql

 static function get_record_sql($sql, $expectmultiple = false, $nolimit = false)
 {
     $result = get_record_sql($sql, $expectmultiple = false, $nolimit = false);
     if (!$result) {
         throw new forum_exception("Failed to get record via SQL");
     }
     return $result;
 }
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:8,代码来源:forum_utils.php

示例9: execute

 function execute($data, $row, $user, $courseid, $starttime = 0, $endtime = 0)
 {
     global $CFG;
     $sql = "SELECT COUNT('x') AS numviews\n              FROM {$CFG->prefix}course_modules cm                   \n                   JOIN {$CFG->prefix}log l     ON l.cmid = cm.id\n             WHERE cm.id = {$data->cmid} AND l.userid = {$row->id} AND l.action LIKE 'view%'\n          GROUP BY cm.id";
     if ($views = get_record_sql($sql)) {
         return $views->numviews;
     }
     return 0;
 }
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:9,代码来源:plugin.class.php

示例10: assign_smarty_vars

 public function assign_smarty_vars()
 {
     $user = $this->get('exporter')->get('user');
     $userid = $user->get('id');
     $updated = get_record_sql('select ' . db_format_tsfield('max(mtime)', 'mtime') . ' from {artefact} a join {artefact_installed_type} t on a.artefacttype = t.name where t.plugin = \'internal\'');
     $this->smarty->assign('artefacttype', 'internal');
     $this->smarty->assign('artefactplugin', 'internal');
     $this->smarty->assign('title', display_name($user, $user));
     $this->smarty->assign('updated', PluginExportLeap::format_rfc3339_date($updated->mtime));
     // If this ID is changed, you'll have to change it in author.tpl too
     $this->smarty->assign('id', 'portfolio:artefactinternal');
     $this->smarty->assign('leaptype', $this->get_leap_type());
     $persondata = array();
     $spacialdata = array();
     usort($this->artefacts, array($this, 'artefact_sort'));
     foreach ($this->artefacts as $a) {
         if (!($data = $this->data_mapping($a))) {
             if ($a->get('artefacttype') == 'introduction') {
                 $this->smarty->assign('contenttype', 'html');
                 $this->smarty->assign('content', clean_html($a->get('title')));
             }
             continue;
         }
         $value = $a->render_self(array());
         $value = $value['html'];
         // TODO fix this when we non-js stuff
         $data = array_merge(array('value' => $value, 'artefacttype' => $a->get('artefacttype'), 'artefactplugin' => 'internal'), $data);
         if (array_key_exists('spacial', $data)) {
             $spacialdata[] = (object) $data;
         } else {
             $label = get_string($a->get('artefacttype'), 'artefact.internal');
             if ($a->get('artefacttype') == 'socialprofile') {
                 $label = $a->get('description');
             }
             $data = array_merge($data, array('label' => $label));
             $persondata[] = (object) $data;
         }
     }
     if ($extras = $this->exporter->get('extrapersondata')) {
         $persondata = array_merge($persondata, $extras);
     }
     $this->smarty->assign('persondata', $persondata);
     $this->smarty->assign('spacialdata', $spacialdata);
     // Grab profile icons and link to them, making sure the default is first
     if ($icons = get_column_sql("SELECT id\n            FROM {artefact}\n            WHERE artefacttype = 'profileicon'\n            AND \"owner\" = ?\n            ORDER BY id = (\n                SELECT profileicon FROM {usr} WHERE id = ?\n            ) DESC, id", array($userid, $userid))) {
         foreach ($icons as $icon) {
             $icon = artefact_instance_from_id($icon);
             $this->add_artefact_link($icon, 'related');
         }
         $this->smarty->assign('links', $this->links);
     }
     if (!($categories = $this->get_categories())) {
         $categories = array();
     }
     $this->smarty->assign('categories', $categories);
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:56,代码来源:lib.php

示例11: mail_print_name_user_message_sort

function mail_print_name_user_message_sort($u)
{
    global $CFG;
    $usuario = get_record_sql("SELECT id, firstname, lastname, username FROM {$CFG->prefix}user \r\n               WHERE id = {$u}");
    if ($usuario) {
        $textname = strtolower($usuario->lastname . " " . $usuario->firstname . " (" . $usuario->username . ")");
    } else {
        $textname = "";
    }
    return $textname;
}
开发者ID:henriquecrang,项目名称:e-UNI,代码行数:11,代码来源:locallib.php

示例12: get_module_from_cmid

function get_module_from_cmid($cmid)
{
    global $CFG;
    if (!($cmrec = get_record_sql("SELECT cm.*, md.name as modname\n                               FROM {$CFG->prefix}course_modules cm,\n                                    {$CFG->prefix}modules md\n                               WHERE cm.id = '{$cmid}' AND\n                                     md.id = cm.module"))) {
        error('cmunknown');
    } elseif (!($modrec = get_record($cmrec->modname, 'id', $cmrec->instance))) {
        error('cmunknown');
    }
    $modrec->instance = $modrec->id;
    $modrec->cmid = $cmrec->id;
    $cmrec->name = $modrec->name;
    return array($modrec, $cmrec);
}
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:13,代码来源:editlib.php

示例13: __get_one_image_

function __get_one_image_($id, $thumb)
{
    global $CFG;
    $id = intval($id);
    $image = get_record_sql("SELECT i.* ,g.requirelogin, g.course\n                             FROM\n                               {$CFG->prefix}imagegallery_images AS i,\n                               {$CFG->prefix}imagegallery AS g\n                             WHERE i.galleryid = g.id AND i.id = '{$id}'");
    if (empty($image)) {
        return false;
        exit;
    }
    if ($thumb) {
        $image->path = dirname($image->path);
        $image->path .= '/thumb_' . $image->name;
    }
    $image->path = $CFG->dataroot . $image->path;
    return $image;
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:16,代码来源:image.php

示例14: ical_parse

/**
 * This functions parses all the events, and creates one iCal
 * (.ics) file per course, storing them in the folder specified in the
 * module's configuration.
 * ToDo: site's events.
 */
function ical_parse()
{
    global $CFG;
    // Retrieves all the courses
    $courses = get_records_sql('SELECT *, 1 FROM ' . $CFG->prefix . 'course');
    // First, we must check if the path to store the iCal files exists...
    if (empty($CFG->ical_path)) {
        set_config('ical_path', 'webdav');
    }
    $webdav_dir = $CFG->dirroot . '/' . $CFG->ical_path;
    if (is_dir($webdav_dir)) {
        // Now, for each course...
        foreach ($courses as $course) {
            $count = get_record_sql('SELECT *, 1 FROM ' . $CFG->prefix . 'event WHERE courseid=' . $course->id);
            if (!empty($count) && $course->id != 0 && ($fp = @fopen($webdav_dir . '/' . $course->shortname . '.ics', "w"))) {
                // Write the header
                $write = fwrite($fp, "BEGIN:VCALENDAR\nVERSION\n :2.0\nPRODID\n :-//Moodle.org//NONSGML iCal Module v0.1 beta//EN");
                // expect creating/modifying the course file
                $events = calendar_get_upcoming(array(0 => $course->id), $groups, $users, get_user_preferences('calendar_lookahead', CALENDAR_UPCOMING_DAYS), get_user_preferences('calendar_maxevents', CALENDAR_UPCOMING_MAXEVENTS));
                // For all the events in the current course
                foreach ($events as $event) {
                    // If the event is visible
                    if ($event->visible) {
                        $write = fwrite($fp, "\nBEGIN:VEVENT\nUID\n :" . $event->id . "-" . $event->timestart . "\nSUMMARY\n :" . $event->name . "\nCATEGORIES\n :" . $course->fullname . "\nSTATUS\n :CONFIRMED\nCLASS\n :PUBLIC\nDESCRIPTION:" . $event->description);
                        // We check if it has a stablished duration
                        if ($event->timeduration != 0) {
                            // It does: we print the event time information, with the duration
                            $write = fwrite($fp, "\nDTSTART\n :" . gmdate("Ymd\\THis\\Z", $event->timestart) . "\nDTEND\n :" . gmdate("Ymd\\THis\\Z", $event->timestart + $event->timeduration));
                        } else {
                            // However, if it doesn't, we assume that the event lasts 24hrs
                            $write = fwrite($fp, "\nDTSTART\n ;VALUE=DATE\n :" . gmdate("Ymd", $event->timestart) . "\nDTEND\n ;VALUE=DATE\n :" . gmdate("Ymd", $event->timestart + 86400));
                        }
                        // And now for the timestamp and we finish this event
                        $write = fwrite($fp, "\nDTSTAMP\n :" . gmdate("Ymd\\THis\\Z", $event->timemodified) . "\nEND:VEVENT");
                    }
                }
                // This calendar file (course file) has ended :)
                $write = fwrite($fp, "\nEND:VCALENDAR");
                fclose($fp);
            }
        }
    } else {
        echo 'The directory ' . $webdav_dir . ' is not valid.';
    }
}
开发者ID:BackupTheBerlios,项目名称:moodlets2-svn,代码行数:51,代码来源:lib.php

示例15: find_lms_user

function find_lms_user($installid, $username, $signature, $confirmaction = null, $firstname = null, $lastname = null, $email = null)
{
    global $CFG;
    // find this host from the installid
    if (empty($CFG->lmshosts) || !is_array($CFG->lmshosts) || !array_key_exists($installid, $CFG->lmshosts)) {
        return LMS_NO_SUCH_HOST;
    }
    $host = $CFG->lmshosts[$installid];
    // validate our md5 hash
    if ($confirmaction == 'signupconfirmation') {
        $stringtohash = $installid . '|' . $username . '|' . $firstname . '|' . $lastname . '|' . $email . '|' . $host['token'];
    } else {
        $stringtohash = $installid . '|' . $username . '|' . $host['token'];
        // firstname, lastname and email cannot be relied upon not to change
        // so we only want to add them to the hash on signup, not for auth or anything else.
    }
    $checksig = md5($stringtohash);
    if ($checksig != $signature) {
        return LMS_INVALID_HASH;
    }
    // if we have an ip address, check it.
    if (array_key_exists('networkaddress', $host) && empty($confirmaction)) {
        if (!address_in_subnet(getremoteaddr(), $host['networkaddress'])) {
            return LMS_INVALID_NETWORK;
        }
    }
    if (!empty($confirmaction) && !empty($host['confirmurl'])) {
        $client = new Snoopy();
        $client->agent = LMS_SNOOPY_USER_AGENT;
        $client->read_timeout = 5;
        $client->use_gzip = true;
        $postdata = array('action' => $confirmaction, 'username' => $username, 'signature' => $signature);
        @$client->submit($host['confirmurl'], $postdata);
        if ($client->results != 'OK') {
            return clean_param($client->results, PARAM_CLEAN);
        }
    }
    // find our user (we only want to check username and installid, the others could potentially change..
    if (!($user = get_record_sql('SELECT u.* FROM ' . $CFG->prefix . 'users u 
                        JOIN ' . $CFG->prefix . 'users_alias ua ON ua.user_id = u.ident
                        WHERE ua.installid = ? AND ua.username = ?', array($installid, $username)))) {
        return LMS_NO_SUCH_USER;
    }
    return $user;
}
开发者ID:BackupTheBerlios,项目名称:tulipan-svn,代码行数:45,代码来源:lmslib.php


注:本文中的get_record_sql函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。