本文整理汇总了PHP中OC_DB::isError方法的典型用法代码示例。如果您正苦于以下问题:PHP OC_DB::isError方法的具体用法?PHP OC_DB::isError怎么用?PHP OC_DB::isError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC_DB
的用法示例。
在下文中一共展示了OC_DB::isError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: scan
public static function scan($id, $path, $storage)
{
$file = $storage->getLocalFile($path);
$result = OC_Files_Antivirus::clamav_scan($file);
switch ($result) {
case CLAMAV_SCANRESULT_UNCHECKED:
\OCP\Util::writeLog('files_antivirus', 'File "' . $path . '" from user "' . $user . '": is not checked', \OCP\Util::ERROR);
break;
case CLAMAV_SCANRESULT_INFECTED:
$infected_action = \OCP\Config::getAppValue('files_antivirus', 'infected_action', 'only_log');
if ($infected_action == 'delete') {
\OCP\Util::writeLog('files_antivirus', 'File "' . $path . '" from user "' . $user . '": is infected, file deleted', \OCP\Util::ERROR);
unlink($file);
} else {
\OCP\Util::writeLog('files_antivirus', 'File "' . $path . '" from user "' . $user . '": is infected', \OCP\Util::ERROR);
}
break;
case CLAMAV_SCANRESULT_CLEAN:
$stmt = OCP\DB::prepare('INSERT INTO `*PREFIX*files_antivirus` (`fileid`, `check_time`) VALUES (?, ?)');
try {
$result = $stmt->execute(array($id, time()));
if (\OC_DB::isError($result)) {
\OC_Log::write('files_antivirus', __METHOD__ . ', DB error: ' . \OC_DB::getErrorMessage($result), \OCP\Util::ERROR);
return;
}
} catch (\Exception $e) {
\OCP\Util::writeLog('files_antivirus', __METHOD__ . ', exception: ' . $e->getMessage(), \OCP\Util::ERROR);
}
break;
}
}
示例2: get
public static function get($path, $root = false)
{
if ($root === false) {
$root = OC_Filesystem::getRoot();
}
$path = $root . $path;
$stmt = OC_DB::prepare('SELECT `id`, `path`,`ctime`,`mtime`,`mimetype`,`size`,`encrypted`,`versioned`,`writable` FROM `*PREFIX*fscache` WHERE `path_hash`=?');
if (!OC_DB::isError($stmt)) {
$result = $stmt->execute(array(md5($path)));
if (!OC_DB::isError($result)) {
$result = $result->fetchRow();
} else {
OC:
Log::write('OC_FileCache_Cached', 'could not execute get: ' . OC_DB::getErrorMessage($result), OC_Log::ERROR);
$result = false;
}
} else {
OC_Log::write('OC_FileCache_Cached', 'could not prepare get: ' . OC_DB::getErrorMessage($stmt), OC_Log::ERROR);
$result = false;
}
if (is_array($result)) {
if (isset(self::$savedData[$path])) {
$result = array_merge($result, self::$savedData[$path]);
}
return $result;
} else {
if (isset(self::$savedData[$path])) {
return self::$savedData[$path];
} else {
return array();
}
}
}
示例3: countUsers
/**
* counts the users in the database
*
* @return int | bool
*/
public function countUsers()
{
$query = OC_DB::prepare('SELECT COUNT(*) FROM `*PREFIX*users`');
$result = $query->execute();
if (OC_DB::isError($result)) {
OC_Log::write('core', OC_DB::getErrorMessage($result), OC_Log::ERROR);
return false;
}
return $result->fetchOne();
}
示例4: getItems
//.........这里部分代码省略.........
$queryLimit = null;
}
// TODO Optimize selects
if ($format == self::FORMAT_STATUSES) {
if ($itemType == 'file' || $itemType == 'folder') {
$select = '`*PREFIX*share`.`id`, `item_type`, `item_source`, `*PREFIX*share`.`parent`,' . ' `share_type`, `file_source`, `path`, `expiration`, `storage`, `share_with`, `mail_send`, `uid_owner`';
} else {
$select = '`id`, `item_type`, `item_source`, `parent`, `share_type`, `share_with`, `expiration`, `mail_send`, `uid_owner`';
}
} else {
if (isset($uidOwner)) {
if ($itemType == 'file' || $itemType == 'folder') {
$select = '`*PREFIX*share`.`id`, `item_type`, `item_source`, `*PREFIX*share`.`parent`,' . ' `share_type`, `share_with`, `file_source`, `path`, `permissions`, `stime`,' . ' `expiration`, `token`, `storage`, `mail_send`, `uid_owner`';
} else {
$select = '`id`, `item_type`, `item_source`, `parent`, `share_type`, `share_with`, `permissions`,' . ' `stime`, `file_source`, `expiration`, `token`, `mail_send`, `uid_owner`';
}
} else {
if ($fileDependent) {
if (($itemType == 'file' || $itemType == 'folder') && $format == \OC_Share_Backend_File::FORMAT_GET_FOLDER_CONTENTS || $format == \OC_Share_Backend_File::FORMAT_FILE_APP_ROOT) {
$select = '`*PREFIX*share`.`id`, `item_type`, `item_source`, `*PREFIX*share`.`parent`, `uid_owner`, ' . '`share_type`, `share_with`, `file_source`, `path`, `file_target`, ' . '`permissions`, `expiration`, `storage`, `*PREFIX*filecache`.`parent` as `file_parent`, ' . '`name`, `mtime`, `mimetype`, `mimepart`, `size`, `unencrypted_size`, `encrypted`, `etag`, `mail_send`';
} else {
$select = '`*PREFIX*share`.`id`, `item_type`, `item_source`, `item_target`,
`*PREFIX*share`.`parent`, `share_type`, `share_with`, `uid_owner`,
`file_source`, `path`, `file_target`, `permissions`, `stime`, `expiration`, `token`, `storage`, `mail_send`';
}
} else {
$select = '*';
}
}
}
$root = strlen($root);
$query = \OC_DB::prepare('SELECT ' . $select . ' FROM `*PREFIX*share` ' . $where, $queryLimit);
$result = $query->execute($queryArgs);
if (\OC_DB::isError($result)) {
\OC_Log::write('OCP\\Share', \OC_DB::getErrorMessage($result) . ', select=' . $select . ' where=' . $where, \OC_Log::ERROR);
}
$items = array();
$targets = array();
$switchedItems = array();
$mounts = array();
while ($row = $result->fetchRow()) {
if (isset($row['id'])) {
$row['id'] = (int) $row['id'];
}
if (isset($row['share_type'])) {
$row['share_type'] = (int) $row['share_type'];
}
if (isset($row['parent'])) {
$row['parent'] = (int) $row['parent'];
}
if (isset($row['file_parent'])) {
$row['file_parent'] = (int) $row['file_parent'];
}
if (isset($row['file_source'])) {
$row['file_source'] = (int) $row['file_source'];
}
if (isset($row['permissions'])) {
$row['permissions'] = (int) $row['permissions'];
}
if (isset($row['storage'])) {
$row['storage'] = (int) $row['storage'];
}
if (isset($row['stime'])) {
$row['stime'] = (int) $row['stime'];
}
// Filter out duplicate group shares for users with unique targets
示例5: isActive
/**
* @brief Checks if an addressbook is active.
* @param integer $id ID of the address book.
* @return boolean
*/
public static function isActive($id)
{
$sql = 'SELECT `active` FROM `*PREFIX*contacts_addressbooks` WHERE `id` = ?';
try {
$stmt = \OCP\DB::prepare($sql);
$result = $stmt->execute(array($id));
if (\OC_DB::isError($result)) {
\OC_Log::write('contacts', __METHOD__ . 'DB error: ' . \OC_DB::getErrorMessage($result), \OC_Log::ERROR);
return false;
}
$row = $result->fetchRow();
return (bool) $row['active'];
} catch (Exception $e) {
\OCP\Util::writeLog('contacts', __METHOD__ . ', exception: ' . $e->getMessage(), \OCP\Util::ERROR);
return false;
}
}
示例6: delete
/**
* @param $id
* @return mixed
*/
public function delete($id)
{
try {
$query = 'SELECT * FROM `*PREFIX*contacts_cards` WHERE `id` = ? AND `addressbookid` = ?';
$stmt = \OCP\DB::prepare($query);
$result = $stmt->execute(array($id, $this->id));
if (\OC_DB::isError($result)) {
\OC_Log::write('contacts', __METHOD__ . 'DB error: ' . \OC_DB::getErrorMessage($result), \OCP\Util::ERROR);
return false;
}
if ($result->numRows() === 0) {
\OC_Log::write('contacts', __METHOD__ . 'Contact with id ' . $id . 'doesn\'t belong to addressbook with id ' . $this->id, \OCP\Util::ERROR);
return false;
}
} catch (\Exception $e) {
\OCP\Util::writeLog('contacts', __METHOD__ . ', exception: ' . $e->getMessage(), \OCP\Util::ERROR);
return false;
}
return VCard::delete($id);
}
示例7: getItems
//.........这里部分代码省略.........
} else {
$where .= ' `item_target` = ?';
}
}
$queryArgs[] = $item;
if ($includeCollections && $collectionTypes && !in_array('folder', $collectionTypes)) {
$placeholders = join(',', array_fill(0, count($collectionTypes), '?'));
$where .= ' OR `item_type` IN (' . $placeholders . '))';
$queryArgs = array_merge($queryArgs, $collectionTypes);
}
}
if ($shareType == self::$shareTypeUserAndGroups && $limit === 1) {
// Make sure the unique user target is returned if it exists,
// unique targets should follow the group share in the database
// If the limit is not 1, the filtering can be done later
$where .= ' ORDER BY `*PREFIX*share`.`id` DESC';
} else {
$where .= ' ORDER BY `*PREFIX*share`.`id` ASC';
}
if ($limit != -1 && !$includeCollections) {
// The limit must be at least 3, because filtering needs to be done
if ($limit < 3) {
$queryLimit = 3;
} else {
$queryLimit = $limit;
}
} else {
$queryLimit = null;
}
$select = self::createSelectStatement($format, $fileDependent, $uidOwner);
$root = strlen($root);
$query = \OC_DB::prepare('SELECT ' . $select . ' FROM `*PREFIX*share` ' . $where, $queryLimit);
$result = $query->execute($queryArgs);
if (\OC_DB::isError($result)) {
\OCP\Util::writeLog('OCP\\Share', \OC_DB::getErrorMessage() . ', select=' . $select . ' where=', \OCP\Util::ERROR);
}
$items = array();
$targets = array();
$switchedItems = array();
$mounts = array();
while ($row = $result->fetchRow()) {
self::transformDBResults($row);
// Filter out duplicate group shares for users with unique targets
if ($fileDependent && !self::isFileReachable($row['path'], $row['storage_id'])) {
continue;
}
if ($row['share_type'] == self::$shareTypeGroupUserUnique && isset($items[$row['parent']])) {
$row['share_type'] = self::SHARE_TYPE_GROUP;
$row['unique_name'] = true;
// remember that we use a unique name for this user
$row['share_with'] = $items[$row['parent']]['share_with'];
// if the group share was unshared from the user we keep the permission, otherwise
// we take the permission from the parent because this is always the up-to-date
// permission for the group share
if ($row['permissions'] > 0) {
$row['permissions'] = $items[$row['parent']]['permissions'];
}
// Remove the parent group share
unset($items[$row['parent']]);
if ($row['permissions'] == 0) {
continue;
}
} else {
if (!isset($uidOwner)) {
// Check if the same target already exists
if (isset($targets[$row['id']])) {
示例8: getUnindexed
/**
* get the list of all unindexed files for the user
*
* @return array
*/
public static function getUnindexed()
{
$files = array();
$absoluteRoot = Filesystem::getView()->getAbsolutePath('/');
$mounts = Filesystem::getMountPoints($absoluteRoot);
$mount = Filesystem::getMountPoint($absoluteRoot);
if (!in_array($mount, $mounts)) {
$mounts[] = $mount;
}
$query = \OC_DB::prepare('
SELECT `*PREFIX*filecache`.`fileid`
FROM `*PREFIX*filecache`
LEFT JOIN `*PREFIX*lucene_status`
ON `*PREFIX*filecache`.`fileid` = `*PREFIX*lucene_status`.`fileid`
WHERE `storage` = ?
AND `status` IS NULL OR `status` = ?
');
foreach ($mounts as $mount) {
if (is_string($mount)) {
$storage = Filesystem::getStorage($mount);
} else {
if ($mount instanceof \OC\Files\Mount\Mount) {
$storage = $mount->getStorage();
} else {
$storage = null;
Util::writeLog('search_lucene', 'expected string or instance of \\OC\\Files\\Mount\\Mount got ' . json_encode($mount), Util::DEBUG);
}
}
//only index local files for now
if ($storage instanceof \OC\Files\Storage\Local) {
$cache = $storage->getCache();
$numericId = $cache->getNumericStorageId();
$result = $query->execute(array($numericId, 'N'));
if (\OC_DB::isError($result)) {
Util::writeLog('search_lucene', 'failed to find unindexed files: ' . \OC_DB::getErrorMessage($result), Util::WARN);
return false;
}
while ($row = $result->fetchRow()) {
$files[] = $row['fileid'];
}
}
}
return $files;
}
示例9: getEnabledApps
public static function getEnabledApps()
{
if (!OC_Config::getValue('installed', false)) {
return array();
}
if (!empty(self::$enabledAppsCache)) {
return self::$enabledAppsCache;
}
$apps = array('files');
$sql = 'SELECT `appid` FROM `*PREFIX*appconfig`' . ' WHERE `configkey` = \'enabled\' AND `configvalue`=\'yes\'';
if (OC_Config::getValue('dbtype', 'sqlite') === 'oci') {
//FIXME oracle hack: need to explicitly cast CLOB to CHAR for comparison
$sql = 'SELECT `appid` FROM `*PREFIX*appconfig`' . ' WHERE `configkey` = \'enabled\' AND to_char(`configvalue`)=\'yes\'';
}
$query = OC_DB::prepare($sql);
$result = $query->execute();
if (\OC_DB::isError($result)) {
throw new DatabaseException($result->getMessage(), $query);
}
while ($row = $result->fetchRow()) {
if (array_search($row['appid'], $apps) === false) {
$apps[] = $row['appid'];
}
}
self::$enabledAppsCache = $apps;
return $apps;
}
示例10: getItems
//.........这里部分代码省略.........
}
} else {
$queryLimit = null;
}
// TODO Optimize selects
if ($format == self::FORMAT_STATUSES) {
if ($itemType == 'file' || $itemType == 'folder') {
$select = '`*PREFIX*share`.`id`, `item_type`, `*PREFIX*share`.`parent`, `share_type`, `file_source`, `path`, `expiration`';
} else {
$select = '`id`, `item_type`, `item_source`, `parent`, `share_type`, `expiration`';
}
} else {
if (isset($uidOwner)) {
if ($itemType == 'file' || $itemType == 'folder') {
$select = '`*PREFIX*share`.`id`, `item_type`, `*PREFIX*share`.`parent`, `share_type`, `share_with`, `file_source`, `path`, `permissions`, `stime`, `expiration`, `token`';
} else {
$select = '`id`, `item_type`, `item_source`, `parent`, `share_type`, `share_with`, `permissions`, `stime`, `file_source`, `expiration`, `token`';
}
} else {
if ($fileDependent) {
if (($itemType == 'file' || $itemType == 'folder') && $format == \OC_Share_Backend_File::FORMAT_FILE_APP || $format == \OC_Share_Backend_File::FORMAT_FILE_APP_ROOT) {
$select = '`*PREFIX*share`.`id`, `item_type`, `*PREFIX*share`.`parent`, `uid_owner`, `share_type`, `share_with`, `file_source`, `path`, `file_target`, `permissions`, `expiration`, `name`, `ctime`, `mtime`, `mimetype`, `size`, `encrypted`, `versioned`, `writable`';
} else {
$select = '`*PREFIX*share`.`id`, `item_type`, `item_source`, `item_target`, `*PREFIX*share`.`parent`, `share_type`, `share_with`, `uid_owner`, `file_source`, `path`, `file_target`, `permissions`, `stime`, `expiration`, `token`';
}
} else {
$select = '*';
}
}
}
$root = strlen($root);
$query = \OC_DB::prepare('SELECT ' . $select . ' FROM `*PREFIX*share` ' . $where, $queryLimit);
$result = $query->execute($queryArgs);
if (\OC_DB::isError($result)) {
\OC_Log::write('OCP\\Share', \OC_DB::getErrorMessage($result) . ', select=' . $select . ' where=' . $where, \OC_Log::ERROR);
}
$items = array();
$targets = array();
while ($row = $result->fetchRow()) {
// Filter out duplicate group shares for users with unique targets
if ($row['share_type'] == self::$shareTypeGroupUserUnique && isset($items[$row['parent']])) {
$row['share_type'] = self::SHARE_TYPE_GROUP;
$row['share_with'] = $items[$row['parent']]['share_with'];
// Remove the parent group share
unset($items[$row['parent']]);
if ($row['permissions'] == 0) {
continue;
}
} else {
if (!isset($uidOwner)) {
// Check if the same target already exists
if (isset($targets[$row[$column]])) {
// Check if the same owner shared with the user twice through a group and user share - this is allowed
$id = $targets[$row[$column]];
if ($items[$id]['uid_owner'] == $row['uid_owner']) {
// Switch to group share type to ensure resharing conditions aren't bypassed
if ($items[$id]['share_type'] != self::SHARE_TYPE_GROUP) {
$items[$id]['share_type'] = self::SHARE_TYPE_GROUP;
$items[$id]['share_with'] = $row['share_with'];
}
// Switch ids if sharing permission is granted on only one share to ensure correct parent is used if resharing
if (~(int) $items[$id]['permissions'] & PERMISSION_SHARE && (int) $row['permissions'] & PERMISSION_SHARE) {
$items[$row['id']] = $items[$id];
unset($items[$id]);
$id = $row['id'];
}
示例11: getAddressBooksForUser
/**
* Returns the list of active addressbooks for a specific user.
*
* @param string $userid
* @return array
*/
public function getAddressBooksForUser(array $options = array())
{
try {
if (!isset(self::$preparedQueries['addressbooksforuser'])) {
$sql = 'SELECT `configkey` from *PREFIX*preferences where `configkey` like ?';
$configkeyPrefix = $this->name . "_%_uri";
self::$preparedQueries['addressbooksforuser'] = \OCP\DB::prepare($sql);
$result = self::$preparedQueries['addressbooksforuser']->execute(array($configkeyPrefix));
if (\OC_DB::isError($result)) {
\OCP\Util::write('contacts', __METHOD__ . 'DB error: ' . \OC_DB::getErrorMessage($result), \OCP\Util::ERROR);
return $this->addressbooks;
}
$this->addressbooks = array();
while ($row = $result->fetchRow()) {
$id = str_replace("_uri", "", str_replace($this->name . "_", "", $row['configkey']));
$this->addressbooks[] = self::getAddressBook($id);
}
return $this->addressbooks;
}
} catch (\Exception $e) {
\OC_Log::write('contacts', __METHOD__ . ' exception: ' . $e->getMessage(), \OCP\Util::ERROR);
return $this->addressbooks;
}
}
示例12: getFileId
/**
* get the file id as used in the cache
* unlike the public getId, full paths are used here (/usename/files/foo instead of /foo)
* @param string $path
* @return int
*/
private static function getFileId($path)
{
$query = OC_DB::prepare('SELECT id FROM *PREFIX*fscache WHERE path_hash=?');
if (OC_DB::isError($query)) {
OC_Log::write('files', 'error while getting file id of ' . $path, OC_Log::ERROR);
return -1;
}
$result = $query->execute(array(md5($path)));
if (OC_DB::isError($result)) {
OC_Log::write('files', 'error while getting file id of ' . $path, OC_Log::ERROR);
return -1;
}
$result = $result->fetchRow();
if (is_array($result)) {
return $result['id'];
} else {
OC_Log::write('files', 'getFileId(): file not found in cache (' . $path . ')', OC_Log::DEBUG);
return -1;
}
}
示例13: db_get_usersOfGroup
private static function db_get_usersOfGroup($gid)
{
$query = OC_DB::prepare('SELECT * FROM `*PREFIX*group_user` WHERE `gid` = ?');
$result = $query->execute(array($gid));
if (OC_DB::isError($result)) {
return -1;
}
$users = array();
while ($row = $result->fetchRow()) {
$users[] = $row['uid'];
}
return $users;
}
示例14: isEnabled
/**
* checks if a user is enabled
* @param string $userid
* @return bool
*/
public static function isEnabled($userid)
{
$sql = "SELECT `userid` FROM `*PREFIX*preferences` WHERE `userid` = ? AND `appid` = ? AND `configkey` = ? AND `configvalue` = ?";
$stmt = OC_DB::prepare($sql);
if (!OC_DB::isError($stmt)) {
$result = $stmt->execute(array($userid, 'core', 'enabled', 'false'));
if (!OC_DB::isError($result)) {
return $result->numRows() ? false : true;
} else {
OC_Log::write('OC_User', 'could not check if enabled: ' . OC_DB::getErrorMessage($result), OC_Log::ERROR);
}
} else {
OC_Log::write('OC_User', 'could not check if enabled: ' . OC_DB::getErrorMessage($stmt), OC_Log::ERROR);
}
return false;
}
示例15: loadUser
private function loadUser($uid)
{
if (empty($this->cache[$uid])) {
$query = OC_DB::prepare('SELECT `uid`, `displayname` FROM `*PREFIX*users` WHERE LOWER(`uid`) = LOWER(?)');
$result = $query->execute(array($uid));
if (OC_DB::isError($result)) {
OC_Log::write('core', OC_DB::getErrorMessage($result), OC_Log::ERROR);
return false;
}
while ($row = $result->fetchRow()) {
$this->cache[$uid]['uid'] = $row['uid'];
$this->cache[$uid]['displayname'] = $row['displayname'];
}
}
return true;
}