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


PHP DB::prepare方法代码示例

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


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


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