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


PHP update_data函数代码示例

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


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

示例1: testCanGetEntitiesByAnnotationCreationTime

 public function testCanGetEntitiesByAnnotationCreationTime()
 {
     $prefix = elgg_get_config('dbprefix');
     $users = elgg_get_entities(array('type' => 'user', 'limit' => 1));
     // create some test annotations
     $subtypes = $this->getRandomValidSubtypes(array('object'), 1);
     $subtype = $subtypes[0];
     $annotation_name = 'test_annotation_name_' . rand();
     // our targets
     $valid1 = new \ElggObject();
     $valid1->subtype = $subtype;
     $valid1->save();
     $id1 = $valid1->annotate($annotation_name, 1, ACCESS_PUBLIC, $users[0]->guid);
     // this one earlier
     $yesterday = time() - 86400;
     update_data("\n\t\t\tUPDATE {$prefix}annotations\n\t\t\tSET time_created = {$yesterday}\n\t\t\tWHERE id = {$id1}\n\t\t");
     $valid2 = new \ElggObject();
     $valid2->subtype = $subtype;
     $valid2->save();
     $valid2->annotate($annotation_name, 1, ACCESS_PUBLIC, $users[0]->guid);
     $options = array('annotation_owner_guid' => $users[0]->guid, 'annotation_created_time_lower' => time() - 3600, 'annotation_name' => $annotation_name);
     $entities = elgg_get_entities_from_annotations($options);
     $this->assertEqual(1, count($entities));
     $this->assertEqual($valid2->guid, $entities[0]->guid);
     $options = array('annotation_owner_guid' => $users[0]->guid, 'annotation_created_time_upper' => time() - 3600, 'annotation_name' => $annotation_name);
     $entities = elgg_get_entities_from_annotations($options);
     $this->assertEqual(1, count($entities));
     $this->assertEqual($valid1->guid, $entities[0]->guid);
     $valid1->delete();
     $valid2->delete();
 }
开发者ID:elgg,项目名称:elgg,代码行数:31,代码来源:ElggCoreGetEntitiesFromAnnotationsTest.php

示例2: create_object_entity

/**
 * Create or update the extras table for a given object.
 * Call create_entity first.
 *
 * @param int    $guid        The guid of the entity you're creating (as obtained by create_entity)
 * @param string $title       The title of the object
 * @param string $description The object's description
 *
 * @return bool
 */
function create_object_entity($guid, $title, $description)
{
    global $CONFIG;
    $guid = (int) $guid;
    $title = sanitise_string($title);
    $description = sanitise_string($description);
    $row = get_entity_as_row($guid);
    if ($row) {
        // Core entities row exists and we have access to it
        $query = "SELECT guid from {$CONFIG->dbprefix}objects_entity where guid = {$guid}";
        if ($exists = get_data_row($query)) {
            $query = "UPDATE {$CONFIG->dbprefix}objects_entity\n\t\t\t\tset title='{$title}', description='{$description}' where guid={$guid}";
            $result = update_data($query);
            if ($result != false) {
                // Update succeeded, continue
                $entity = get_entity($guid);
                elgg_trigger_event('update', $entity->type, $entity);
                return $guid;
            }
        } else {
            // Update failed, attempt an insert.
            $query = "INSERT into {$CONFIG->dbprefix}objects_entity\n\t\t\t\t(guid, title, description) values ({$guid}, '{$title}','{$description}')";
            $result = insert_data($query);
            if ($result !== false) {
                $entity = get_entity($guid);
                if (elgg_trigger_event('create', $entity->type, $entity)) {
                    return $guid;
                } else {
                    $entity->delete();
                }
            }
        }
    }
    return false;
}
开发者ID:portokallidis,项目名称:Metamorphosis-Meducator,代码行数:45,代码来源:objects.php

示例3: upgrade_20141130

function upgrade_20141130()
{
    $upgrade_version = get_upgrade_version();
    if ($upgrade_version >= UPGRADE_VERSION) {
        return true;
    }
    $site = elgg_get_site_entity();
    $dbprefix = elgg_get_config('dbprefix');
    // move ip tracking from heavy object entities to lighter-weight annotations
    $options = array("type" => "object", "subtype" => "spam_login_filter_ip", 'limit' => false);
    $batch = new ElggBatch('elgg_get_entities', $options, null, 50, false);
    $week_ago = time() - 604800;
    // just delete anything over a week old
    foreach ($batch as $e) {
        // create a new record as an annotation and delete the entity
        if ($e->time_created > $week_ago) {
            $id = $site->annotate('spam_login_filter_ip', $e->ip_address, ACCESS_PUBLIC);
            if ($id) {
                $sql = "UPDATE {$dbprefix}annotations SET time_created = {$e->time_created} WHERE id = {$id}";
                update_data($sql);
            }
        }
        $e->delete();
    }
    set_upgrade_version(20141130);
}
开发者ID:n8b,项目名称:VMN,代码行数:26,代码来源:upgrades.php

示例4: dbvalidate_fix_bad_entities

function dbvalidate_fix_bad_entities()
{
    $db_prefix = elgg_get_config('dbprefix');
    $guid = elgg_get_logged_in_user_guid();
    $query = "UPDATE {$db_prefix}entities e LEFT JOIN {$db_prefix}entities o ON e.owner_guid = o.guid" . " SET e.owner_guid = {$guid}" . " WHERE (e.type = 'object' OR e.type='group') AND (o.guid IS NULL OR o.guid = 0)";
    update_data($query);
}
开发者ID:iionly,项目名称:dbvalidator,代码行数:7,代码来源:start.php

示例5: upgrade_1395099219

function upgrade_1395099219()
{
    // updating river entries
    $dbprefix = elgg_get_config('dbprefix');
    $query = "UPDATE {$dbprefix}river r\n\t\tSET r.view = 'framework/mechanics/river/claim'\n\t\tWHERE r.view = 'river/object/hjformsubmission/create' AND r.action_type = 'claim'";
    update_data($query);
}
开发者ID:amcfarlane1251,项目名称:ongarde,代码行数:7,代码来源:upgrade.php

示例6: index

 /**
  *用户修改昵称
  *	用户在个人中心可以修改自己的昵称
  *流程分析
  *	判断用户新昵称和旧昵称是否一致
  *	将新昵称写入数据库
  **/
 public function index()
 {
     $home_member_id = session('home_member_id');
     $member_info = get_info($this->table, array('id' => $home_member_id));
     if (IS_POST) {
         $nickname = I('nickname');
         if ($member_info['nickname'] == $nickname) {
             $this->error('您的昵称未作修改!');
         }
         unset($_POST);
         $_POST['id'] = session('home_member_id');
         $_POST['nickname'] = $nickname;
         $result = update_data($this->table);
         if (is_numeric($result)) {
             session('nickname', $_POST['nickname']);
             //更新缓存
             $this->success('修改成功!', U('User/UpdateName/index'), $ajax);
         } else {
             $this->error('修改失败,请联系客服!', U('User/UpdateName/index'), $ajax);
         }
     } else {
         $data['member_info'] = $member_info;
         $this->assign($data);
         $this->display();
     }
 }
开发者ID:976112643,项目名称:manor,代码行数:33,代码来源:UpdateNameController.class.php

示例7: profile_manager_run_once

function profile_manager_run_once()
{
    global $CONFIG;
    // upgrade
    $profile_field_class_name = "ProfileManagerCustomProfileField";
    $group_field_class_name = "ProfileManagerCustomGroupField";
    $field_type_class_name = "ProfileManagerCustomProfileType";
    $field_category_class_name = "ProfileManagerCustomFieldCategory";
    if ($id = get_subtype_id('object', ProfileManagerCustomProfileField::SUBTYPE)) {
        update_data("UPDATE {$CONFIG->dbprefix}entity_subtypes set class='{$profile_field_class_name}' WHERE id={$id}");
    } else {
        add_subtype('object', ProfileManagerCustomProfileField::SUBTYPE, $profile_field_class_name);
    }
    if ($id = get_subtype_id('object', ProfileManagerCustomGroupField::SUBTYPE)) {
        update_data("UPDATE {$CONFIG->dbprefix}entity_subtypes set class='{$group_field_class_name}' WHERE id={$id}");
    } else {
        add_subtype('object', ProfileManagerCustomGroupField::SUBTYPE, $group_field_class_name);
    }
    if ($id = get_subtype_id('object', ProfileManagerCustomProfileType::SUBTYPE)) {
        update_data("UPDATE {$CONFIG->dbprefix}entity_subtypes set class='{$field_type_class_name}' WHERE id={$id}");
    } else {
        add_subtype('object', ProfileManagerCustomProfileType::SUBTYPE, $field_type_class_name);
    }
    if ($id = get_subtype_id('object', ProfileManagerCustomFieldCategory::SUBTYPE)) {
        update_data("UPDATE {$CONFIG->dbprefix}entity_subtypes set class='{$field_category_class_name}' WHERE id={$id}");
    } else {
        add_subtype('object', ProfileManagerCustomFieldCategory::SUBTYPE, $field_category_class_name);
    }
}
开发者ID:portokallidis,项目名称:Metamorphosis-Meducator,代码行数:29,代码来源:start.php

示例8: testCanUpdateData

 public function testCanUpdateData()
 {
     _elgg_services()->db->addQuerySpec(['sql' => 'UPDATE A SET b = :b WHERE c = :c', 'params' => [':b' => 'b', ':c' => 'c'], 'row_count' => 20]);
     _elgg_services()->db->addQuerySpec(['sql' => 'UPDATE A SET b = :b WHERE d = :d', 'params' => [':b' => 'b', ':d' => 'd'], 'row_count' => 0]);
     $this->assertTrue(update_data('UPDATE A SET b = :b WHERE c = :c', [':b' => 'b', ':c' => 'c']));
     $this->assertEquals(20, update_data('UPDATE A SET b = :b WHERE c = :c', [':b' => 'b', ':c' => 'c'], true));
     $this->assertTrue(update_data('UPDATE A SET b = :b WHERE d = :d', [':b' => 'b', ':d' => 'd']));
     $this->assertEquals(0, update_data('UPDATE A SET b = :b WHERE d = :d', [':b' => 'b', ':d' => 'd'], true));
 }
开发者ID:elgg,项目名称:elgg,代码行数:9,代码来源:DatabaseTest.php

示例9: pages_2012061800

/**
 * Update subtype
 *
 * @param ElggObject $page
 */
function pages_2012061800($page)
{
    $dbprefix = elgg_get_config('dbprefix');
    $subtype_id = (int) get_subtype_id('object', 'page_top');
    $page_guid = (int) $page->guid;
    update_data("UPDATE {$dbprefix}entities\n\t\tSET subtype = {$subtype_id} WHERE guid = {$page_guid}");
    error_log("called");
    return true;
}
开发者ID:duanhv,项目名称:mdg-social,代码行数:14,代码来源:2012061800.php

示例10: setStatus

 function setStatus($field = "status")
 {
     $ids = I('ids');
     if (!$ids) {
         return array('status' => '0', 'msg' => '请选择要修改的数据');
         // 			$this->error('请选择要修改的数据');
     }
     $field_val = intval(I('get.' . $field));
     if (is_array($ids)) {
         $_POST = array($field => $field_val);
         $map['id'] = array('in', $ids);
         //$result=update_data($this->table,array(),$map);
         $Model = M($this->table);
         // 实例化User对象
         $Model->where($map)->save($_POST);
         // 根据条件更新记录
         $ids_str = implode(',', $ids);
         /*如果该表数据有缓存,那么删除缓存*/
         if ($this->cache_data != '') {
             F($this->cache_data, NULL);
         }
         if ($this->session_cache_name != '') {
             session($this->session_cache_name, NULL);
         }
         if ($this->has_parent) {
             $this->parent_operate();
         }
         return array('status' => '1', 'msg' => '操作成功');
         // 			$this->success('操作成功');
     } else {
         $ids = intval($ids);
         if (!$ids) {
             return array('status' => '0', 'msg' => '请选择要修改的数据');
             // 				$this->error('请选择要操作的数据');
         }
         $_POST = array('id' => $ids, $field => $field_val);
         $result = update_data($this->table);
         if (is_numeric($result)) {
             /*如果该表数据有缓存,那么删除缓存*/
             if ($this->cache_data != '') {
                 F($this->cache_data, NULL);
             }
             if ($this->session_cache_name != '') {
                 session($this->session_cache_name, NULL);
             }
             if ($this->has_parent) {
                 $this->parent_operate();
             }
             return array('status' => '1', 'msg' => '操作成功');
             // 				$this->success('操作成功');
         } else {
             return array('status' => '0', 'msg' => $result);
             // 				$this->error($result);
         }
     }
 }
开发者ID:976112643,项目名称:manor,代码行数:56,代码来源:HomeController.class.php

示例11: upgrade_izap_videos_to

function upgrade_izap_videos_to($version)
{
    global $CONFIG;
    $update_entity_subtype = "UPDATE {$CONFIG->dbprefix}entity_subtypes SET class = 'IzapVideos' WHERE subtype = 'izap_videos'";
    $del_entity_query = "DELETE FROM {$CONFIG->dbprefix}entities\n                WHERE subtype IN (SELECT id FROM {$CONFIG->dbprefix}entity_subtypes\n                                  WHERE subtype='izapVideoQueue')";
    $del_queue_object_query = "DELETE FROM {$CONFIG->dbprefix}entity_subtypes where subtype='izapVideoQueue'";
    if (update_data($update_entity_subtype) || (delete_data($del_entity_query) || delete_data($del_queue_object_query))) {
        datalist_set('izap_videos_version', $version);
    }
}
开发者ID:rimpy,项目名称:izap_videos,代码行数:10,代码来源:upgrade.php

示例12: index

 /**
  *用户修改头像
  *	用户在个人中心可以修改自己的头像
  *流程分析
  *	1、接收用户的号码和验证码
  *	2、验证验证码
  *		验证码要和提交的手机一致
  *	3、修改用户的手机号码
  **/
 public function index()
 {
     //手机app参数
     $apptype = (!empty(I('post.apptype')) and I('post.apptype') == C('APP_KEY')) ? true : false;
     //手机app接口密钥
     //手机app与电脑客户端参数区分
     if ($apptype) {
         $app_key = trim(I("post.key"));
         //md5加密的登录时间
         $home_member_id = I("post.home_member_id");
         $this->isLoginExpire($app_key, $member_id);
         //判断登录过期
         $ajax = true;
         $update_phone = trim(I('update_phone'));
         $update_code = trim(I('update_code'));
     } else {
         $ajax = false;
         $home_member_id = session('home_member_id');
         $update_phone = session('update_phone');
         $update_code = session('update_code');
     }
     //获取用户信息
     $member_info = get_info($this->table, array('id' => $home_member_id));
     if (!$member_info) {
         $this->error("未获取到您的信息", '', $ajax);
     }
     if (IS_POST) {
         //接收用户的手机号码
         $member_telephone = trim(I('newPhone'));
         $code = trim(I('code'));
         //验证号码是否做了修改
         if ($member_info['telephone'] == $member_telephone) {
             $this->error('您的手机未作修改!!', '', $ajax);
         }
         //验证验证码的正确性
         if ($member_telephone != $update_phone || $code != $update_code) {
             $this->error('您的验证码有误!', '', $ajax);
         }
         unset($_POST);
         ///dump($code);
         $_POST['id'] = intval($home_member_id);
         $_POST['telephone'] = $member_telephone;
         $result = update_data($this->table);
         if (is_numeric($result)) {
             $this->success('修改成功!', U('User/UpdatePhone/index'), $ajax);
         } else {
             $this->error('修改失败,请联系客服!', U('User/UpdatePhone/index'), $ajax);
         }
     } else {
         $data['member_info'] = $member_info;
         $this->assign($data);
         $this->display();
     }
 }
开发者ID:976112643,项目名称:manor,代码行数:63,代码来源:UpdatePhoneController.class.php

示例13: update_page

function update_page()
{
    global $user, $sql_updates;
    if (isset($_POST['edit'])) {
        $edit = $_POST['edit'];
    }
    if (isset($_POST['op'])) {
        $op = $_POST['op'];
    }
    switch ($op) {
        case "Update":
            // make sure we have updates to run.
            print update_page_header("Drupal database update");
            $links[] = "<a href=\"index.php\">main page</a>";
            $links[] = "<a href=\"index.php?q=admin\">administration pages</a>";
            print theme("item_list", $links);
            // NOTE: we can't use l() here because the URL would point to 'update.php?q=admin'.
            if ($edit["start"] == -1) {
                print "No updates to perform.";
            } else {
                update_data($edit["start"]);
            }
            print "<br />Updates were attempted. If you see no failures above, you may proceed happily to the <a href=\"index.php?q=admin\">administration pages</a>.";
            print " Otherwise, you may need to update your database manually.";
            print update_page_footer();
            break;
        default:
            // NOTE: We need the following five lines in order to fix a bug with
            //       database.mysql (issue #15337).  We should be able to remove
            //       this work around in the future.
            $result = db_query("SELECT * FROM {variable} WHERE name = 'update_start' AND value LIKE '%;\"'");
            if ($variable = db_fetch_object($result)) {
                $variable->value = unserialize(substr($variable->value, 0, -2) . '";');
                variable_set('update_start', $variable->value);
            }
            $start = variable_get("update_start", 0);
            $dates[] = "All";
            $i = 1;
            foreach ($sql_updates as $date => $sql) {
                $dates[$i++] = $date;
                if ($date == $start) {
                    $selected = $i;
                }
            }
            $dates[$i] = "No updates available";
            // make update form and output it.
            $form = form_select("Perform updates from", "start", isset($selected) ? $selected : -1, $dates, "This defaults to the first available update since the last update you performed.");
            $form .= form_submit("Update");
            print update_page_header("Drupal database update");
            print form($form);
            print update_page_footer();
            break;
    }
}
开发者ID:BackupTheBerlios,项目名称:astbill-svn,代码行数:54,代码来源:update.php

示例14: action_log

function action_log($table_name, $table_id = 0, $action_filed = 'id,title')
{
    $url = strtolower(MODULE_NAME . '/' . CONTROLLER_NAME . '/' . ACTION_NAME);
    if (is_numeric($table_id)) {
        $map['id'] = $table_id;
    } else {
        $map['id'] = array('in', $table_id);
    }
    $result = get_result($table_name, $map, $action_filed);
    $_POST = array('member_id' => session('member_id'), 'username' => session('username'), 'url' => $url, 'table_name' => $table_name, 'table_id' => $table_id, 'description' => json_encode($result), 'ip' => get_client_ip());
    update_data('action_log');
}
开发者ID:976112643,项目名称:manor,代码行数:12,代码来源:function.php

示例15: update

 protected function update()
 {
     $rules = array(array('title', 'require', '标题必须!', 1), array('content', 'require', '内容必须!', 1));
     $_POST['content'] = replaceStrImg($_POST['content'], "replace");
     $_POST['type'] = $this->type;
     $result = update_data($this->table, $rules);
     if (is_numeric($result)) {
         $this->success('操作成功!', U('index'));
     } else {
         $this->error($result);
     }
 }
开发者ID:976112643,项目名称:manor,代码行数:12,代码来源:IndexController.class.php


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