• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP OCP\DB类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: uuidExists

 /**
  * @brief returns true if and only if a user with the given uuid exists in the LDAP
  * @param string a unique user identifier
  * @return a boolean value
  */
 public function uuidExists($uuid)
 {
     //check backend status
     if (!$this->enabled) {
         return false;
     }
     //check tables
     $query = \OCP\DB::prepare('SELECT COUNT(*) FROM *PREFIX*ldap_user_mapping WHERE owncloud_name = ?');
     $result = $query->execute(array($uuid));
     if (!\OCP\DB::isError($result)) {
         $count = $result->fetchAll(\PDO::FETCH_COLUMN, 0);
         if ($count[0] === 1) {
             return true;
         }
     }
     //check primary LDAP server
     $this->connect();
     $uuid = $this->access->escapeFilterPart($uuid);
     $filter = \OCP\Util::mb_str_replace('%uid', $uuid, $this->access->connection->ldapLoginFilter, 'UTF-8');
     $result = $this->access->fetchListOfUsers($filter, $this->connection->ldapUuidAttribute);
     if (count($result) === 1 && $result[0]['count'] === 1) {
         return true;
     }
     return false;
 }
开发者ID:GIP-RECIA,项目名称:user_cas,代码行数:30,代码来源:ldap_backend_adapter.php


示例2: testShareMountLoseParentFolder

 /**
  * test if the mount point moves up if the parent folder no longer exists
  */
 function testShareMountLoseParentFolder()
 {
     // share to user
     $fileinfo = $this->view->getFileInfo($this->folder);
     $result = \OCP\Share::shareItem('folder', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, 31);
     $statement = "UPDATE `*PREFIX*share` SET `file_target` = ? where `share_with` = ?";
     $query = \OCP\DB::prepare($statement);
     $arguments = array('/foo/bar' . $this->folder, self::TEST_FILES_SHARING_API_USER2);
     $query->execute($arguments);
     $query = \OCP\DB::prepare('SELECT * FROM `*PREFIX*share`');
     $result = $query->execute();
     $shares = $result->fetchAll();
     $this->assertSame(1, count($shares));
     $share = reset($shares);
     $this->assertSame('/foo/bar' . $this->folder, $share['file_target']);
     self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
     // share should have moved up
     $query = \OCP\DB::prepare('SELECT * FROM `*PREFIX*share`');
     $result = $query->execute();
     $shares = $result->fetchAll();
     $this->assertSame(1, count($shares));
     $share = reset($shares);
     $this->assertSame($this->folder, $share['file_target']);
     //cleanup
     self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
     \OCP\Share::unshare('folder', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2);
     $this->view->unlink($this->folder);
 }
开发者ID:evanjt,项目名称:core,代码行数:31,代码来源:sharedmount.php


示例3: 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


示例4: 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


示例5: deleteTestActivities

 protected function deleteTestActivities()
 {
     $query = DB::prepare('DELETE FROM `*PREFIX*activity` WHERE `app` = ?');
     $query->execute(array('test'));
     $query = DB::prepare('DELETE FROM `*PREFIX*activity_mq` WHERE `amq_appid` = ?');
     $query->execute(array('test'));
 }
开发者ID:enoch85,项目名称:owncloud-testserver,代码行数:7,代码来源:consumertest.php


示例6: run

 /**
  * Background scanner main job
  * @return null
  */
 public function run()
 {
     if (!$this->initFS()) {
         return;
     }
     // locate files that are not checked yet
     $dirMimetypeId = \OC::$server->getMimeTypeLoader()->getId('httpd/unix-directory');
     $sql = 'SELECT `*PREFIX*filecache`.`fileid`, `*PREFIX*storages`.*' . ' FROM `*PREFIX*filecache`' . ' LEFT JOIN `*PREFIX*files_antivirus` ON `*PREFIX*files_antivirus`.`fileid` = `*PREFIX*filecache`.`fileid`' . ' JOIN `*PREFIX*storages` ON `*PREFIX*storages`.`numeric_id` = `*PREFIX*filecache`.`storage`' . ' WHERE `mimetype` != ?' . ' AND (`*PREFIX*storages`.`id` LIKE ? OR `*PREFIX*storages`.`id` LIKE ?)' . ' AND (`*PREFIX*files_antivirus`.`fileid` IS NULL OR `mtime` > `check_time`)' . ' AND `path` LIKE ?';
     $stmt = \OCP\DB::prepare($sql, 5);
     try {
         $result = $stmt->execute(array($dirMimetypeId, 'local::%', 'home::%', 'files/%'));
         if (\OCP\DB::isError($result)) {
             \OCP\Util::writeLog('files_antivirus', __METHOD__ . 'DB error: ' . \OCP\DB::getErrorMessage($result), \OCP\Util::ERROR);
             return;
         }
     } catch (\Exception $e) {
         \OCP\Util::writeLog('files_antivirus', __METHOD__ . ', exception: ' . $e->getMessage(), \OCP\Util::ERROR);
         return;
     }
     $view = new \OC\Files\View('/');
     while ($row = $result->fetchRow()) {
         $path = $view->getPath($row['fileid']);
         if (!is_null($path)) {
             $item = new Item($this->l10n, $view, $path, $row['fileid']);
             $scanner = $this->scannerFactory->getScanner();
             $status = $scanner->scan($item);
             $status->dispatch($item, true);
         }
     }
     \OC_Util::tearDownFS();
 }
开发者ID:amin-hedayati,项目名称:files_antivirus,代码行数:35,代码来源:backgroundscanner.php


示例7: getChildren

 public function getChildren($itemSource)
 {
     $children = array();
     $parents = array($itemSource);
     $query = \OCP\DB::prepare('SELECT `id` FROM `*PREFIX*mimetypes` WHERE `mimetype` = ?');
     $result = $query->execute(array('httpd/unix-directory'));
     if ($row = $result->fetchRow()) {
         $mimetype = $row['id'];
     } else {
         $mimetype = -1;
     }
     while (!empty($parents)) {
         $parents = "'" . implode("','", $parents) . "'";
         $query = \OCP\DB::prepare('SELECT `fileid`, `name`, `mimetype` FROM `*PREFIX*filecache`' . ' WHERE `parent` IN (' . $parents . ')');
         $result = $query->execute();
         $parents = array();
         while ($file = $result->fetchRow()) {
             $children[] = array('source' => $file['fileid'], 'file_path' => $file['name']);
             // If a child folder is found look inside it
             if ($file['mimetype'] == $mimetype) {
                 $parents[] = $file['fileid'];
             }
         }
     }
     return $children;
 }
开发者ID:ninjasilicon,项目名称:core,代码行数:26,代码来源:folder.php


示例8: getstats

 public function getstats()
 {
     $timeperiod = json_decode($_POST['accessstats']);
     $from_timestamp = date("Y-m-d 0:0:0", strtotime($timeperiod->from_date));
     $to_timestamp = date("Y-m-d 23:59:59", strtotime($timeperiod->to_date));
     $sql = 'SELECT id, time, username, path FROM `*PREFIX*accessstats_items` WHERE time >= ? and time <= ?';
     error_log($from_timestamp);
     $query = \OCP\DB::prepare($sql);
     $query->bindparam(1, $from_timestamp);
     $query->bindparam(2, $to_timestamp);
     $result = $query->execute();
     $data = "id,time,username,path\r\n";
     while ($row = $result->fetchRow()) {
         $data .= "\"" . $row['id'] . "\",\"" . $row['time'] . "\",\"" . $row['username'] . "\",\"" . $row['path'] . "\"\r\n";
     }
     header('Content-Description: File Transfer');
     //header('Content-Type: application/octet-stream');
     header('Content-Disposition: attachment; filename=access_report.csv');
     header('Expires: 0');
     header('Cache-Control: must-revalidate');
     header('Pragma: public');
     header('Content-Length: ' . strlen($data));
     print $data;
     exit(0);
 }
开发者ID:nickbooties,项目名称:accessstats,代码行数:25,代码来源:accessstatscontroller.php


示例9: import

 function import()
 {
     switch ($this->appinfo->version) {
         default:
             // All versions of the app have had the same db structure, so all can use the same import function
             $query = $this->content->prepare('SELECT * FROM contacts_addressbooks WHERE userid = ?');
             $results = $query->execute(array($this->olduid));
             $idmap = array();
             $app = new \OCA\Contacts\App($this->uid);
             while ($row = $results->fetchRow()) {
                 // Import each addressbook
                 $addressbookquery = \OCP\DB::prepare('INSERT INTO `*PREFIX*contacts_addressbooks` ' . '(`userid`, `displayname`, `uri`, `description`, `ctag`) VALUES (?, ?, ?, ?, ?)');
                 $addressbookquery->execute(array($this->uid, $row['displayname'], $row['uri'], $row['description'], $row['ctag']));
                 // Map the id
                 $idmap[$row['id']] = \OCP\DB::insertid('*PREFIX*contacts_addressbooks');
                 // Make the addressbook active
                 $addressbook = $app->getAddressBook('local', $idmap[$row['id']]);
                 $addressbook->setActive(true);
             }
             // Now tags
             foreach ($idmap as $oldid => $newid) {
                 $query = $this->content->prepare('SELECT * FROM contacts_cards WHERE addressbookid = ?');
                 $results = $query->execute(array($oldid));
                 while ($row = $results->fetchRow()) {
                     // Import the contacts
                     $contactquery = \OCP\DB::prepare('INSERT INTO `*PREFIX*contacts_cards` ' . '(`addressbookid`, `fullname`, `carddata`, `uri`, `lastmodified`) VALUES (?, ?, ?, ?, ?)');
                     $contactquery->execute(array($newid, $row['fullname'], $row['carddata'], $row['uri'], $row['lastmodified']));
                 }
             }
             // All done!
             break;
     }
     return true;
 }
开发者ID:WYSAC,项目名称:oregon-owncloud,代码行数:34,代码来源:migrate.php


示例10: passwordChangeListener

 /**
  * get the sha256 hash of the password needed for ampache
  *
  * @param array $params, parameters passed from OC_Hook
  */
 public static function passwordChangeListener($params)
 {
     if (isset($params['uid']) and $params['password']) {
         $name = $params['uid'];
         $password = hash('sha256', $params['password']);
         $query = \OCP\DB::prepare("UPDATE `*PREFIX*media_users` SET `user_password_sha256` = ? WHERE `user_id` = ?");
         $query->execute(array($password, $name));
     }
 }
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:14,代码来源:media.php


示例11: update

 public function update(OtpUserData $OtpUserData)
 {
     $sql = 'UPDATE  `' . $this->getTableName() . '` ' . 'SET `request_prefix_pin` =?,' . '`algorithm` =?,' . '`token_seed` =?,' . '`user_pin` =?,' . '`number_of_digits` =?,' . '`time_interval` =?,' . '`last_event` =?,' . '`last_login` =?,' . '`error_counter` =?,' . '`locked` =?,' . '`qrcode` =? ' . 'WHERE `user`=? ';
     //print_r($OtpUserData);
     $query = \OCP\DB::prepare($sql);
     $result = $query->execute(array($OtpUserData->getRequestPrefixPin(), $OtpUserData->getAlgorithm(), $OtpUserData->getTokenSeed(), $OtpUserData->getUserPin(), $OtpUserData->getNumberOfDigits(), $OtpUserData->getTimeInterval(), $OtpUserData->getLastEvent(), $OtpUserData->getLastLogin(), $OtpUserData->getErrorCounter(), $OtpUserData->getLocked(), $OtpUserData->getQrcode(), $OtpUserData->getUser()));
     //~ print_r($query);exit;
     return $result;
 }
开发者ID:gummipunkt,项目名称:user-otp,代码行数:9,代码来源:otpuserdatamapper.php


示例12: setFileData

 public function setFileData($path, $width, $height)
 {
     $stmt = \OCP\DB::prepare('INSERT INTO `*PREFIX*pictures_images_cache` (`uid_owner`, `path`, `width`, `height`) VALUES (?, ?, ?, ?)');
     $stmt->execute(array(\OCP\USER::getUser(), $path, $width, $height));
     $ret = array('path' => $path, 'width' => $width, 'height' => $height);
     $dir = dirname($path);
     $this->cache[$dir][$path] = $ret;
     return $ret;
 }
开发者ID:blablubli,项目名称:owncloudapps,代码行数:9,代码来源:managers.php


示例13: 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


示例14: tearDown

 function tearDown()
 {
     $this->view->unlink($this->filename);
     $this->view->deleteAll($this->folder);
     self::$tempStorage = null;
     // clear database table
     $query = \OCP\DB::prepare('DELETE FROM `*PREFIX*share`');
     $query->execute();
     parent::tearDown();
 }
开发者ID:Romua1d,项目名称:core,代码行数:10,代码来源:share.php


示例15: getSetting

 public function getSetting($userId, $settingName)
 {
     $sql = 'SELECT value FROM ' . '*PREFIX*weather_config WHERE `user` = ? and `key` = ?';
     $query = \OCP\DB::prepare($sql);
     $result = $query->execute(array($userId, $settingName));
     if ($row = $result->fetchRow()) {
         return $row["value"];
     }
     return 0;
 }
开发者ID:nerzhul,项目名称:owncloud-weather,代码行数:10,代码来源:settingsmapper.php


示例16: tearDown

 protected function tearDown()
 {
     self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
     $this->view->unlink($this->filename);
     $this->view->deleteAll($this->folder);
     self::$tempStorage = null;
     // clear database table
     $query = \OCP\DB::prepare('DELETE FROM `*PREFIX*share`');
     $query->execute();
     parent::tearDown();
 }
开发者ID:evanjt,项目名称:core,代码行数:11,代码来源:share.php


示例17: migrate

 public function migrate()
 {
     $sql = 'SELECT user_id, datakey, datavalue FROM ' . '*PREFIX*ocsms_user_datas WHERE datakey LIKE \'lastReadDate-%\'';
     $query = \OCP\DB::prepare($sql);
     $result = $query->execute(array());
     while ($row = $result->fetchRow()) {
         $pn = preg_replace("#lastReadDate[-]#", "", $row["datakey"]);
         $this->setLast($row["user_id"], $pn, $row["datavalue"]);
     }
     $query = \OCP\DB::prepare("DELETE FROM *PREFIX*ocsms_user_datas WHERE datakey LIKE 'lastReadDate-%'");
     $query->execute(array());
 }
开发者ID:nerzhul,项目名称:ocsms,代码行数:12,代码来源:conversationstatemapper.php


示例18: testTableTruncate

 public function testTableTruncate()
 {
     $statement = \OCP\DB::prepare('INSERT INTO `*PREFIX*ldap_user_mapping` (`ldap_dn`, `owncloud_name`, `directory_uuid`) VALUES (?, ?, ?)');
     $statement->execute(array('db01', 'oc1', '000-0000-0000'));
     $statement->execute(array('db02', 'oc2', '000-0000-0001'));
     $statement = \OCP\DB::prepare('SELECT count(*) FROM `*PREFIX*ldap_user_mapping`');
     $result = $statement->execute();
     $this->assertEquals(2, $result->fetchOne());
     Helper::clearMapping('user');
     $result = $statement->execute();
     $this->assertEquals(0, $result->fetchOne());
 }
开发者ID:pinoniq,项目名称:core,代码行数:12,代码来源:helper.php


示例19: getKey

 public function getKey($key)
 {
     try {
         $query = \OCP\DB::prepare("SELECT `value` FROM `*PREFIX*ocsms_config` WHERE `key` = ? AND `user` = ?");
         $result = $query->execute(array($key, $this->user));
         while ($row = $result->fetchRow()) {
             return $this->crypto->decrypt($row["value"]);
         }
         return false;
     } catch (DoesNotExistException $e) {
         return false;
     }
 }
开发者ID:WilliamRen,项目名称:ocsms,代码行数:13,代码来源:configmapper.php


示例20: 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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP OCP\Files类代码示例发布时间:2022-05-23
下一篇:
PHP OCP\Config类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap