本文整理汇总了PHP中rs_EOF函数的典型用法代码示例。如果您正苦于以下问题:PHP rs_EOF函数的具体用法?PHP rs_EOF怎么用?PHP rs_EOF使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rs_EOF函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validation
function validation($data, $files)
{
global $CFG, $db, $USER;
$errors = parent::validation($data, $files);
$sql = stripslashes($data['querysql']);
// Simple test to avoid evil stuff in the SQL.
if (report_customsql_contains_bad_word($sql)) {
$errors['querysql'] = get_string('notallowedwords', 'report_customsql', implode(', ', report_customsql_bad_words_list()));
// Do not allow any semicolons.
} else {
if (strpos($sql, ';') !== false) {
$errors['querysql'] = get_string('nosemicolon', 'report_customsql');
// Make sure prefix is prefix_, not explicit.
} else {
if ($CFG->prefix != '' && preg_match('/\\b' . $CFG->prefix . '\\w+/i', $sql)) {
$errors['querysql'] = get_string('noexplicitprefix', 'report_customsql', $CFG->prefix);
// Now try running the SQL, and ensure it runs without errors.
} else {
$report = new stdClass();
$report->querysql = $sql;
$report->runable = $data['runable'];
$sql = report_customsql_prepare_sql($report, time());
$rs = report_customsql_execute_query($sql, 2);
if (!$rs) {
$errors['querysql'] = get_string('queryfailed', 'report_customsql', $db->ErrorMsg());
} else {
if (!empty($data['singlerow'])) {
if (rs_EOF($rs)) {
$errors['querysql'] = get_string('norowsreturned', 'report_customsql');
} else {
rs_fetch_next_record($rs);
if (!rs_EOF($rs)) {
$errors['querysql'] = get_string('morethanonerowreturned', 'report_customsql');
}
}
}
}
if ($rs) {
rs_close($rs);
}
}
}
}
return $errors;
}
示例2: validation
function validation($data, $files)
{
global $DB, $CFG, $db, $USER;
$errors = parent::validation($data, $files);
$sql = $data['querysql'];
$sql = trim($sql);
// Simple test to avoid evil stuff in the SQL.
if (preg_match('/\\b(ALTER|CREATE|DELETE|DROP|GRANT|INSERT|INTO|TRUNCATE|UPDATE|SET|VACUUM|REINDEX|DISCARD|LOCK)\\b/i', $sql)) {
$errors['querysql'] = get_string('notallowedwords', 'block_configurable_reports');
// Do not allow any semicolons.
} else {
if (strpos($sql, ';') !== false) {
$errors['querysql'] = get_string('nosemicolon', 'report_customsql');
// Make sure prefix is prefix_, not explicit.
} else {
if ($CFG->prefix != '' && preg_match('/\\b' . $CFG->prefix . '\\w+/i', $sql)) {
$errors['querysql'] = get_string('noexplicitprefix', 'block_configurable_reports');
// Now try running the SQL, and ensure it runs without errors.
} else {
$sql = $this->_customdata['reportclass']->prepare_sql($sql);
$rs = $this->_customdata['reportclass']->execute_query($sql, 2);
if (!$rs) {
$errors['querysql'] = get_string('queryfailed', 'block_configurable_reports', $db->ErrorMsg());
} else {
if (!empty($data['singlerow'])) {
if (rs_EOF($rs)) {
$errors['querysql'] = get_string('norowsreturned', 'block_configurable_reports');
}
}
}
if ($rs) {
$rs->close();
}
}
}
}
return $errors;
}
示例3: backup_user_info
function backup_user_info($bf, $preferences)
{
global $CFG;
require_once $CFG->dirroot . '/tag/lib.php';
$status = true;
// Use a recordset to for the memory handling on to
// the DB and run faster
// Note the outer join with mnet_host: It shouldn't be neccesary
// but there are some sites having mnet_host records missing
// and that causes backup to fail (no users). Being a bit more
// flexible here (outer joing) we bypass the problem and doesn't
// cause more troubles. Eloy - MDL-16879
$users = get_recordset_sql("SELECT b.old_id, b.table_name, b.info,\n u.*, m.wwwroot\n FROM {$CFG->prefix}backup_ids b\n JOIN {$CFG->prefix}user u ON b.old_id=u.id\n LEFT JOIN {$CFG->prefix}mnet_host m ON u.mnethostid=m.id\n WHERE b.backup_code = '{$preferences->backup_unique_code}' AND\n b.table_name = 'user'");
//If we have users to backup
if ($users && !rs_EOF($users)) {
//Begin Users tag
fwrite($bf, start_tag("USERS", 2, true));
$counter = 0;
//With every user
while ($user = rs_fetch_next_record($users)) {
//Begin User tag
fwrite($bf, start_tag("USER", 3, true));
//Output all user data
fwrite($bf, full_tag("ID", 4, false, $user->id));
fwrite($bf, full_tag("AUTH", 4, false, $user->auth));
fwrite($bf, full_tag("CONFIRMED", 4, false, $user->confirmed));
fwrite($bf, full_tag("POLICYAGREED", 4, false, $user->policyagreed));
fwrite($bf, full_tag("DELETED", 4, false, $user->deleted));
fwrite($bf, full_tag("USERNAME", 4, false, $user->username));
// Prevent user passwords in backup files unless
// $CFG->includeuserpasswordsinbackup is defined. MDL-20838
if (!empty($CFG->includeuserpasswordsinbackup)) {
fwrite($bf, full_tag("PASSWORD", 4, false, $user->password));
}
fwrite($bf, full_tag("IDNUMBER", 4, false, $user->idnumber));
fwrite($bf, full_tag("FIRSTNAME", 4, false, $user->firstname));
fwrite($bf, full_tag("LASTNAME", 4, false, $user->lastname));
fwrite($bf, full_tag("EMAIL", 4, false, $user->email));
fwrite($bf, full_tag("EMAILSTOP", 4, false, $user->emailstop));
fwrite($bf, full_tag("ICQ", 4, false, $user->icq));
fwrite($bf, full_tag("SKYPE", 4, false, $user->skype));
fwrite($bf, full_tag("YAHOO", 4, false, $user->yahoo));
fwrite($bf, full_tag("AIM", 4, false, $user->aim));
fwrite($bf, full_tag("MSN", 4, false, $user->msn));
fwrite($bf, full_tag("PHONE1", 4, false, $user->phone1));
fwrite($bf, full_tag("PHONE2", 4, false, $user->phone2));
fwrite($bf, full_tag("INSTITUTION", 4, false, $user->institution));
fwrite($bf, full_tag("DEPARTMENT", 4, false, $user->department));
fwrite($bf, full_tag("ADDRESS", 4, false, $user->address));
fwrite($bf, full_tag("CITY", 4, false, $user->city));
fwrite($bf, full_tag("COUNTRY", 4, false, $user->country));
fwrite($bf, full_tag("LANG", 4, false, $user->lang));
fwrite($bf, full_tag("THEME", 4, false, $user->theme));
fwrite($bf, full_tag("TIMEZONE", 4, false, $user->timezone));
fwrite($bf, full_tag("FIRSTACCESS", 4, false, $user->firstaccess));
fwrite($bf, full_tag("LASTACCESS", 4, false, $user->lastaccess));
fwrite($bf, full_tag("LASTLOGIN", 4, false, $user->lastlogin));
fwrite($bf, full_tag("CURRENTLOGIN", 4, false, $user->currentlogin));
fwrite($bf, full_tag("LASTIP", 4, false, $user->lastip));
fwrite($bf, full_tag("PICTURE", 4, false, $user->picture));
fwrite($bf, full_tag("URL", 4, false, $user->url));
fwrite($bf, full_tag("DESCRIPTION", 4, false, $user->description));
fwrite($bf, full_tag("MAILFORMAT", 4, false, $user->mailformat));
fwrite($bf, full_tag("MAILDIGEST", 4, false, $user->maildigest));
fwrite($bf, full_tag("MAILDISPLAY", 4, false, $user->maildisplay));
fwrite($bf, full_tag("HTMLEDITOR", 4, false, $user->htmleditor));
fwrite($bf, full_tag("AJAX", 4, false, $user->ajax));
fwrite($bf, full_tag("AUTOSUBSCRIBE", 4, false, $user->autosubscribe));
fwrite($bf, full_tag("TRACKFORUMS", 4, false, $user->trackforums));
if ($user->mnethostid != $CFG->mnet_localhost_id && !empty($user->wwwroot)) {
fwrite($bf, full_tag("MNETHOSTURL", 4, false, $user->wwwroot));
}
fwrite($bf, full_tag("TIMEMODIFIED", 4, false, $user->timemodified));
/// write assign/override code for context_userid
$user->isneeded = strpos($user->info, "needed");
fwrite($bf, start_tag("ROLES", 4, true));
if ($user->info != "needed" && $user->info != "") {
//PRINT ROLE INFO
$roles = explode(",", $user->info);
foreach ($roles as $role) {
if ($role != "" && $role != "needed") {
fwrite($bf, start_tag("ROLE", 5, true));
//Print Role info
fwrite($bf, full_tag("TYPE", 6, false, $role));
//Print ROLE end
fwrite($bf, end_tag("ROLE", 5, true));
}
}
}
//Needed
if ($user->isneeded !== false) {
//Print ROLE start
fwrite($bf, start_tag("ROLE", 5, true));
//Print Role info
fwrite($bf, full_tag("TYPE", 6, false, "needed"));
//Print ROLE end
fwrite($bf, end_tag("ROLE", 5, true));
}
//End ROLES tag
fwrite($bf, end_tag("ROLES", 4, true));
//.........这里部分代码省略.........
示例4: validation_low_security
function validation_low_security($data, $files) {
global $DB, $CFG, $db, $USER;
$errors = parent::validation($data, $files);
$sql = $data['querysql'];
$sql = trim($sql);
if (empty($this->_customdata['report']->runstatistics) OR $this->_customdata['report']->runstatistics == 0) {
// Simple test to avoid evil stuff in the SQL.
//if (preg_match('/\b(ALTER|CREATE|DELETE|DROP|GRANT|INSERT|INTO|TRUNCATE|UPDATE|SET|VACUUM|REINDEX|DISCARD|LOCK)\b/i', $sql)) {
// Allow cron SQL queries to run CREATE|INSERT|INTO queries.
if (preg_match('/\b(ALTER|DELETE|DROP|GRANT|TRUNCATE|UPDATE|SET|VACUUM|REINDEX|DISCARD|LOCK)\b/i', $sql)) {
$errors['querysql'] = get_string('notallowedwords', 'block_cobalt_reports');
}
// Now try running the SQL, and ensure it runs without errors.
} else {
$sql = $this->_customdata['reportclass']->prepare_sql($sql);
$rs = $this->_customdata['reportclass']->execute_query($sql, 2);
if (!$rs) {
$errors['querysql'] = get_string('queryfailed', 'block_cobalt_reports', $db->ErrorMsg());
} else if (!empty($data['singlerow'])) {
if (rs_EOF($rs)) {
$errors['querysql'] = get_string('norowsreturned', 'block_cobalt_reports');
}
}
if ($rs) {
$rs->close();
}
}
return $errors;
}
示例5: forum_cron
//.........这里部分代码省略.........
}
if ($posts) {
foreach ($posts as $post) {
mtrace($mailcount[$post->id] . " users were sent post {$post->id}, '{$post->subject}'");
if ($errorcount[$post->id]) {
set_field("forum_posts", "mailed", "2", "id", "{$post->id}");
}
}
}
// release some memory
unset($subscribedusers);
unset($mailcount);
unset($errorcount);
$USER = clone $cronuser;
course_setup(SITEID);
$sitetimezone = $CFG->timezone;
// Now see if there are any digest mails waiting to be sent, and if we should send them
mtrace('Starting digest processing...');
@set_time_limit(300);
// terminate if not able to fetch all digests in 5 minutes
if (!isset($CFG->digestmailtimelast)) {
// To catch the first time
set_config('digestmailtimelast', 0);
}
$timenow = time();
$digesttime = usergetmidnight($timenow, $sitetimezone) + $CFG->digestmailtime * 3600;
// Delete any really old ones (normally there shouldn't be any)
$weekago = $timenow - 7 * 24 * 3600;
delete_records_select('forum_queue', "timemodified < {$weekago}");
mtrace('Cleaned old digest records');
if ($CFG->digestmailtimelast < $digesttime and $timenow > $digesttime) {
mtrace('Sending forum digests: ' . userdate($timenow, '', $sitetimezone));
$digestposts_rs = get_recordset_select('forum_queue', "timemodified < {$digesttime}");
if (!rs_EOF($digestposts_rs)) {
// We have work to do
$usermailcount = 0;
//caches - reuse the those filled before too
$discussionposts = array();
$userdiscussions = array();
while ($digestpost = rs_fetch_next_record($digestposts_rs)) {
if (!isset($users[$digestpost->userid])) {
if ($user = get_record('user', 'id', $digestpost->userid)) {
$users[$digestpost->userid] = $user;
} else {
continue;
}
}
$postuser = $users[$digestpost->userid];
if ($postuser->emailstop) {
if (!empty($CFG->forum_logblocked)) {
add_to_log(SITEID, 'forum', 'mail blocked', '', '', 0, $postuser->id);
}
continue;
}
if (!isset($posts[$digestpost->postid])) {
if ($post = get_record('forum_posts', 'id', $digestpost->postid)) {
$posts[$digestpost->postid] = $post;
} else {
continue;
}
}
$discussionid = $digestpost->discussionid;
if (!isset($discussions[$discussionid])) {
if ($discussion = get_record('forum_discussions', 'id', $discussionid)) {
$discussions[$discussionid] = $discussion;
} else {
示例6: fix_coursecategory_orphans
/**
* Ensure all courses have a valid course category
* useful if a category has been removed manually
**/
function fix_coursecategory_orphans()
{
global $CFG;
// Note: the handling of sortorder here is arguably
// open to race conditions. Hard to fix here, unlikely
// to hit anyone in production.
$sql = "SELECT c.id, c.category, c.shortname\n FROM {$CFG->prefix}course c\n LEFT OUTER JOIN {$CFG->prefix}course_categories cc ON c.category=cc.id\n WHERE cc.id IS NULL AND c.id != " . SITEID;
$rs = get_recordset_sql($sql);
if (!rs_EOF($rs)) {
// we have some orphans
// the "default" category is the lowest numbered...
$default = get_field_sql("SELECT MIN(id)\n FROM {$CFG->prefix}course_categories");
$sortorder = get_field_sql("SELECT MAX(sortorder)\n FROM {$CFG->prefix}course\n WHERE category={$default}");
begin_sql();
$tx = true;
while ($tx && ($course = rs_fetch_next_record($rs))) {
$tx = $tx && set_field('course', 'category', $default, 'id', $course->id);
$tx = $tx && set_field('course', 'sortorder', ++$sortorder, 'id', $course->id);
}
if ($tx) {
commit_sql();
} else {
rollback_sql();
}
}
rs_close($rs);
}
示例7: grade_update
//.........这里部分代码省略.........
$grades = array($grades['userid'] => $grades);
}
}
/// normalize and verify grade array
foreach ($grades as $k => $g) {
if (!is_array($g)) {
$g = (array) $g;
$grades[$k] = $g;
}
if (empty($g['userid']) or $k != $g['userid']) {
debugging('Incorrect grade array index, must be user id! Grade ignored.');
unset($grades[$k]);
}
}
if (empty($grades)) {
return GRADE_UPDATE_FAILED;
}
$count = count($grades);
if ($count == 1) {
reset($grades);
$uid = key($grades);
$sql = "SELECT * FROM {$CFG->prefix}grade_grades WHERE itemid = {$grade_item->id} AND userid = {$uid}";
} else {
if ($count < 200) {
$uids = implode(',', array_keys($grades));
$sql = "SELECT * FROM {$CFG->prefix}grade_grades WHERE itemid = {$grade_item->id} AND userid IN ({$uids})";
} else {
$sql = "SELECT * FROM {$CFG->prefix}grade_grades WHERE itemid = {$grade_item->id}";
}
}
$rs = get_recordset_sql($sql);
$failed = false;
while (count($grades) > 0) {
$grade_grade = null;
$grade = null;
while ($rs and !rs_EOF($rs)) {
if (!($gd = rs_fetch_next_record($rs))) {
break;
}
$userid = $gd->userid;
if (!isset($grades[$userid])) {
// this grade not requested, continue
continue;
}
// existing grade requested
$grade = $grades[$userid];
$grade_grade = new grade_grade($gd, false);
unset($grades[$userid]);
break;
}
if (is_null($grade_grade)) {
if (count($grades) == 0) {
// no more grades to process
break;
}
$grade = reset($grades);
$userid = $grade['userid'];
$grade_grade = new grade_grade(array('itemid' => $grade_item->id, 'userid' => $userid), false);
$grade_grade->load_optional_fields();
// add feedback and info too
unset($grades[$userid]);
}
$rawgrade = false;
$feedback = false;
$feedbackformat = FORMAT_MOODLE;
$usermodified = $USER->id;
$datesubmitted = null;
$dategraded = null;
if (array_key_exists('rawgrade', $grade)) {
$rawgrade = $grade['rawgrade'];
}
if (array_key_exists('feedback', $grade)) {
$feedback = $grade['feedback'];
}
if (array_key_exists('feedbackformat', $grade)) {
$feedbackformat = $grade['feedbackformat'];
}
if (array_key_exists('usermodified', $grade)) {
$usermodified = $grade['usermodified'];
}
if (array_key_exists('datesubmitted', $grade)) {
$datesubmitted = $grade['datesubmitted'];
}
if (array_key_exists('dategraded', $grade)) {
$dategraded = $grade['dategraded'];
}
// update or insert the grade
if (!$grade_item->update_raw_grade($userid, $rawgrade, $source, $feedback, $feedbackformat, $usermodified, $dategraded, $datesubmitted, $grade_grade)) {
$failed = true;
}
}
if ($rs) {
rs_close($rs);
}
if (!$failed) {
return GRADE_UPDATE_OK;
} else {
return GRADE_UPDATE_FAILED;
}
}
示例8: remove_test_table
/**
* Drops a table from the database pointed to by the database connection.
* This undoes the create performed by load_test_table().
*
* This function should not be used in real code. Only for testing and debugging.
*
* @param string $tablename the name of the table to populate. E.g. 'mdl_unittest_user'.
* @param object $db an AdoDB database connection.
* @param bool $cascade If true, also drop tables that depend on this one, e.g. through
* foreign key constraints.
*/
function remove_test_table($tablename, $db, $cascade = false)
{
global $CFG;
_private_execute_sql('DROP TABLE ' . $tablename . ($cascade ? ' CASCADE' : '') . ';', $db);
if ($CFG->dbfamily == 'postgres') {
$rs = $db->Execute("SELECT relname FROM pg_class WHERE relname = '{$tablename}_id_seq' AND relkind = 'S';");
if ($rs && !rs_EOF($rs)) {
_private_execute_sql("DROP SEQUENCE {$tablename}_id_seq;", $db);
}
}
if ($CFG->dbfamily == 'oracle') {
_private_execute_sql("DROP SEQUENCE {$tablename}_id_seq;", $db);
}
}
示例9: valid
public function valid()
{
return !empty($this->rs) && !rs_EOF($this->rs);
}