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


PHP DB::isError方法代码示例

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


在下文中一共展示了DB::isError方法的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: 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

示例3: shareFileOrFolderWithGroup

 protected function shareFileOrFolderWithGroup($params)
 {
     // User performing the share
     $subject = 'shared_sharing_group_self';
     $this->shareNotificationForSharer($subject, $params['shareWith'], $params['fileSource'], $params['itemType']);
     // Members of the new group
     $affectedUsers = array();
     $usersInGroup = Data::readGroupUsers($params['shareWith']);
     foreach ($usersInGroup as $user) {
         $affectedUsers[$user] = $params['fileTarget'];
     }
     // Remove the triggering user, we already managed his notifications
     unset($affectedUsers[$this->currentUser]);
     if (empty($affectedUsers)) {
         return;
     }
     $filteredStreamUsersInGroup = $this->userSettings->filterUsersBySetting($usersInGroup, 'stream', Files_Sharing::TYPE_SHARED);
     $filteredEmailUsersInGroup = $this->userSettings->filterUsersBySetting($usersInGroup, 'email', Files_Sharing::TYPE_SHARED);
     // Check when there was a naming conflict and the target is different
     // for some of the users
     $query = DB::prepare('SELECT `share_with`, `file_target` FROM `*PREFIX*share` WHERE `parent` = ? ');
     $result = $query->execute(array($params['id']));
     if (DB::isError($result)) {
         Util::writeLog('OCA\\Activity\\Hooks::shareFileOrFolderWithGroup', DB::getErrorMessage($result), Util::ERROR);
     } else {
         while ($row = $result->fetchRow()) {
             $affectedUsers[$row['share_with']] = $row['file_target'];
         }
     }
     foreach ($affectedUsers as $user => $path) {
         if (empty($filteredStreamUsersInGroup[$user]) && empty($filteredEmailUsersInGroup[$user])) {
             continue;
         }
         $this->addNotificationsForUser($user, 'shared_with_by', array($path, $this->currentUser), $path, $params['itemType'] === 'file', !empty($filteredStreamUsersInGroup[$user]), !empty($filteredEmailUsersInGroup[$user]) ? $filteredEmailUsersInGroup[$user] : 0);
     }
 }
开发者ID:inwinstack,项目名称:owncloud-sharing_group,代码行数:36,代码来源:fileshooks.php

示例4: getUsersSharingFile

    /**
     * @brief Find which users can access a shared item
     * @param $path to the file
     * @param $user owner of the file
     * @param include owner to the list of users with access to the file
     * @return array
     * @note $path needs to be relative to user data dir, e.g. 'file.txt'
     *       not '/admin/data/file.txt'
     */
    public static function getUsersSharingFile($path, $user, $includeOwner = false)
    {
        $shares = array();
        $publicShare = false;
        $source = -1;
        $cache = false;
        $view = new \OC\Files\View('/' . $user . '/files/');
        $meta = $view->getFileInfo(\OC\Files\Filesystem::normalizePath($path));
        if ($meta !== false) {
            $source = $meta['fileid'];
            $cache = new \OC\Files\Cache\Cache($meta['storage']);
        }
        while ($source !== -1) {
            // Fetch all shares of this file path from DB
            $query = \OC_DB::prepare('SELECT `share_with`
				FROM
				`*PREFIX*share`
				WHERE
				`item_source` = ? AND `share_type` = ?');
            $result = $query->execute(array($source, self::SHARE_TYPE_USER));
            if (\OCP\DB::isError($result)) {
                \OCP\Util::writeLog('OCP\\Share', \OC_DB::getErrorMessage($result), \OC_Log::ERROR);
            } else {
                while ($row = $result->fetchRow()) {
                    $shares[] = $row['share_with'];
                }
            }
            // We also need to take group shares into account
            $query = \OC_DB::prepare('SELECT `share_with`
				FROM
				`*PREFIX*share`
				WHERE
				`item_source` = ? AND `share_type` = ?');
            $result = $query->execute(array($source, self::SHARE_TYPE_GROUP));
            if (\OCP\DB::isError($result)) {
                \OCP\Util::writeLog('OCP\\Share', \OC_DB::getErrorMessage($result), \OC_Log::ERROR);
            } else {
                while ($row = $result->fetchRow()) {
                    $usersInGroup = \OC_Group::usersInGroup($row['share_with']);
                    $shares = array_merge($shares, $usersInGroup);
                }
            }
            //check for public link shares
            if (!$publicShare) {
                $query = \OC_DB::prepare('SELECT `share_with`
					FROM
					`*PREFIX*share`
					WHERE
					`item_source` = ? AND `share_type` = ?');
                $result = $query->execute(array($source, self::SHARE_TYPE_LINK));
                if (\OCP\DB::isError($result)) {
                    \OCP\Util::writeLog('OCP\\Share', \OC_DB::getErrorMessage($result), \OC_Log::ERROR);
                } else {
                    if ($result->fetchRow()) {
                        $publicShare = true;
                    }
                }
            }
            // let's get the parent for the next round
            $meta = $cache->get((int) $source);
            if ($meta !== false) {
                $source = (int) $meta['parent'];
            } else {
                $source = -1;
            }
        }
        // Include owner in list of users, if requested
        if ($includeOwner) {
            $shares[] = $user;
        }
        return array("users" => array_unique($shares), "public" => $publicShare);
    }
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:81,代码来源:share.php

示例5: updateDBProperties

 public static function updateDBProperties($contactid, $vcard = null)
 {
     $stmt = \OCP\DB::prepare('DELETE FROM `' . self::ContactsProbTable . '` WHERE `contactid` = ?');
     try {
         $stmt->execute(array($contactid));
     } catch (\Exception $e) {
         \OCP\Util::writeLog(self::$appname, __METHOD__ . ', exception: ' . $e->getMessage(), \OCP\Util::ERROR);
         \OCP\Util::writeLog(self::$appname, __METHOD__ . ', id: ' . $id, \OCP\Util::DEBUG);
         throw new \Exception(App::$l10n->t('There was an error deleting properties for this contact.'));
     }
     if (is_null($vcard)) {
         return;
     }
     $stmt = \OCP\DB::prepare('INSERT INTO `' . self::ContactsProbTable . '` ' . '(`userid`, `contactid`,`name`,`value`,`preferred`) VALUES(?,?,?,?,?)');
     foreach ($vcard->children as $property) {
         if (!in_array($property->name, self::$index_properties)) {
             continue;
         }
         $preferred = 0;
         foreach ($property->parameters as $parameter) {
             if ($parameter->name == 'TYPE' && strtoupper($parameter->getValue()) == 'PREF') {
                 $preferred = 1;
                 break;
             }
         }
         try {
             $result = $stmt->execute(array(\OCP\User::getUser(), $contactid, $property->name, $property->getValue(), $preferred));
             if (\OCP\DB::isError($result)) {
                 \OCP\Util::writeLog(self::$appname, __METHOD__ . 'DB error: ' . \OCP\DB::getErrorMessage($result), \OCP\Util::ERROR);
                 return false;
             }
         } catch (\Exception $e) {
             \OCP\Util::writeLog(self::$appname, __METHOD__ . ', exception: ' . $e->getMessage(), \OCP\Util::ERROR);
             return false;
         }
     }
 }
开发者ID:ViToni,项目名称:contactsplus,代码行数:37,代码来源:app.php

示例6: getUsersSharingFile

    /**
     * Find which users can access a shared item
     * @param string $path to the file
     * @param string $ownerUser owner of the file
     * @param boolean $includeOwner include owner to the list of users with access to the file
     * @param boolean $returnUserPaths Return an array with the user => path map
     * @param boolean $recursive take all parent folders into account (default true)
     * @return array
     * @note $path needs to be relative to user data dir, e.g. 'file.txt'
     *       not '/admin/data/file.txt'
     */
    public static function getUsersSharingFile($path, $ownerUser, $includeOwner = false, $returnUserPaths = false, $recursive = true)
    {
        Filesystem::initMountPoints($ownerUser);
        $shares = $sharePaths = $fileTargets = array();
        $publicShare = false;
        $remoteShare = false;
        $source = -1;
        $cache = false;
        $view = new \OC\Files\View('/' . $ownerUser . '/files');
        $meta = $view->getFileInfo($path);
        if ($meta) {
            $path = substr($meta->getPath(), strlen('/' . $ownerUser . '/files'));
        } else {
            // if the file doesn't exists yet we start with the parent folder
            $meta = $view->getFileInfo(dirname($path));
        }
        if ($meta !== false) {
            $source = $meta['fileid'];
            $cache = new \OC\Files\Cache\Cache($meta['storage']);
        }
        while ($source !== -1) {
            // Fetch all shares with another user
            if (!$returnUserPaths) {
                $query = \OC_DB::prepare('SELECT `share_with`, `file_source`, `file_target`
					FROM
					`*PREFIX*share`
					WHERE
					`item_source` = ? AND `share_type` = ? AND `item_type` IN (\'file\', \'folder\')');
                $result = $query->execute(array($source, self::SHARE_TYPE_USER));
            } else {
                $query = \OC_DB::prepare('SELECT `share_with`, `file_source`, `file_target`
				FROM
				`*PREFIX*share`
				WHERE
				`item_source` = ? AND `share_type` IN (?, ?) AND `item_type` IN (\'file\', \'folder\')');
                $result = $query->execute(array($source, self::SHARE_TYPE_USER, self::$shareTypeGroupUserUnique));
            }
            if (\OCP\DB::isError($result)) {
                \OCP\Util::writeLog('OCP\\Share', \OC_DB::getErrorMessage(), \OCP\Util::ERROR);
            } else {
                while ($row = $result->fetchRow()) {
                    $shares[] = $row['share_with'];
                    if ($returnUserPaths) {
                        $fileTargets[(int) $row['file_source']][$row['share_with']] = $row;
                    }
                }
            }
            // We also need to take group shares into account
            $query = \OC_DB::prepare('SELECT `share_with`, `file_source`, `file_target`
				FROM
				`*PREFIX*share`
				WHERE
				`item_source` = ? AND `share_type` = ? AND `item_type` IN (\'file\', \'folder\')');
            $result = $query->execute(array($source, self::SHARE_TYPE_GROUP));
            if (\OCP\DB::isError($result)) {
                \OCP\Util::writeLog('OCP\\Share', \OC_DB::getErrorMessage(), \OCP\Util::ERROR);
            } else {
                while ($row = $result->fetchRow()) {
                    $usersInGroup = \OC_Group::usersInGroup($row['share_with']);
                    $shares = array_merge($shares, $usersInGroup);
                    if ($returnUserPaths) {
                        foreach ($usersInGroup as $user) {
                            if (!isset($fileTargets[(int) $row['file_source']][$user])) {
                                // When the user already has an entry for this file source
                                // the file is either shared directly with him as well, or
                                // he has an exception entry (because of naming conflict).
                                $fileTargets[(int) $row['file_source']][$user] = $row;
                            }
                        }
                    }
                }
            }
            //check for public link shares
            if (!$publicShare) {
                $query = \OC_DB::prepare('
					SELECT `share_with`
					FROM `*PREFIX*share`
					WHERE `item_source` = ? AND `share_type` = ? AND `item_type` IN (\'file\', \'folder\')', 1);
                $result = $query->execute(array($source, self::SHARE_TYPE_LINK));
                if (\OCP\DB::isError($result)) {
                    \OCP\Util::writeLog('OCP\\Share', \OC_DB::getErrorMessage(), \OCP\Util::ERROR);
                } else {
                    if ($result->fetchRow()) {
                        $publicShare = true;
                    }
                }
            }
            //check for remote share
            if (!$remoteShare) {
//.........这里部分代码省略.........
开发者ID:evanjt,项目名称:core,代码行数:101,代码来源:share.php

示例7: mapComponent

    /**
     * inserts a new user or group into the mappings table
     * @param string $dn the record in question
     * @param string $ocName the name to use in ownCloud
     * @param bool $isUser is it a user or a group?
     * @return bool true on success, false otherwise
     *
     * inserts a new user or group into the mappings table
     */
    private function mapComponent($dn, $ocName, $isUser = true)
    {
        $table = $this->getMapTable($isUser);
        $sqlAdjustment = '';
        $dbType = \OCP\Config::getSystemValue('dbtype');
        if ($dbType === 'mysql' || $dbType == 'oci') {
            $sqlAdjustment = 'FROM DUAL';
        }
        $insert = \OCP\DB::prepare('
			INSERT INTO `' . $table . '` (`ldap_dn`, `owncloud_name`, `directory_uuid`)
				SELECT ?,?,?
				' . $sqlAdjustment . '
				WHERE NOT EXISTS (
					SELECT 1
					FROM `' . $table . '`
					WHERE `ldap_dn` = ?
						OR `owncloud_name` = ?)
		');
        //feed the DB
        $insRows = $insert->execute(array($dn, $ocName, $this->getUUID($dn, $isUser), $dn, $ocName));
        if (\OCP\DB::isError($insRows)) {
            return false;
        }
        if ($insRows === 0) {
            return false;
        }
        if ($isUser) {
            //make sure that email address is retrieved prior to login, so user
            //will be notified when something is shared with him
            $this->userManager->get($ocName)->update();
        }
        return true;
    }
开发者ID:olucao,项目名称:owncloud-core,代码行数:42,代码来源:access.php

示例8: deleteUser

 public static function deleteUser($loginName)
 {
     $query = \OCP\DB::prepare('DELETE FROM *PREFIX*shibboleth_user WHERE login_name = ?');
     $result = $query->execute(array($loginName));
     if (\OCP\DB::isError($result)) {
         return false;
     }
     return true;
 }
开发者ID:EUDAT-B2DROP,项目名称:user_shibboleth,代码行数:9,代码来源:db.php

示例9: getUsersSharingFile

    /**
     * Find which users can access a shared item
     * @param string $path to the file
     * @param string $ownerUser owner of the file
     * @param boolean $includeOwner include owner to the list of users with access to the file
     * @param boolean $returnUserPaths Return an array with the user => path map
     * @return array
     * @note $path needs to be relative to user data dir, e.g. 'file.txt'
     *       not '/admin/data/file.txt'
     */
    public static function getUsersSharingFile($path, $ownerUser, $includeOwner = false, $returnUserPaths = false)
    {
        $shares = $sharePaths = $fileTargets = array();
        $publicShare = false;
        $source = -1;
        $cache = false;
        $view = new \OC\Files\View('/' . $ownerUser . '/files');
        if ($view->file_exists($path)) {
            $meta = $view->getFileInfo($path);
            $path = substr($meta->getPath(), strlen('/' . $ownerUser . '/files'));
        } else {
            // if the file doesn't exists yet we start with the parent folder
            $meta = $view->getFileInfo(dirname($path));
        }
        if ($meta !== false) {
            $source = $meta['fileid'];
            $cache = new \OC\Files\Cache\Cache($meta['storage']);
        }
        while ($source !== -1) {
            // Fetch all shares with another user
            $query = \OC_DB::prepare('SELECT `share_with`, `file_source`, `file_target`
				FROM
				`*PREFIX*share`
				WHERE
				`item_source` = ? AND `share_type` = ? AND `item_type` IN (\'file\', \'folder\')');
            $result = $query->execute(array($source, self::SHARE_TYPE_USER));
            if (\OCP\DB::isError($result)) {
                \OCP\Util::writeLog('OCP\\Share', \OC_DB::getErrorMessage($result), \OC_Log::ERROR);
            } else {
                while ($row = $result->fetchRow()) {
                    $shares[] = $row['share_with'];
                    if ($returnUserPaths) {
                        $fileTargets[(int) $row['file_source']][$row['share_with']] = $row;
                    }
                }
            }
            // We also need to take group shares into account
            $query = \OC_DB::prepare('SELECT `share_with`, `file_source`, `file_target`
				FROM
				`*PREFIX*share`
				WHERE
				`item_source` = ? AND `share_type` = ? AND `item_type` IN (\'file\', \'folder\')');
            $result = $query->execute(array($source, self::SHARE_TYPE_GROUP));
            if (\OCP\DB::isError($result)) {
                \OCP\Util::writeLog('OCP\\Share', \OC_DB::getErrorMessage($result), \OC_Log::ERROR);
            } else {
                while ($row = $result->fetchRow()) {
                    $usersInGroup = \OC_Group::usersInGroup($row['share_with']);
                    $shares = array_merge($shares, $usersInGroup);
                    if ($returnUserPaths) {
                        foreach ($usersInGroup as $user) {
                            $fileTargets[(int) $row['file_source']][$user] = $row;
                        }
                    }
                }
            }
            //check for public link shares
            if (!$publicShare) {
                $query = \OC_DB::prepare('SELECT `share_with`
					FROM
					`*PREFIX*share`
					WHERE
					`item_source` = ? AND `share_type` = ? AND `item_type` IN (\'file\', \'folder\')');
                $result = $query->execute(array($source, self::SHARE_TYPE_LINK));
                if (\OCP\DB::isError($result)) {
                    \OCP\Util::writeLog('OCP\\Share', \OC_DB::getErrorMessage($result), \OC_Log::ERROR);
                } else {
                    if ($result->fetchRow()) {
                        $publicShare = true;
                    }
                }
            }
            // let's get the parent for the next round
            $meta = $cache->get((int) $source);
            if ($meta !== false) {
                $source = (int) $meta['parent'];
            } else {
                $source = -1;
            }
        }
        // Include owner in list of users, if requested
        if ($includeOwner) {
            $shares[] = $ownerUser;
            if ($returnUserPaths) {
                $sharePaths[$ownerUser] = $path;
            }
        }
        if ($returnUserPaths) {
            $fileTargetIDs = array_keys($fileTargets);
            $fileTargetIDs = array_unique($fileTargetIDs);
//.........这里部分代码省略.........
开发者ID:WYSAC,项目名称:oregon-owncloud,代码行数:101,代码来源:share.php

示例10: prepareEvents

 private function prepareEvents()
 {
     $sql = "SELECT \n\t\t\t\t\tDATEDIFF(obj.startdate, obj.enddate) as diff, \n\t\t\t\t\tcal.displayname as calendar, \n\t\t\t\t\tobj.summary as title, \n\t\t\t\t\tcal.calendarcolor as color, \n\t\t\t\t\tIF(obj.repeating=0,obj.startdate,rep.startdate) as eventStart, \n\t\t\t\t\tIF(repeating=0,obj.enddate,rep.enddate) as eventEnd,\n\t\t\t\t\tobj.calendardata as data\n\t\t\t\tFROM \n\t\t\t\t\t`*PREFIX*clndr_objects` obj \n\t\t\t\t\t\tLEFT JOIN \n\t\t\t\t\t`*PREFIX*clndr_repeat` rep ON obj.id = rep.eventid\n\t\t\t\t\t\tJOIN\n\t\t\t\t\t`*PREFIX*clndr_calendars` cal on cal.id = obj.calendarid\n\t\t\t\tWHERE obj.objecttype = 'VEVENT' AND\n\t\t\t\t\tuserid = ?  AND \n\t\t\t\t\t(\n\t\t\t\t\t\tDATE(obj.enddate) >= CURRENT_DATE\n\t\t\t\t\tOR \n\t\t\t\t\t\tDATE(rep.enddate) >= CURRENT_DATE\n\t\t\t\t\t)\n\t\t\t\tORDER BY\n\t\t\t\t\teventStart\n\t\t\t\tLIMIT " . $this->numEvents;
     $params = array($this->user);
     $query = \OCP\DB::prepare($sql);
     $result = $query->execute($params);
     if (\OCP\DB::isError($result)) {
         $this->errorMsg = "SQL Error";
         \OCP\Util::writeLog('ocDashboard', \OC_DB::getErrorMessage($result), \OC_Log::ERROR);
     }
     while ($row = $result->fetchRow()) {
         // with timezone
         $row['start'] = strtotime($row['eventStart']) + $this->timezoneAdd * 60 * 60;
         $row['end'] = strtotime($row['eventEnd']) + $this->timezoneAdd * 60 * 60;
         //withour timezone
         $row['origStart'] = strtotime($row['eventStart']);
         $row['origEnd'] = strtotime($row['eventEnd']);
         $this->events[] = $row;
     }
 }
开发者ID:kam1katze,项目名称:ocDashboard,代码行数:20,代码来源:calendar.php

示例11: deleteSentItems

 /**
  * Delete all entries we dealt with
  *
  * @param array $affectedUsers
  * @param int $maxTime
  */
 public function deleteSentItems($affectedUsers, $maxTime)
 {
     $placeholders = implode(',', array_fill(0, sizeof($affectedUsers), '?'));
     $queryParams = $affectedUsers;
     array_unshift($queryParams, (int) $maxTime);
     $query = \OCP\DB::prepare('DELETE FROM `*PREFIX*activity_mq` ' . ' WHERE `amq_timestamp` <= ? ' . ' AND `amq_affecteduser` IN (' . $placeholders . ')');
     $result = $query->execute($queryParams);
     if (\OCP\DB::isError($result)) {
         \OCP\Util::writeLog('Activity', \OCP\DB::getErrorMessage($result), \OCP\Util::ERROR);
     }
 }
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:17,代码来源:mailqueuehandler.php

示例12: deleteServerConfiguration

    /**
     * deletes a given saved LDAP/AD server configuration.
     * @param string $prefix the configuration prefix of the config to delete
     * @return bool true on success, false otherwise
     */
    public function deleteServerConfiguration($prefix)
    {
        if (!in_array($prefix, self::getServerConfigurationPrefixes())) {
            return false;
        }
        $saveOtherConfigurations = '';
        if (empty($prefix)) {
            $saveOtherConfigurations = 'AND `configkey` NOT LIKE \'s%\'';
        }
        $query = \OCP\DB::prepare('
			DELETE
			FROM `*PREFIX*appconfig`
			WHERE `configkey` LIKE ?
				' . $saveOtherConfigurations . '
				AND `appid` = \'user_ldap\'
				AND `configkey` NOT IN (\'enabled\', \'installed_version\', \'types\', \'bgjUpdateGroupsLastRun\')
		');
        $delRows = $query->execute(array($prefix . '%'));
        if (\OCP\DB::isError($delRows)) {
            return false;
        }
        if ($delRows === 0) {
            return false;
        }
        return true;
    }
开发者ID:loulancn,项目名称:core,代码行数:31,代码来源:helper.php

示例13: mapComponent

    /**
     * @brief inserts a new user or group into the mappings table
     * @param $dn the record in question
     * @param $ocname the name to use in ownCloud
     * @param $isUser is it a user or a group?
     * @returns true on success, false otherwise
     *
     * inserts a new user or group into the mappings table
     */
    private function mapComponent($dn, $ocname, $isUser = true)
    {
        $table = $this->getMapTable($isUser);
        $sqlAdjustment = '';
        $dbtype = \OCP\Config::getSystemValue('dbtype');
        if ($dbtype === 'mysql') {
            $sqlAdjustment = 'FROM DUAL';
        }
        $insert = \OCP\DB::prepare('
			INSERT INTO `' . $table . '` (`ldap_dn`, `owncloud_name`, `directory_uuid`)
				SELECT ?,?,?
				' . $sqlAdjustment . '
				WHERE NOT EXISTS (
					SELECT 1
					FROM `' . $table . '`
					WHERE `ldap_dn` = ?
						OR `owncloud_name` = ?)
		');
        //feed the DB
        $insRows = $insert->execute(array($dn, $ocname, $this->getUUID($dn, $isUser), $dn, $ocname));
        if (\OCP\DB::isError($insRows)) {
            return false;
        }
        if ($insRows === 0) {
            return false;
        }
        return true;
    }
开发者ID:omusico,项目名称:isle-web-framework,代码行数:37,代码来源:access.php

示例14: delete

 /**
  * @param $id
  * @return mixed
  */
 public function delete($id)
 {
     try {
         $query = 'SELECT COUNT(*) as `count` FROM `*PREFIX*contacts_cards` WHERE `id` = ? AND `addressbookid` = ?';
         $stmt = \OCP\DB::prepare($query);
         $result = $stmt->execute(array($id, $this->id));
         if (\OCP\DB::isError($result)) {
             \OCP\Util::writeLog('contacts', __METHOD__ . 'DB error: ' . \OC_DB::getErrorMessage($result), \OCP\Util::ERROR);
             return false;
         }
         if ((int) $result['count'] === 0) {
             \OCP\Util::writeLog('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);
 }
开发者ID:droiter,项目名称:openwrt-on-android,代码行数:24,代码来源:addressbookprovider.php

示例15: updateIndex

 /**
  * Update the contact property index.
  *
  * If vcard is null the properties for that contact will be purged.
  * If it is a valid object the old properties will first be purged
  * and the current properties indexed.
  *
  * @param string $contactId
  * @param VCard|null $vCard
  */
 public static function updateIndex($contactId, $vCard = null)
 {
     self::purgeIndexes(array($contactId));
     if (is_null($vCard)) {
         return;
     }
     if (!isset(self::$updateindexstmt)) {
         self::$updateindexstmt = \OCP\DB::prepare('INSERT INTO `' . self::$indexTableName . '` ' . '(`userid`, `contactid`,`name`,`value`,`preferred`) VALUES(?,?,?,?,?)');
     }
     foreach ($vCard->children as $property) {
         if (!in_array($property->name, self::$indexProperties)) {
             continue;
         }
         $preferred = 0;
         foreach ($property->parameters as $parameter) {
             if ($parameter->name == 'TYPE' && strtoupper($parameter->getValue()) == 'PREF') {
                 $preferred = 1;
                 break;
             }
         }
         try {
             $result = self::$updateindexstmt->execute(array(\OC::$server->getUserSession()->getUser()->getUId(), $contactId, $property->name, substr($property->getValue(), 0, 254), $preferred));
             if (\OCP\DB::isError($result)) {
                 \OCP\Util::writeLog('contacts', __METHOD__ . 'DB error: ' . \OC_DB::getErrorMessage($result), \OCP\Util::ERROR);
                 return false;
             }
         } catch (\Exception $e) {
             \OCP\Util::writeLog('contacts', __METHOD__ . ', exception: ' . $e->getMessage(), \OCP\Util::ERROR);
             return false;
         }
     }
 }
开发者ID:untitaker,项目名称:contacts,代码行数:42,代码来源:properties.php


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