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


PHP DB::beginTransaction方法代码示例

本文整理汇总了PHP中OCP\DB::beginTransaction方法的典型用法代码示例。如果您正苦于以下问题:PHP DB::beginTransaction方法的具体用法?PHP DB::beginTransaction怎么用?PHP DB::beginTransaction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OCP\DB的用法示例。


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

示例1: delete

 public function delete($id)
 {
     \OCP\DB::beginTransaction();
     $query = \OCP\DB::prepare('DELETE FROM *PREFIX*ownboard_postit_comments ' . 'WHERE id = ?');
     $query->execute(array($id));
     \OCP\DB::commit();
 }
开发者ID:nerzhul,项目名称:ownBoard,代码行数:7,代码来源:commentmapper.php

示例2: notifyUserDeletion

    /**
     * Handle user removal from ownCloud
     */
    public static function notifyUserDeletion($args)
    {
        try {
            \OCP\DB::beginTransaction();
            $query = \OCP\DB::prepare('SELECT `pid`, `title` FROM `*PREFIX*collaboration_project` WHERE `pid` IN 
										(SELECT DISTINCT(`pid`) FROM `*PREFIX*collaboration_works_on` WHERE `member`=?) AND `completed`=?');
            $result = $query->execute(array($args['uid'], false));
            $projs = $result->fetchAll();
            if (count($projs) != 0) {
                $projects = $projs[0]['title'];
                $pids = $projs[0]['pid'];
                for ($i = 1; $i < count($projs); $i++) {
                    $projects .= ', ' . $projs[$i]['title'];
                    $pids .= ' ' . $projs[$i]['pid'];
                }
                OC_Collaboration_Post::createPost('Member Removed', 'Owncloud member \'' . $args['uid'] . '\' has been removed from owncloud and hence from the project(s) ' . $projects, OC_User::getUser(), NULL, 'Member removal', OC_Collaboration_Project::getMembersWorkingOnProjects(explode(' ', $pids)), true);
            }
            OC_Collaboration_Project::deleteMemberRole(NULL, $args['uid'], NULL, OC_User::getUser(), true);
            OC_Collaboration_Skillset::removeSkillsOfMember($args['uid']);
            OC_Collaboration_Post::removePostsByMember($args['uid'], true);
            \OCP\DB::commit();
            OC_Log::write('collaboration', 'User deletion notification posted.', OCP\Util::INFO);
        } catch (\Exception $e) {
            OC_Log::write('collaboration', __METHOD__ . ', Exception: ' . $e->getMessage(), OCP\Util::DEBUG);
            return false;
        }
    }
开发者ID:pjrobertson,项目名称:owncloud-collaboration,代码行数:30,代码来源:hooks.php

示例3: setLast

 public function setLast($userId, $phoneNumber, $lastDate)
 {
     \OCP\DB::beginTransaction();
     $query = \OCP\DB::prepare('DELETE FROM *PREFIX*ocsms_conversation_read_states ' . 'WHERE user_id = ? AND phone_number = ?');
     $query->execute(array($userId, $phoneNumber));
     $query = \OCP\DB::prepare('INSERT INTO *PREFIX*ocsms_conversation_read_states' . '(user_id, phone_number, int_date) VALUES ' . '(?,?,?)');
     $query->execute(array($userId, $phoneNumber, $lastDate));
     \OCP\DB::commit();
 }
开发者ID:nerzhul,项目名称:ocsms,代码行数:9,代码来源:conversationstatemapper.php

示例4: setSetting

 public function setSetting($settingName, $userId, $settingValue)
 {
     \OCP\DB::beginTransaction();
     $query = \OCP\DB::prepare('DELETE FROM *PREFIX*weather_config ' . 'WHERE `user` = ? and `key` = ?');
     $query->execute(array($userId, $settingName));
     $query = \OCP\DB::prepare('INSERT INTO *PREFIX*weather_config ' . '(`user`,`key`,`value`) VALUES (?,?,?)');
     $query->execute(array($userId, $settingName, $settingValue));
     \OCP\DB::commit();
 }
开发者ID:nerzhul,项目名称:owncloud-weather,代码行数:9,代码来源:settingsmapper.php

示例5: logRead

 public static function logRead($params)
 {
     //LOG: user, path, time
     // $logstring = \OCP\User::getUser().", ".$params['path'].", ".date("d-m-Y H:i:s");
     $sql = "insert into `*PREFIX*accessstats_items` (`username`,`path`,`time`) values (?,?,?)";
     \OCP\DB::beginTransaction();
     $query = \OCP\DB::prepare($sql);
     $result = $query->execute(array(\OCP\User::getUser(), $params['path'], time()));
     \OCP\DB::commit();
 }
开发者ID:nickbooties,项目名称:accessstats,代码行数:10,代码来源:hooks.php

示例6: delete

 public function delete($id)
 {
     \OCP\DB::beginTransaction();
     // First delete comments in postits in the category
     $query = \OCP\DB::prepare('DELETE FROM *PREFIX*ownboard_postit_comments ' . 'WHERE postit_id IN (SELECT id FROM *PREFIX*ownboard_postit ' . 'WHERE category_id = ?)');
     $query->execute(array($id));
     // Next delete postits in the category
     $query = \OCP\DB::prepare('DELETE FROM *PREFIX*ownboard_postit ' . 'WHERE category_id = ?');
     $query->execute(array($id));
     // Then delete the category
     $query = \OCP\DB::prepare('DELETE FROM *PREFIX*ownboard_category ' . 'WHERE id = ?');
     $query->execute(array($id));
     \OCP\DB::commit();
 }
开发者ID:nerzhul,项目名称:ownBoard,代码行数:14,代码来源:categorymapper.php

示例7: create

 public function create($userId, $name)
 {
     \OCP\DB::beginTransaction();
     $query = \OCP\DB::prepare('INSERT INTO *PREFIX*weather_city ' . '(user_id, name) VALUES (?,?)');
     $query->execute(array($userId, $name));
     \OCP\DB::commit();
     $sql = 'SELECT max(id) as maxid FROM ' . '*PREFIX*weather_city WHERE user_id = ? and name = ?';
     $query = \OCP\DB::prepare($sql);
     $result = $query->execute(array($userId, $name));
     if ($row = $result->fetchRow()) {
         return $row['maxid'];
     }
     return null;
 }
开发者ID:nerzhul,项目名称:owncloud-weather,代码行数:14,代码来源:citymapper.php

示例8: create

 public function create($categoryId, $title)
 {
     $now = date("Y-m-d H:i:s");
     \OCP\DB::beginTransaction();
     $query = \OCP\DB::prepare('INSERT INTO *PREFIX*ownboard_postit' . '(title, category_id, last_update) VALUES (?,?,?)');
     $query->execute(array($title, $categoryId, $now));
     \OCP\DB::commit();
     $sql = 'SELECT max(id) FROM ' . '*PREFIX*ownboard_postit WHERE category_id = ? and title = ? ' . 'and last_update = ?';
     $query = \OCP\DB::prepare($sql);
     $result = $query->execute(array($categoryId, $title, $now));
     if ($row = $result->fetchRow()) {
         return array("id" => $row['max'], "last_update" => $now);
     }
     return null;
 }
开发者ID:nerzhul,项目名称:ownBoard,代码行数:15,代码来源:postitmapper.php

示例9: reset

 /**
  * Reset the flag to true for all accounts
  * @param OutputInterface $output
  */
 protected function reset($output)
 {
     try {
         \OCP\DB::beginTransaction();
         $sql = "UPDATE *PREFIX*preferences\n                        SET configvalue = 1\n                        WHERE appid = 'user_set_password' AND configkey = 'show'";
         $stmt = \OCP\DB::prepare($sql);
         $rowCount = $stmt->execute();
         \OCP\DB::commit();
         $this->consoleDisplay(' flags have been resetted to "true".');
     } catch (\Exception $e) {
         // rollBack not implemented in \OCP\DB! (ownCloud 7.0.5)
         $conn = \OCP\DB::getConnection();
         $conn->rollBack();
         $this->consoleDisplay('Fatal error: ' . $e->getMessage(), self::ERROR);
     }
 }
开发者ID:ppaysant,项目名称:user_set_password,代码行数:20,代码来源:uspreset.php

示例10: Init

 /**
  * Create a flag set to false for each existing account
  * @param OutputInterface $output
  */
 protected function Init($output)
 {
     try {
         \OCP\DB::beginTransaction();
         $sql = "INSERT INTO *PREFIX*preferences\n                        (SELECT uid, 'user_set_password', 'show', 0 FROM oc_users)\n                        ON duplicate key UPDATE configvalue = 0";
         $stmt = \OCP\DB::prepare($sql);
         $rowCount = $stmt->execute();
         \OCP\DB::commit();
         $this->consoleDisplay(' flags have been initialized to "false".');
     } catch (\Exception $e) {
         // rollBack not implemented in \OCP\DB! (ownCloud 7.0.5)
         $conn = \OCP\DB::getConnection();
         $conn->rollBack();
         $this->consoleDisplay('Fatal error: ' . $e->getMessage(), self::ERROR);
     }
 }
开发者ID:ppaysant,项目名称:user_set_password,代码行数:20,代码来源:uspinit.php

示例11: editComment

 /**
  * @brief Alter the contents of a comment
  * @param Comment ID
  * @param Modified content to be presented in the comment
  * @return date|boolean (Modified time|false)
  */
 public static function editComment($comment_id, $content)
 {
     try {
         \OCP\DB::beginTransaction();
         $query = \OCP\DB::prepare('UPDATE `*PREFIX*collaboration_comment` SET `content`=?, `time`=CURRENT_TIMESTAMP WHERE `comment_id`=?');
         $result = $query->execute(array($content, $comment_id));
         $query = \OCP\DB::prepare('SELECT `time` FROM `*PREFIX*collaboration_comment` WHERE `comment_id`=?');
         $result = $query->execute(array($comment_id));
         $time = NULL;
         if ($row = $result->fetchRow()) {
             $time = $row['time'];
         }
         \OCP\DB::commit();
         return $time;
     } catch (\Exception $e) {
         OC_Log::write('collaboration', __METHOD__ . ', Exception: ' . $e->getMessage(), OCP\Util::DEBUG);
         return false;
     }
 }
开发者ID:TheAgentK,项目名称:owncloud-collaboration,代码行数:25,代码来源:comments.php

示例12: deleteMemberRole

 /**
  * @brief Delete a member from a role of a project
  * @param Project ID from which the role has to be removed
  * @param Member whose role has to be removed
  * @param Role to be removed
  * @param Member who removed the other member from his/her role
  * @param Whether the calling method has already initiated the (database) transaction
  * @return int|boolean (ID of the post intimating the role removal|false)
  */
 public static function deleteMemberRole($pid, $member, $role, $user, $inTransaction = false)
 {
     try {
         if (!$inTransaction) {
             \OCP\DB::beginTransaction();
         }
         // Remove from all roles
         if (is_null($pid) && is_null($role)) {
             $query = \OCP\DB::prepare('DELETE FROM `*PREFIX*collaboration_works_on` WHERE `member`=?');
             $result = $query->execute(array($member));
         } else {
             $query = \OCP\DB::prepare('DELETE FROM `*PREFIX*collaboration_works_on` WHERE `pid`=? AND `member`=? AND `role`=?');
             $result = $query->execute(array($pid, $member, $role));
         }
         // Member removed from owncloud
         if (is_null($pid)) {
             OC_Collaboration_Task::removeMembersTasks($member, $user, true);
         } else {
             if (!self::isMemberWorkingOnProject($member, $pid)) {
                 OC_Collaboration_Task::unassignMembersTasks($member, $pid, $user, true);
             }
         }
         $post_id = OC_Collaboration_Post::createPost('Removed from role', 'You are removed from \'' . $role . '\' role from project \'' . self::getProjectTitle($pid) . '\'.', $user, $pid, 'Role Deletion', array($member), true);
         if (!$inTransaction) {
             \OCP\DB::commit();
         }
         return $post_id;
     } catch (\Exception $e) {
         OC_Log::write('collaboration', __METHOD__ . ', Exception: ' . $e->getMessage(), OCP\Util::DEBUG);
         return false;
     }
 }
开发者ID:TheAgentK,项目名称:owncloud-collaboration,代码行数:41,代码来源:projects.php

示例13: writeToDB

 public function writeToDB($userId, $smsList, $purgeAllSmsBeforeInsert = false)
 {
     \OCP\DB::beginTransaction();
     if ($purgeAllSmsBeforeInsert === true) {
         $query = \OCP\DB::prepare('DELETE FROM *PREFIX*ocsms_smsdatas ' . 'WHERE user_id = ?');
         $result = $query->execute(array($userId));
     }
     foreach ($smsList as $sms) {
         $smsFlags = sprintf("%s%s", $sms["read"] === "true" ? "1" : "0", $sms["seen"] === "true" ? "1" : "0");
         // Only delete if we haven't purged the DB
         if ($purgeAllSmsBeforeInsert === false) {
             // Remove previous record
             // @ TODO: only update the required fields, getAllIds can be useful
             $query = \OCP\DB::prepare('DELETE FROM *PREFIX*ocsms_smsdatas ' . 'WHERE user_id = ? AND sms_id = ?');
             $result = $query->execute(array($userId, (int) $sms["_id"]));
         }
         $now = date("Y-m-d H:i:s");
         $query = \OCP\DB::prepare('INSERT INTO *PREFIX*ocsms_smsdatas ' . '(user_id, added, lastmodified, sms_flags, sms_date, sms_id,' . 'sms_address, sms_msg, sms_mailbox, sms_type) VALUES ' . '(?,?,?,?,?,?,?,?,?,?)');
         $result = $query->execute(array($userId, $now, $now, $smsFlags, $sms["date"], (int) $sms["_id"], $sms["address"], $sms["body"], (int) $sms["mbox"], (int) $sms["type"]));
     }
     \OCP\DB::commit();
 }
开发者ID:nerzhul,项目名称:ocsms,代码行数:22,代码来源:smsmapper.php

示例14: editPost

 /**
  * @brief Edit the given post with the given title and content
  * @param Post ID
  * @param Title of the post
  * @param Modified post content
  * @return boolean (true|false)
  */
 public static function editPost($post_id, $title, $content)
 {
     try {
         \OCP\DB::beginTransaction();
         $query = \OCP\DB::prepare('UPDATE `*PREFIX*collaboration_post` SET `title`=?, `content`=?, `time`=CURRENT_TIMESTAMP WHERE `post_id`=?');
         $del_comment = \OCP\DB::prepare('DELETE FROM `*PREFIX*collaboration_comment` WHERE `post_id`=?');
         $result = $query->execute(array($title, $content, $post_id));
         $result = $del_comment->execute(array($post_id));
         \OCP\DB::commit();
         return true;
     } catch (\Exception $e) {
         OC_Log::write('collaboration', __METHOD__ . ', Exception: ' . $e->getMessage(), OCP\Util::DEBUG);
         return false;
     }
 }
开发者ID:TheAgentK,项目名称:owncloud-collaboration,代码行数:22,代码来源:posts.php

示例15: explode

     $collection->deleteSongByPath($path);
     $paths = explode(PATH_SEPARATOR, \OCP\Config::getUserValue(\OCP\USER::getUser(), 'media', 'paths', ''));
     if (array_search($path, $paths) !== false) {
         unset($paths[array_search($path, $paths)]);
         \OCP\Config::setUserValue(\OCP\USER::getUser(), 'media', 'paths', implode(PATH_SEPARATOR, $paths));
     }
     break;
 case 'get_collection':
     $data = array();
     $data['artists'] = $collection->getArtists();
     $data['albums'] = $collection->getAlbums();
     $data['songs'] = $collection->getSongs();
     \OCP\JSON::encodedPrint($data);
     break;
 case 'scan':
     \OCP\DB::beginTransaction();
     set_time_limit(0);
     //recursive scan can take a while
     $eventSource = new \OC_EventSource();
     $watcher = new ScanWatcher($eventSource);
     $scanner = new Scanner($collection);
     \OC_Hook::connect('media', 'song_count', $watcher, 'count');
     \OC_Hook::connect('media', 'song_scanned', $watcher, 'scanned');
     $scanner->scanCollection();
     $watcher->done();
     $eventSource->close();
     \OCP\DB::commit();
     break;
 case 'scanFile':
     $scanner = new Scanner($collection);
     echo $scanner->scanFile($arguments['path']) ? 'true' : 'false';
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:31,代码来源:api.php


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