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


PHP insert_record函数代码示例

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


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

示例1: scheduler_add_instance

/**
 * Given an object containing all the necessary data,
 * (defined by the form in mod_form.php) this function
 * will create a new instance and return the id number
 * of the new instance.
 *
 * @param object $scheduler An object from the form in mod_form.php
 * @return int The id of the newly inserted scheduler record
 */
function scheduler_add_instance($scheduler)
{
    $scheduler->timecreated = time();
    # You may have to add extra stuff in here #
    echo 'new scheduler added';
    return insert_record('scheduler', $scheduler);
}
开发者ID:arshanam,项目名称:Moodle-ITScholars-LMS,代码行数:16,代码来源:lib.php

示例2: 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;
 }
开发者ID:remotelearner,项目名称:elis.cm,代码行数:37,代码来源:message_output_email.php

示例3: save_question_options

 function save_question_options($question)
 {
     $result = true;
     $update = true;
     $answer = get_record("question_answers", "question", $question->id);
     if (!$answer) {
         $answer = new stdClass();
         $answer->question = $question->id;
         $update = false;
     }
     $answer->answer = $question->feedback;
     $answer->feedback = $question->feedback;
     $answer->fraction = $question->fraction;
     if ($update) {
         if (!update_record("question_answers", $answer)) {
             $result = new stdClass();
             $result->error = "Could not update quiz answer!";
         }
     } else {
         if (!($answer->id = insert_record("question_answers", $answer))) {
             $result = new stdClass();
             $result->error = "Could not insert quiz answer!";
         }
     }
     return $result;
 }
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:26,代码来源:questiontype.php

示例4: block_openshare_updategroup

function block_openshare_updategroup($courseid, $groupid)
{
    $sql = 'SELECT u.id FROM mdl_user u 
	JOIN mdl_role_assignments ra ON ra.userid = u.id 
	JOIN mdl_role r ON ra.roleid = r.id 
	JOIN mdl_context con ON ra.contextid = con.id 
	JOIN mdl_course c ON c.id = con.instanceid AND con.contextlevel = 50 WHERE (r.shortname = \'student\' OR r.shortname = \'teacher\' OR r.shortname = \'editingteacher\' OR r.shortname = \'coursecreator\') AND c.id = ' . $courseid;
    $rs = get_recordset_sql($sql);
    if (!empty($rs)) {
        while ($rec = rs_fetch_next_record($rs)) {
            //prep dataobject for door
            $groupenroll = new object();
            $groupenroll->timeadded = time();
            $groupenroll->groupid = $groupid;
            $groupenroll->userid = $rec->id;
            $ingroup = get_record("groups_members", "groupid", $groupid, "userid", $rec->id);
            if (empty($ingroup)) {
                insert_record("groups_members", $groupenroll);
                print 'updated' . $groupenroll->groupid . $groupenroll->userid . '<br/>';
            }
        }
    } else {
        print_error("No users in this course!");
    }
    // Close the recordset to save memory
    rs_close($rs);
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:27,代码来源:locallib.php

示例5: requestfriendship_submit

function requestfriendship_submit(Pieform $form, $values)
{
    global $USER, $SESSION, $id, $goto;
    $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);
    $n->fromuser = $loggedinid;
    $lang = get_user_language($user->id);
    $displayname = display_name($USER, $user);
    $n->strings = new stdClass();
    $n->strings->urltext = (object) array('key' => 'Requests');
    $f->owner = $id;
    $f->requester = $loggedinid;
    $f->message = $values['message'];
    insert_record('usr_friend_request', $f);
    $n->subject = get_string_from_language($lang, 'requestedfriendlistsubject', 'group');
    if (isset($values['message']) && !empty($values['message'])) {
        $n->message = get_string_from_language($lang, 'requestedfriendlistmessageexplanation', 'group', $displayname) . $values['message'];
    } else {
        $n->message = get_string_from_language($lang, 'requestedfriendlistinboxmessage', 'group', $displayname);
    }
    require_once 'activity.php';
    activity_occurred('maharamessage', $n);
    handle_event('addfriendrequest', array('requester' => $loggedinid, 'owner' => $id));
    $SESSION->add_ok_msg(get_string('friendformrequestsuccess', 'group', display_name($id)));
    redirect($goto);
}
开发者ID:rboyatt,项目名称:mahara,代码行数:33,代码来源:requestfriendship.php

示例6: lms_get_folder

function lms_get_folder($installid, $foldername, $user)
{
    // look for the installid folder first.
    if (!($folder = get_record('file_folders', 'owner', $user->ident, 'name', $installid))) {
        // we have to make it.
        $folder = new StdClass();
        $folder->name = $installid;
        $folder->owner = $user->ident;
        $folder->files_owner = $user->ident;
        $folder->parent = -1;
        $folder->access = 'user' . $user->ident;
        // ew
        $folder->ident = insert_record('file_folders', $folder);
    }
    if (!($subfolder = get_record('file_folders', 'owner', $user->ident, 'name', $foldername, 'parent', $folder->ident))) {
        // we have to make it.
        $subfolder = new StdClass();
        $subfolder->name = $foldername;
        $subfolder->owner = $user->ident;
        $subfolder->files_owner = $user->ident;
        $subfolder->parent = $folder->ident;
        $subfolder->access = 'user' . $user->ident;
        // ew
        $subfolder->ident = insert_record('file_folders', $subfolder);
    }
    return $subfolder;
}
开发者ID:BackupTheBerlios,项目名称:tulipan-svn,代码行数:27,代码来源:lmslib.php

示例7: save_question_options

 function save_question_options($question)
 {
     if ($answer = get_record("question_answers", "question", $question->id)) {
         // Existing answer, so reuse it
         $answer->answer = $question->feedback;
         $answer->feedback = $question->feedback;
         $answer->fraction = $question->fraction;
         if (!update_record("question_answers", $answer)) {
             $result = new stdClass();
             $result->error = "Could not update quiz answer!";
             return $result;
         }
     } else {
         $answer = new stdClass();
         $answer->question = $question->id;
         $answer->answer = $question->feedback;
         $answer->feedback = $question->feedback;
         $answer->fraction = $question->fraction;
         if (!($answer->id = insert_record("question_answers", $answer))) {
             $result = new stdClass();
             $result->error = "Could not insert quiz answer!";
             return $result;
         }
     }
     return true;
 }
开发者ID:veritech,项目名称:pare-project,代码行数:26,代码来源:questiontype.php

示例8: slideshow_captions_restore_mods

function slideshow_captions_restore_mods($old_slideshow_id, $new_slideshow_id, $info, $restore)
{
    global $CFG;
    $status = true;
    //Get the captions array
    $captions = $info['MOD']['#']['CAPTIONS']['0']['#']['CAPTION'];
    //Iterate over captions
    for ($i = 0; $i < sizeof($captions); $i++) {
        $cap_info = $captions[$i];
        //traverse_xmlize($cap_info);                                                                 //Debug
        //print_object ($GLOBALS['traverse_array']);                                                  //Debug
        //$GLOBALS['traverse_array']="";                                                              //Debug
        //We'll need this later!!
        $oldid = backup_todb($cap_info['#']['ID']['0']['#']);
        $olduserid = backup_todb($cap_info['#']['USERID']['0']['#']);
        //Now, build the SLIDESHOW_MESSAGES record structure
        $caption->slideshow = $new_slideshow_id;
        $caption->image = backup_todb($cap_info['#']['IMAGE']['0']['#']);
        $caption->title = backup_todb($cap_info['#']['TITLE']['0']['#']);
        $caption->caption = backup_todb($cap_info['#']['CAPTION']['0']['#']);
        //The structure is equal to the db, so insert the slideshow_message
        $newid = insert_record("slideshow_captions", $caption);
        //Do some output
        if (($i + 1) % 50 == 0) {
            if (!defined('RESTORE_SILENTLY')) {
                echo ".";
                if (($i + 1) % 1000 == 0) {
                    echo "<br />";
                }
            }
            backup_flush(300);
        }
    }
    return $status;
}
开发者ID:kai707,项目名称:ITSA-backup,代码行数:35,代码来源:restorelib.php

示例9: commit

 public function commit()
 {
     if ($this->initialized == self::UNINITIALIZED) {
         return false;
     }
     if (false == $this->changed) {
         return true;
     }
     if (empty($this->members['displayname'])) {
         $this->members['displayname'] = $this->members['name'];
     }
     if (false == $this->changed) {
         return true;
     }
     $application = new stdClass();
     $application->name = $this->members['name'];
     $application->displayname = $this->members['displayname'];
     $application->xmlrpcserverurl = $this->members['xmlrpcserverurl'];
     if ($this->initialized == self::INITIALIZED) {
         $this->initialized = self::PERSISTENT;
         return insert_record('application', $application);
     } elseif ($this->initialized == self::PERSISTENT) {
         return update_record('application', $application, array('name' => $application->oldname));
     }
     return false;
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:26,代码来源:application.php

示例10: AppendSudokuB

function AppendSudokuB()
{
    $level1 = required_param('level1', PARAM_NUMBER);
    // action
    $level2 = required_param('level2', PARAM_NUMBER);
    // action
    $count = required_param('count', PARAM_NUMBER);
    // action
    $level = $level1;
    for ($i = 1; $i <= $count; $i++) {
        set_time_limit(30);
        Create($si, $sp, $level);
        $newrec->data = PackSudoku($si, $sp);
        if (strlen($newrec->data) != 81) {
            return 0;
        }
        $newrec->level = $level;
        $newrec->opened = GetOpened($si);
        insert_record("game_sudoku_database", $newrec, true);
        $level++;
        if ($level > $level2) {
            $level = $level1;
        }
        echo get_string('sudoku_creating', 'game', $i) . "<br>\r\n";
    }
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:26,代码来源:create.php

示例11: forumng_add_instance

function forumng_add_instance($forumng)
{
    // Avoid including forum libraries in large areas of Moodle code that
    // require this lib.php; only include when functions are called
    require_once dirname(__FILE__) . '/forum.php';
    $useshared = !empty($forumng->usesharedgroup['useshared']);
    if ($useshared) {
        $idnumber = $forumng->usesharedgroup['originalcmidnumber'];
        if (!($originalcm = get_record('course_modules', 'idnumber', $idnumber, 'module', get_field('modules', 'id', 'name', 'forumng')))) {
            return false;
        }
        if (!($originalforumng = get_record('forumng', 'id', $originalcm->instance))) {
            return false;
        }
        // Create appropriate data for forumng table
        $forumng = (object) array('name' => addslashes($originalforumng->name), 'course' => $forumng->course, 'type' => 'clone', 'originalcmid' => $originalcm->id);
    }
    // Pick a random magic number
    $part1 = mt_rand(0, 99999999);
    $part2 = mt_rand(0, 99999999);
    while (strlen($part2) < 8) {
        $part2 = '0' . $part2;
    }
    $forumng->magicnumber = $part1 . $part2;
    if (!($id = insert_record('forumng', $forumng))) {
        return false;
    }
    // Handle post-creation actions (but only if a new forum actually was
    // created, and not just a new reference to a shared one!)
    if (!$useshared) {
        $forum = forum::get_from_id($id, forum::CLONE_DIRECT, false);
        $forum->created($forumng->cmidnumber);
    }
    return $id;
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:35,代码来源:lib.php

示例12: diplome_restore_mods

function diplome_restore_mods($mod, $restore)
{
    global $CFG;
    $status = true;
    //Get record from backup_ids
    $data = backup_getid($restore->backup_unique_code, $mod->modtype, $mod->id);
    if ($data) {
        //Now get completed xmlized object
        $info = $data->info;
        //Now, build the ACCOUNTING record structure
        $diplome->course = $restore->course_id;
        $diplome->name = backup_todb($info['MOD']['#']['NAME']['0']['#']);
        $diplome->intro = backup_todb($info['MOD']['#']['INTRO']['0']['#']);
        $diplome->introformat = backup_todb($info['MOD']['#']['INTROFORMAT']['0']['#']);
        $diplome->timecreated = time();
        $diplome->timemodified = time();
        //The structure is equal to the db, so insert the label
        $newid = insert_record("diplome", $diplome);
        //Do some output
        if (!defined('RESTORE_SILENTLY')) {
            echo "<li>" . get_string("modulename", "diplome") . " \"" . format_string(stripslashes($diplome->name), true) . "\"</li>";
        }
        backup_flush(300);
        if ($newid) {
            //We have the newid, update backup_ids
            backup_putid($restore->backup_unique_code, $mod->modtype, $mod->id, $newid);
        } else {
            $status = false;
        }
    } else {
        $status = false;
    }
    return $status;
}
开发者ID:ruxandra25,项目名称:diplome,代码行数:34,代码来源:restorelib.php

示例13: sclipowebclass_add_event

function sclipowebclass_add_event($sclipo)
{
    $sclipo->timemodified = time();
    # May have to add extra stuff in here #
    $returnid = insert_record("event", $sclipo);
    return $returnid;
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:7,代码来源:lib.php

示例14: xmldb_blocktype_taggedposts_upgrade

function xmldb_blocktype_taggedposts_upgrade($oldversion = 0)
{
    if ($oldversion < 2015011500) {
        $table = new XMLDBTable('blocktype_taggedposts_tags');
        $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL, XMLDB_SEQUENCE);
        $table->addFieldInfo('block_instance', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL);
        $table->addFieldInfo('tag', XMLDB_TYPE_CHAR, 128, null, XMLDB_NOTNULL);
        $table->addFieldInfo('tagtype', XMLDB_TYPE_INTEGER, 10, null, XMLDB_NOTNULL);
        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
        $table->addIndexInfo('tagtagtypeix', XMLDB_INDEX_NOTUNIQUE, array('tag', 'tagtype'));
        if (!table_exists($table)) {
            create_table($table);
            $rs = get_recordset('block_instance', 'blocktype', 'taggedposts', 'id', 'id, configdata');
            while ($bi = $rs->FetchRow()) {
                // Each block will have only one tag (because we combined this upgrade block
                // with the upgrade block for the "multiple tags" enhancement.
                $configdata = unserialize($bi['configdata']);
                if (!empty($configdata['tagselect'])) {
                    $todb = new stdClass();
                    $todb->block_instance = $bi['id'];
                    $todb->tag = $configdata['tagselect'];
                    $todb->tagtype = PluginBlocktypeTaggedposts::TAGTYPE_INCLUDE;
                    insert_record('blocktype_taggedposts_tags', $todb);
                }
            }
        }
    }
    return true;
}
开发者ID:rboyatt,项目名称:mahara,代码行数:29,代码来源:upgrade.php

示例15: lightboxgallery_restore_metadata

function lightboxgallery_restore_metadata($galleryid, $info, $restore)
{
    $status = true;
    if (isset($info['MOD']['#']['IMAGEMETAS']['0']['#']['IMAGEMETA'])) {
        $imagemetas = $info['MOD']['#']['IMAGEMETAS']['0']['#']['IMAGEMETA'];
    } else {
        $imagemetas = array();
    }
    for ($i = 0; $i < sizeof($imagemetas); $i++) {
        $sub_info = $imagemetas[$i];
        $oldid = backup_todb($sub_info['#']['ID']['0']['#']);
        $record = new object();
        $record->gallery = $galleryid;
        $record->image = backup_todb($sub_info['#']['IMAGE']['0']['#']);
        $record->metatype = backup_todb($sub_info['#']['METATYPE']['0']['#']);
        $record->description = backup_todb($sub_info['#']['DESCRIPTION']['0']['#']);
        $newid = insert_record('lightboxgallery_image_meta', $record);
        if (($i + 1) % 50 == 0) {
            if (!defined('RESTORE_SILENTLY')) {
                echo '.';
                if (($i + 1) % 1000 == 0) {
                    echo '<br />';
                }
            }
            backup_flush(300);
        }
        if ($newid) {
            backup_putid($restore->backup_unique_code, 'lightboxgallery_image_meta', $oldid, $newid);
        } else {
            $status = false;
        }
    }
    return $status;
}
开发者ID:itziko,项目名称:Moodle-jQuery-Lightbox-Gallery,代码行数:34,代码来源:restorelib.php


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