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


PHP db_commit函数代码示例

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


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

示例1: image_zap

function image_zap($image_id)
{
    $filename = db_getOne("SELECT filename FROM image WHERE id=?", $image_id);
    db_do("DELETE FROM image WHERE id=?", $image_id);
    db_commit();
    unlink(image_path($filename));
}
开发者ID:bcampbell,项目名称:journalisted,代码行数:7,代码来源:image.php

示例2: index

 /**
  * Show invoicing settings panel
  *
  * @param void
  * @return null
  */
 function index()
 {
     require_once INVOICING_MODULE_PATH . '/models/InvoicePdfGenerator.class.php';
     $paper_formats = array(PAPER_FORMAT_A4, PAPER_FORMAT_A3, PAPER_FORMAT_A5, PAPER_FORMAT_LETTER, PAPER_FORMAT_LEGAL);
     $paper_orientations = array(PAPER_ORIENTATION_PORTRAIT, PAPER_ORIENTATION_LANDSCAPE);
     $pdf_settings_data = $this->request->post('pdf_settings');
     if (!is_array($pdf_settings_data)) {
         $pdf_settings_data = array('paper_format' => ConfigOptions::getValue('invoicing_pdf_paper_format'), 'paper_orientation' => ConfigOptions::getValue('invoicing_pdf_paper_orientation'), 'header_text_color' => ConfigOptions::getValue('invoicing_pdf_header_text_color'), 'page_text_color' => ConfigOptions::getValue('invoicing_pdf_page_text_color'), 'border_color' => ConfigOptions::getValue('invoicing_pdf_border_color'), 'background_color' => ConfigOptions::getValue('invoicing_pdf_background_color'));
     }
     // if
     if ($this->request->isSubmitted()) {
         db_begin_work();
         ConfigOptions::setValue('invoicing_pdf_paper_format', array_var($pdf_settings_data, 'paper_format', 'A4'));
         ConfigOptions::setValue('invoicing_pdf_paper_orientation', array_var($pdf_settings_data, 'paper_orientation', 'Portrait'));
         ConfigOptions::setValue('invoicing_pdf_header_text_color', array_var($pdf_settings_data, 'header_text_color', '000000'));
         ConfigOptions::setValue('invoicing_pdf_page_text_color', array_var($pdf_settings_data, 'page_text_color', '000000'));
         ConfigOptions::setValue('invoicing_pdf_border_color', array_var($pdf_settings_data, 'border_color', '000000'));
         ConfigOptions::setValue('invoicing_pdf_background_color', array_var($pdf_settings_data, 'background_color', 'FFFFFF'));
         db_commit();
         flash_success('Successfully modified PDF settings');
         $this->redirectTo('admin_invoicing_pdf');
     }
     // if
     $this->smarty->assign(array('paper_formats' => $paper_formats, 'paper_orientations' => $paper_orientations, 'pdf_settings_data' => $pdf_settings_data));
 }
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:31,代码来源:PdfSettingsAdminController.class.php

示例3: __construct

 function __construct($pagepath = null)
 {
     $this->P = person_if_signed_on();
     // "pwb_" prefix means passwordbox
     $this->action = get_http_var('pwb_action');
     $this->pw1 = get_http_var('pw1', null);
     $this->pw2 = get_http_var('pw2', null);
     $this->err = null;
     $this->info = null;
     if (is_null($pagepath)) {
         // no specific page - use the _current_ one.
         $foo = crack_url($_SERVER['REQUEST_URI']);
         $this->pagepath = $foo['path'];
     } else {
         // use the one supplied.
         $this->pagepath = $pagepath;
     }
     if (is_null($this->P)) {
         return;
     }
     if ($this->action == 'set_password') {
         if (is_null($this->pw1) || is_null($this->pw2)) {
             $this->err = "Please type your new password twice";
         } elseif (strlen($this->pw1) < 5 || strlen($this->pw2) < 5) {
             $this->err = "Your password must be at least 5 characters long";
         } elseif ($this->pw1 != $this->pw2) {
             $this->err = "Please type the same password twice";
         } else {
             // all looks good. do it.
             $this->P->password($this->pw1);
             db_commit();
             $this->info = 'Password changed';
         }
     }
 }
开发者ID:bcampbell,项目名称:journalisted,代码行数:35,代码来源:passwordbox.php

示例4: i_set_account_settings

 /**
  * Sets the specified account settings to the current user.
  * A table with | Setting label | value | is expected.
  *
  * @Given /^I set the following account settings values:$/
  * @param TableNode $table
  */
 public function i_set_account_settings(TableNode $table)
 {
     global $USER;
     $prefs = array();
     foreach ($table->getHash() as $accountpref) {
         $prefs[$accountpref['field']] = $accountpref['value'];
     }
     // Validate the settings
     if (isset($prefs['urlid']) && get_config('cleanurls') && $prefs['urlid'] != $USER->get('urlid')) {
         if (strlen($prefs['urlid']) < 3) {
             throw new Exception("Invalid urlid: " . get_string('rule.minlength.minlength', 'pieforms', 3));
         } else {
             if (record_exists('usr', 'urlid', $prefs['urlid'])) {
                 throw new Exception("Invalid urlid: " . get_string('urlalreadytaken', 'account'));
             }
         }
     }
     if (get_config('allowmobileuploads')) {
         foreach ($prefs['mobileuploadtoken'] as $k => $text) {
             if (strlen($text) > 0 && !preg_match('/^[a-zA-Z0-9 !@#$%^&*()\\-_=+\\[{\\]};:\'",<\\.>\\/?]{6,}$/', $text)) {
                 throw new Exception("Invalid mobileuploadtoken: " . get_string('badmobileuploadtoken', 'account'));
             }
         }
     }
     // Update user's account settings
     db_begin();
     // use this as looping through values is not safe.
     $expectedprefs = expected_account_preferences();
     if (isset($prefs['maildisabled']) && $prefs['maildisabled'] == 0 && get_account_preference($USER->get('id'), 'maildisabled') == 1) {
         // Reset the sent and bounce counts otherwise mail will be disabled
         // on the next send attempt
         $u = new StdClass();
         $u->email = $USER->get('email');
         $u->id = $USER->get('id');
         update_bounce_count($u, true);
         update_send_count($u, true);
     }
     // Remember the user's language & theme prefs, so we can reload the page if they change them
     $oldlang = $USER->get_account_preference('lang');
     $oldtheme = $USER->get_account_preference('theme');
     $oldgroupsideblockmaxgroups = $USER->get_account_preference('groupsideblockmaxgroups');
     $oldgroupsideblocksortby = $USER->get_account_preference('groupsideblocksortby');
     if (get_config('allowmobileuploads') && isset($prefs['mobileuploadtoken'])) {
         // Make sure the mobile token is formatted / saved correctly
         $prefs['mobileuploadtoken'] = array_filter($prefs['mobileuploadtoken']);
         $new_token_pref = '|' . join('|', $prefs['mobileuploadtoken']) . '|';
         $USER->set_account_preference('mobileuploadtoken', $new_token_pref);
         unset($prefs['mobileuploadtoken']);
     }
     // Set user account preferences
     foreach ($expectedprefs as $eprefkey => $epref) {
         if (isset($prefs[$eprefkey]) && $prefs[$eprefkey] !== get_account_preference($USER->get('id'), $eprefkey)) {
             $USER->set_account_preference($eprefkey, $prefs[$eprefkey]);
         }
     }
     db_commit();
 }
开发者ID:banterweb,项目名称:mahara,代码行数:64,代码来源:BehatAccount.php

示例5: name

 function name($name = null)
 {
     if (!is_null($name)) {
         db_query('update person set name = ? where id = ?', array($name, $this->id));
         db_commit();
         $this->name = $name;
     } elseif (is_null($this->name)) {
         err(_("Person has no name in name() function"));
         // try calling name_or_blank or has_name
     }
     return $this->name;
 }
开发者ID:palfrey,项目名称:phplib,代码行数:12,代码来源:person.php

示例6: delete_tag_submit

function delete_tag_submit(Pieform $form, $values)
{
    global $SESSION, $USER, $tag;
    if (!($userid = $USER->get('id'))) {
        redirect(get_config('wwwroot') . 'edittags.php?tag=' . urlencode($tag));
    }
    db_begin();
    execute_sql("DELETE FROM {view_tag} WHERE tag = ? AND view IN (SELECT id FROM {view} WHERE \"owner\" = ?)", array($tag, $userid));
    execute_sql("DELETE FROM {artefact_tag} WHERE tag = ? AND artefact IN (SELECT id FROM {artefact} WHERE \"owner\" = ?)", array($tag, $userid));
    db_commit();
    $SESSION->add_ok_msg(get_string('tagdeletedsuccessfully'));
    redirect(get_config('wwwroot') . 'tags.php');
}
开发者ID:richardmansfield,项目名称:richardms-mahara,代码行数:13,代码来源:edittags.php

示例7: deleteuser

 public static function deleteuser($event, $user)
 {
     db_begin();
     // Before deleting the user's notifications, remove parent pointers to the
     // messages we're about to delete. The temporary table in this query is
     // required by MySQL
     execute_sql("\n            UPDATE {notification_internal_activity}\n            SET parent = NULL\n            WHERE parent IN (\n                SELECT id FROM (\n                   SELECT id FROM {notification_internal_activity} WHERE usr = ?\n                ) AS temp\n            )", array($user['id']));
     delete_records('notification_internal_activity', 'usr', $user['id']);
     // Delete system messages from this user where the url points to their
     // missing profile.  They're mostly friend requests, which are now useless.
     delete_records_select('notification_internal_activity', '"from" = ? AND type = (SELECT id FROM {activity_type} WHERE name = ?) AND url = ?', array($user['id'], 'maharamessage', get_config('wwwroot') . 'user/view.php?id=' . $user['id']));
     db_commit();
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:13,代码来源:lib.php

示例8: edit_comment_submit

function edit_comment_submit(Pieform $form, $values)
{
    global $viewid, $comment, $SESSION, $goto;
    db_begin();
    $comment->set('description', $values['message']);
    $comment->set('private', 1 - (int) $values['ispublic']);
    $comment->commit();
    require_once 'activity.php';
    $data = (object) array('commentid' => $comment->get('id'), 'viewid' => $viewid);
    activity_occurred('feedback', $data, 'artefact', 'comment');
    db_commit();
    $SESSION->add_ok_msg(get_string('commentupdated', 'artefact.comment'));
    redirect($goto);
}
开发者ID:richardmansfield,项目名称:richardms-mahara,代码行数:14,代码来源:edit.php

示例9: addmembers_submit

function addmembers_submit(Pieform $form, $values)
{
    global $SESSION, $group, $USER;
    if (empty($values['users'])) {
        redirect(get_config('wwwroot') . 'group/inviteusers.php?id=' . GROUP);
    }
    db_begin();
    foreach ($values['users'] as $userid) {
        group_invite_user($group, $userid, $USER->get('id'), 'member', true);
    }
    db_commit();
    $SESSION->add_ok_msg(get_string('invitationssent', 'group', count($values['users'])));
    redirect(get_config('wwwroot') . 'group/members.php?id=' . GROUP);
}
开发者ID:richardmansfield,项目名称:richardms-mahara,代码行数:14,代码来源:inviteusers.php

示例10: editgroup_submit

function editgroup_submit(Pieform $form, $values)
{
    global $USER;
    global $SESSION;
    db_begin();
    $now = db_format_timestamp(time());
    list($grouptype, $jointype) = explode('.', $values['grouptype']);
    $values['public'] = isset($values['public']) ? $values['public'] : 0;
    $values['usersautoadded'] = isset($values['usersautoadded']) ? $values['usersautoadded'] : 0;
    update_record('group', (object) array('id' => $values['id'], 'name' => $values['name'], 'description' => $values['description'], 'grouptype' => $grouptype, 'jointype' => $jointype, 'mtime' => $now, 'usersautoadded' => intval($values['usersautoadded']), 'public' => intval($values['public'])), 'id');
    $SESSION->add_ok_msg(get_string('groupsaved', 'group'));
    db_commit();
    redirect('/group/view.php?id=' . $values['id']);
}
开发者ID:Br3nda,项目名称:mahara,代码行数:14,代码来源:edit.php

示例11: addmembers_submit

function addmembers_submit(Pieform $form, $values)
{
    global $SESSION;
    if (empty($values['users'])) {
        redirect(get_config('wwwroot') . 'group/addmembers.php?id=' . GROUP);
    }
    db_begin();
    foreach ($values['users'] as $userid) {
        group_add_user(GROUP, $userid);
    }
    db_commit();
    $SESSION->add_ok_msg(get_string('newmembersadded', 'group', count($values['users'])));
    redirect(get_config('wwwroot') . 'group/members.php?id=' . GROUP);
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:14,代码来源:addmembers.php

示例12: license_submit

function license_submit(Pieform $form, $values)
{
    global $SESSION;
    $data = new StdClass();
    foreach (array('name', 'displayname', 'shortname', 'icon') as $f) {
        $data->{$f} = trim($values[$f]);
    }
    db_begin();
    delete_records('artefact_license', 'name', $data->name);
    insert_record('artefact_license', $data);
    db_commit();
    $SESSION->add_ok_msg(get_string('licensesaved', 'admin'));
    redirect('/admin/site/licenses.php');
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:14,代码来源:license-edit.php

示例13: loginlink_submit

 /**
  * Link form callback - link the accounts.
  *
  * @param \Pieform $form Pieform instance.
  * @param array $values Submitted values.
  */
 public function loginlink_submit(\Pieform $form, $values)
 {
     global $USER, $SESSION;
     if ($this->authinstance === null || empty($this->oidcusername)) {
         // User is not logged in. They should never reach here, but as a failsafe...
         redirect('/');
     }
     db_begin();
     delete_records('auth_remote_user', 'authinstance', $this->authinstance, 'localusr', $USER->id);
     insert_record('auth_remote_user', (object) array('authinstance' => $this->authinstance, 'remoteusername' => $this->oidcusername, 'localusr' => $USER->id));
     db_commit();
     $SESSION->set('auth_oidc_linkdata', null);
     @session_write_close();
     redirect('/');
 }
开发者ID:remotelearner,项目名称:mahara-auth_oidc,代码行数:21,代码来源:linker.php

示例14: adminusers_submit

function adminusers_submit(Pieform $form, $values)
{
    global $SESSION;
    db_begin();
    execute_sql('UPDATE {usr}
        SET admin = 0
        WHERE admin = 1');
    execute_sql('UPDATE {usr}
        SET admin = 1
        WHERE id IN (' . join(',', array_map('intval', $values['users'])) . ')');
    activity_add_admin_defaults($values['users']);
    db_commit();
    $SESSION->add_ok_msg(get_string('adminusersupdated', 'admin'));
    redirect('/admin/users/admins.php');
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:15,代码来源:admins.php

示例15: submitview_submit

function submitview_submit(Pieform $form, $values)
{
    global $SESSION, $USER, $viewid, $groupid, $group;
    db_begin();
    update_record('view', array('submittedgroup' => $groupid, 'submittedtime' => db_format_timestamp(time())), array('id' => $viewid));
    $roles = get_column('grouptype_roles', 'role', 'grouptype', $group->grouptype, 'see_submitted_views', 1);
    foreach ($roles as $role) {
        $accessrecord = (object) array('view' => $viewid, 'group' => $groupid, 'role' => $role, 'visible' => 0, 'allowcomments' => 1, 'approvecomments' => 0);
        ensure_record_exists('view_access', $accessrecord, $accessrecord);
    }
    ArtefactType::update_locked($USER->get('id'));
    activity_occurred('groupmessage', array('subject' => get_string('viewsubmitted', 'view'), 'message' => get_string('viewsubmitted', 'view'), 'submittedview' => $viewid, 'viewowner' => $USER->get('id'), 'group' => $groupid, 'roles' => $roles, 'strings' => (object) array('urltext' => (object) array('key' => 'view'))));
    db_commit();
    $SESSION->add_ok_msg(get_string('viewsubmitted', 'view'));
    redirect('/' . returnto());
}
开发者ID:richardmansfield,项目名称:richardms-mahara,代码行数:16,代码来源:submit.php


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