本文整理汇总了PHP中OCP\DB类的典型用法代码示例。如果您正苦于以下问题:PHP DB类的具体用法?PHP DB怎么用?PHP DB使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DB类的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;
}
示例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);
}
示例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;
}
}
示例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();
}
示例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'));
}
示例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();
}
示例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;
}
示例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);
}
示例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;
}
示例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));
}
}
示例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;
}
示例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;
}
示例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();
}
示例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();
}
示例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;
}