$schemaManager->removeDBStructure($file);
}
- /**
- * check if a result is an error, works with Doctrine
- * @param mixed $result
- * @return bool
- */
- public static function isError($result) {
- //Doctrine returns false on error (and throws an exception)
- return $result === false;
- }
/**
* check if a result is an error and throws an exception, works with \Doctrine\DBAL\DBALException
* @param mixed $result
* @throws \OC\DatabaseException
*/
public static function raiseExceptionOnError($result, $message = null) {
- if(self::isError($result)) {
+ if($result === false) {
if ($message === null) {
$message = self::getErrorMessage();
} else {
$message .= ', Root cause:' . self::getErrorMessage();
}
- throw new \OC\DatabaseException($message, self::getErrorCode());
+ throw new \OC\DatabaseException($message, \OC::$server->getDatabaseConnection()->errorCode());
}
}
- public static function getErrorCode() {
- $connection = \OC::$server->getDatabaseConnection();
- return $connection->errorCode();
- }
/**
* returns the error code and message as a string for logging
* works with DoctrineException
public static function getShareByToken($token, $checkPasswordProtection = true) {
$query = \OC_DB::prepare('SELECT * FROM `*PREFIX*share` WHERE `token` = ?', 1);
$result = $query->execute(array($token));
- if (\OC_DB::isError($result)) {
+ if ($result === false) {
\OCP\Util::writeLog('OCP\Share', \OC_DB::getErrorMessage() . ', token=' . $token, \OCP\Util::ERROR);
}
$row = $result->fetchRow();
$root = strlen($root);
$query = \OC_DB::prepare('SELECT '.$select.' FROM `*PREFIX*share` '.$where, $queryLimit);
$result = $query->execute($queryArgs);
- if (\OC_DB::isError($result)) {
+ if ($result === false) {
\OCP\Util::writeLog('OCP\Share',
\OC_DB::getErrorMessage() . ', select=' . $select . ' where=',
\OCP\Util::ERROR);
if (isset($row['parent'])) {
$query = \OC_DB::prepare('SELECT `file_target` FROM `*PREFIX*share` WHERE `id` = ?');
$parentResult = $query->execute(array($row['parent']));
- if (\OC_DB::isError($result)) {
+ if ($result === false) {
\OCP\Util::writeLog('OCP\Share', 'Can\'t select parent: ' .
\OC_DB::getErrorMessage() . ', select=' . $select . ' where=' . $where,
\OCP\Util::ERROR);
$query = OC_DB::prepare('SELECT `uid`, `displayname` FROM `*PREFIX*users` WHERE LOWER(`uid`) = LOWER(?)');
$result = $query->execute(array($uid));
- if (OC_DB::isError($result)) {
+ if ($result === false) {
\OCP\Util::writeLog('core', OC_DB::getErrorMessage(), \OCP\Util::ERROR);
return false;
}
public function countUsers() {
$query = OC_DB::prepare('SELECT COUNT(*) FROM `*PREFIX*users`');
$result = $query->execute();
- if (OC_DB::isError($result)) {
+ if ($result === false) {
\OCP\Util::writeLog('core', OC_DB::getErrorMessage(), \OCP\Util::ERROR);
return false;
}