$query->andWhere($query->expr()->neq('uri', $query->createNamedParameter(BirthdayService::BIRTHDAY_CALENDAR_URI)));
}
- return (int)$query->execute()->fetchColumn();
+ $result = $query->execute();
+ $column = (int)$result->fetchColumn();
+ $result->closeCursor();
+ return $column;
}
/**
$query->select('synctoken')
->from($table)
->where($query->expr()->eq('id', $query->createNamedParameter($calendarId)));
- $syncToken = (int)$query->execute()->fetchColumn();
+ $result = $query->execute();
+ $syncToken = (int)$result->fetchColumn();
+ $result->closeCursor();
$query = $this->db->getQueryBuilder();
$query->insert('calendarchanges')
->from('addressbooks')
->where($query->expr()->eq('principaluri', $query->createNamedParameter($principalUri)));
- return (int)$query->execute()->fetchColumn();
+ $result = $query->execute();
+ $column = (int) $result->fetchColumn();
+ $result->closeCursor();
+ return $column;
}
/**
$query = $this->db->getQueryBuilder();
$query->select($query->createFunction('MAX(' . $query->getColumnName('id') . ')'))
->from('calendarobjects');
- $maxId = (int)$query->execute()->fetchColumn();
+ $result = $query->execute();
+ $maxId = (int) $result->fetchColumn();
+ $result->closeCursor();
$output->info('Add background job');
$this->jobList->add(BuildCalendarSearchIndexBackgroundJob::class, [
$query = $this->db->getQueryBuilder();
$query->select($query->createFunction('MAX(' . $query->getColumnName('id') . ')'))
->from('calendarobjects');
- $maxId = (int)$query->execute()->fetchColumn();
+ $result = $query->execute();
+ $maxId = (int) $result->fetchColumn();
+ $result->closeCursor();
$output->info('Add background job');
$this->jobList->add(BuildReminderIndexBackgroundJob::class, [
$this->invokePrivate($backend, 'updateProperties', [$bookId, $cardUri, $vCard->serialize()]);
$query = $this->db->getQueryBuilder();
- $result = $query->select('*')->from('cards_properties')->execute()->fetchAll();
+ $query->select('*')
+ ->from('cards_properties');
+
+ $qResult = $query->execute();
+ $result = $qResult->fetchAll();
+ $qResult->closeCursor();
$this->assertSame(2, count($result));
$this->invokePrivate($backend, 'updateProperties', [$bookId, $cardUri, $vCard->serialize()]);
$query = $this->db->getQueryBuilder();
- $result = $query->select('*')->from('cards_properties')->execute()->fetchAll();
+ $query->select('*')
+ ->from('cards_properties');
+
+ $qResult = $query->execute();
+ $result = $qResult->fetchAll();
+ $qResult->closeCursor();
$this->assertSame(1, count($result));
$this->invokePrivate($this->backend, 'purgeProperties', [1, 1]);
$query = $this->db->getQueryBuilder();
- $result = $query->select('*')->from('cards_properties')->execute()->fetchAll();
+ $query->select('*')
+ ->from('cards_properties');
+
+ $qResult = $query->execute();
+ $result = $qResult->fetchAll();
+ $qResult->closeCursor();
+
$this->assertSame(1, count($result));
$this->assertSame(1 ,(int)$result[0]['addressbookid']);
$this->assertSame(2 ,(int)$result[0]['cardid']);
->from('properties')
->where($query->expr()->eq('userid', $query->createNamedParameter($user)))
->where($query->expr()->eq('propertypath', $query->createNamedParameter($this->formatPath($path))));
- return $query->execute()->fetchAll(\PDO::FETCH_KEY_PAIR);
+
+
+ $result = $query->execute();
+ $data = $result->fetchAll(\PDO::FETCH_KEY_PAIR);
+ $result->closeCursor();
+ return $data;
}
public function testPropFindNoDbCalls() {
$query->select('*')->from($this->externalShareTable)
->where($query->expr()->eq('user', $query->createNamedParameter($share->getShareOwner())))
->andWhere($query->expr()->eq('mountpoint', $query->createNamedParameter($share->getTarget())));
- $result = $query->execute()->fetchAll();
+ $qResult = $query->execute();
+ $result = $qResult->fetchAll();
+ $qResult->closeCursor();
if (isset($result[0]) && (int)$result[0]['remote_id'] > 0) {
return $result[0];
$query = $this->dbConnection->getQueryBuilder();
$query->select('remote_id')->from('federated_reshares')
->where($query->expr()->eq('share_id', $query->createNamedParameter((int)$share->getId())));
- $data = $query->execute()->fetch();
+ $result = $query->execute();
+ $data = $result->fetch();
+ $result->closeCursor();
if (!is_array($data) || !isset($data['remote_id'])) {
throw new ShareNotFound();
$query->select('*')->from($this->dbTable)
->where($query->expr()->eq('id', $query->createParameter('id')))
->setParameter('id', $id);
- $query->execute();
- $result = $query->execute()->fetchAll();
+
+ $qResult = $query->execute();
+ $result = $qResult->fetchAll();
+ $qResult->closeCursor();
if (empty($result)) {
throw new \Exception('No Server found with ID: ' . $id);
);
$query = $this->connection->getQueryBuilder()->select('*')->from($this->dbTable);
- $result = $query->execute()->fetchAll();
+
+ $qResult = $query->execute();
+ $result = $qResult->fetchAll();
+ $qResult->closeCursor();
$this->assertEmpty($result, 'we need to start with a empty trusted_servers table');
}
$id = $this->dbHandler->addServer($url);
$query = $this->connection->getQueryBuilder()->select('*')->from($this->dbTable);
- $result = $query->execute()->fetchAll();
+
+ $qResult = $query->execute();
+ $result = $qResult->fetchAll();
+ $qResult->closeCursor();
$this->assertSame(1, count($result));
$this->assertSame($expectedUrl, $result[0]['url']);
$this->assertSame($id, (int)$result[0]['id']);
$id2 = $this->dbHandler->addServer('server2');
$query = $this->connection->getQueryBuilder()->select('*')->from($this->dbTable);
- $result = $query->execute()->fetchAll();
+
+ $qResult = $query->execute();
+ $result = $qResult->fetchAll();
+ $qResult->closeCursor();
$this->assertSame(2, count($result));
$this->assertSame('server1', $result[0]['url']);
$this->assertSame('server2', $result[1]['url']);
$this->dbHandler->removeServer($id2);
$query = $this->connection->getQueryBuilder()->select('*')->from($this->dbTable);
- $result = $query->execute()->fetchAll();
+
+ $qResult = $query->execute();
+ $result = $qResult->fetchAll();
+ $qResult->closeCursor();
$this->assertSame(1, count($result));
$this->assertSame('server1', $result[0]['url']);
$this->assertSame($id1, (int)$result[0]['id']);
public function XtestAddToken() {
$this->dbHandler->addServer('server1');
$query = $this->connection->getQueryBuilder()->select('*')->from($this->dbTable);
- $result = $query->execute()->fetchAll();
+
+ $qResult = $query->execute();
+ $result = $qResult->fetchAll();
+ $qResult->closeCursor();
$this->assertSame(1, count($result));
$this->assertSame(null, $result[0]['token']);
$this->dbHandler->addToken('http://server1', 'token');
$query = $this->connection->getQueryBuilder()->select('*')->from($this->dbTable);
- $result = $query->execute()->fetchAll();
+
+ $qResult = $query->execute();
+ $result = $qResult->fetchAll();
+ $qResult->closeCursor();
$this->assertSame(1, count($result));
$this->assertSame('token', $result[0]['token']);
}
public function XtestAddSharedSecret() {
$this->dbHandler->addServer('server1');
$query = $this->connection->getQueryBuilder()->select('*')->from($this->dbTable);
- $result = $query->execute()->fetchAll();
+
+ $qResult = $query->execute();
+ $result = $qResult->fetchAll();
+ $qResult->closeCursor();
$this->assertSame(1, count($result));
$this->assertSame(null, $result[0]['shared_secret']);
$this->dbHandler->addSharedSecret('http://server1', 'secret');
$query = $this->connection->getQueryBuilder()->select('*')->from($this->dbTable);
- $result = $query->execute()->fetchAll();
+
+ $qResult = $query->execute();
+ $result = $qResult->fetchAll();
+ $qResult->closeCursor();
$this->assertSame(1, count($result));
$this->assertSame('secret', $result[0]['shared_secret']);
}
public function testSetServerStatus() {
$this->dbHandler->addServer('server1');
$query = $this->connection->getQueryBuilder()->select('*')->from($this->dbTable);
- $result = $query->execute()->fetchAll();
+
+ $qResult = $query->execute();
+ $result = $qResult->fetchAll();
+ $qResult->closeCursor();
$this->assertSame(1, count($result));
$this->assertSame(TrustedServers::STATUS_PENDING, (int)$result[0]['status']);
$this->dbHandler->setServerStatus('http://server1', TrustedServers::STATUS_OK);
$query = $this->connection->getQueryBuilder()->select('*')->from($this->dbTable);
- $result = $query->execute()->fetchAll();
+
+ $qResult = $query->execute();
+ $result = $qResult->fetchAll();
+ $qResult->closeCursor();
$this->assertSame(1, count($result));
$this->assertSame(TrustedServers::STATUS_OK, (int)$result[0]['status']);
}
$query = $builder->select($fields)
->from($table)
->where($builder->expr()->in('mount_id', $placeHolders));
- $rows = $query->execute()->fetchAll();
+
+ $result = $query->execute();
+ $rows = $result->fetchAll();
+ $result->closeCursor();
$result = [];
foreach ($mountIds as $mountId) {
$storageCheckQuery = $qb->select('*')
->from('storages')
->where($qb->expr()->eq('numeric_id', $qb->expr()->literal($numericId)));
- $storages = $storageCheckQuery->execute()->fetchAll();
+
+ $result = $storageCheckQuery->execute();
+ $storages = $result->fetchAll();
+ $result->closeCursor();
$this->assertCount($expectedCountAfterDeletion, $storages, "expected $expectedCountAfterDeletion storages, got " . json_encode($storages));
}
$qb->select('*')
->from('storages')
->where($qb->expr()->eq('numeric_id', $qb->createNamedParameter($numericId)));
- $result = $qb->execute()->fetchAll();
+
+ $qResult = $qb->execute();
+ $result = $qResult->fetchAll();
+ $qResult->closeCursor();
if (!empty($result)) {
return true;
}
$qb->select('*')
->from('filecache')
->where($qb->expr()->eq('storage', $qb->createNamedParameter($numericId)));
- $result = $qb->execute()->fetchAll();
+
+ $qResult = $qb->execute();
+ $result = $qResult->fetchAll();
+ $qResult->closeCursor();
if (!empty($result)) {
return true;
}
$query = $this->connection->getQueryBuilder();
$query->select('*')
->from('share');
- $allShares = $query->execute()->fetchAll();
+ $result = $query->execute();
+ $allShares = $result->fetchAll();
+ $result->closeCursor();
foreach ($allShares as $share) {
if ((int)$share['share_type'] === IShare::TYPE_LINK) {
->andWhere($query->expr()->eq('parent', $query->createNamedParameter($parentId)))
->andWhere($query->expr()->iLike('name', $query->createNamedParameter($pattern)));
+ $result = $query->execute();
+ $entries = $result->fetchAll();
+ $result->closeCursor();
+
/** @var CacheEntry[] $matches */
$matches = array_map(function (array $data) {
return Cache::cacheEntryFromData($data, \OC::$server->getMimeTypeLoader());
- }, $query->execute()->fetchAll());
+ }, $entries);
foreach ($matches as $ma) {
if ($timestamp) {
// if the delete operation was execute only files from user1
// should be left.
$query = $this->dbConnection->getQueryBuilder();
- $result = $query->select('user')
- ->from($this->trashTable)
- ->execute()->fetchAll();
+ $query->select('user')
+ ->from($this->trashTable);
+
+ $qResult = $query->execute();
+ $result = $qResult->fetchAll();
+ $qResult->closeCursor();
+
$this->assertSame(5, count($result));
foreach ($result as $r) {
$this->assertSame('user1', $r['user']);
);
$qb = $this->connection->getQueryBuilder();
- $result = $qb->select('*')
+ $qb->select('*')
->from('share')
- ->where($qb->expr()->eq('id', $qb->createNamedParameter($id)))
- ->execute()->fetchAll();
+ ->where($qb->expr()->eq('id', $qb->createNamedParameter($id)));
+
+ $qResult = $qb->execute();
+ $result = $qResult->fetchAll();
+ $qResult->closeCursor();
$this->assertSame(1, count($result));
);
$qb = $this->connection->getQueryBuilder();
- $result = $qb->select('*')
+ $qb->select('*')
->from('share')
- ->where($qb->expr()->eq('id', $qb->createNamedParameter($id)))
- ->execute()->fetchAll();
+ ->where($qb->expr()->eq('id', $qb->createNamedParameter($id)));
+
+ $qResult = $qb->execute();
+ $result = $qResult->fetchAll();
+ $qResult->closeCursor();
$this->assertSame(1, count($result));
$query = $this->connection->getQueryBuilder();
$query->select('*')->from('share')
->where($query->expr()->eq('id', $query->createNamedParameter($id)));
- $before = $query->execute()->fetchAll();
+
+ $result = $query->execute();
+ $before = $result->fetchAll();
+ $result->closeCursor();
$this->assertTrue(is_array($before));
$this->assertSame(1, count($before));
$query = $this->connection->getQueryBuilder();
$query->select('*')->from('share')
->where($query->expr()->eq('id', $query->createNamedParameter($id)));
- $after = $query->execute()->fetchAll();
+
+ $result = $query->execute();
+ $after = $result->fetchAll();
+ $result->closeCursor();
$this->assertTrue(is_array($after));
$this->assertEmpty($after);
$query = $this->connection->getQueryBuilder();
$query->select('*')->from('share');
- $before = $query->execute()->fetchAll();
+
+ $result = $query->execute();
+ $before = $result->fetchAll();
+ $result->closeCursor();
$this->assertTrue(is_array($before));
$this->assertSame(2, count($before));
$query = $this->connection->getQueryBuilder();
$query->select('*')->from('share');
- $after = $query->execute()->fetchAll();
+
+ $result = $query->execute();
+ $after = $result->fetchAll();
+ $result->closeCursor();
$this->assertTrue(is_array($after));
$this->assertSame(1, count($after));
$query->whereFileId($file);
}
- $data = $query->execute()->fetch();
+ $result = $query->execute();
+ $data = $result->fetch();
+ $result->closeCursor();
//merge partial data
if (!$data and is_string($file) and isset($this->partial[$file])) {
->whereParent($fileId)
->orderBy('name', 'ASC');
- $files = $query->execute()->fetchAll();
+ $result = $query->execute();
+ $files = $result->fetchAll();
+ $result->closeCursor();
+
return array_map(function (array $data) {
return self::cacheEntryFromData($data, $this->mimetypeLoader);
}, $files);
->whereStorageId()
->wherePath($file);
- $id = $query->execute()->fetchColumn();
+ $result = $query->execute();
+ $id = $result->fetchColumn();
+ $result->closeCursor();
+
return $id === false ? -1 : (int)$id;
}
->from('filecache')
->whereStorageId()
->wherePath($file);
- $size = $query->execute()->fetchColumn();
+
+ $result = $query->execute();
+ $size = $result->fetchColumn();
+ $result->closeCursor();
+
if ($size !== false) {
if ((int)$size === -1) {
return self::SHALLOW;
->whereStorageId()
->andWhere($query->expr()->iLike('name', $query->createNamedParameter($pattern)));
+ $result = $query->execute();
+ $files = $result->fetchAll();
+ $result->closeCursor();
+
return array_map(function (array $data) {
return self::cacheEntryFromData($data, $this->mimetypeLoader);
- }, $query->execute()->fetchAll());
+ }, $files);
}
/**
$query->andWhere($query->expr()->eq('mimepart', $query->createNamedParameter($mimeId, IQueryBuilder::PARAM_INT)));
}
+ $result = $query->execute();
+ $files = $result->fetchAll();
+ $result->closeCursor();
+
return array_map(function (array $data) {
return self::cacheEntryFromData($data, $this->mimetypeLoader);
- }, $query->execute()->fetchAll());
+ }, $files);
}
public function searchQuery(ISearchQuery $searchQuery) {
->whereParent($fileId)
->andWhere($query->expr()->lt('size', $query->createNamedParameter(0, IQueryBuilder::PARAM_INT)));
- return (int)$query->execute()->fetchColumn();
+ $result = $query->execute();
+ $size = (int)$result->fetchColumn();
+ $result->closeCursor();
+
+ return $size;
}
return -1;
}
->whereStorageId()
->whereParent($id);
- if ($row = $query->execute()->fetch()) {
+ $result = $query->execute();
+ $row = $result->fetch();
+ $result->closeCursor();
+
+ if ($row) {
[$sum, $min] = array_values($row);
$sum = 0 + $sum;
$min = 0 + $min;
->from('filecache')
->whereStorageId();
+ $result = $query->execute();
+ $files = $result->fetchAll(\PDO::FETCH_COLUMN);
+ $result->closeCursor();
+
return array_map(function ($id) {
return (int)$id;
- }, $query->execute()->fetchAll(\PDO::FETCH_COLUMN));
+ }, $files);
}
/**
->andWhere($query->expr()->lt('size', $query->createNamedParameter(0, IQueryBuilder::PARAM_INT)))
->orderBy('fileid', 'DESC');
- return $query->execute()->fetchColumn();
+ $result = $query->execute();
+ $path = $result->fetchColumn();
+ $result->closeCursor();
+
+ return $path;
}
/**
->whereStorageId()
->whereFileId($id);
- $path = $query->execute()->fetchColumn();
+ $result = $query->execute();
+ $path = $result->fetchColumn();
+ $result->closeCursor();
+
return $path === false ? null : $path;
}
$query->select('path', 'storage')
->from('filecache')
->where($query->expr()->eq('fileid', $query->createNamedParameter($id, IQueryBuilder::PARAM_INT)));
- if ($row = $query->execute()->fetch()) {
+
+ $result = $query->execute();
+ $row = $result->fetch();
+ $result->closeCursor();
+
+ if ($row) {
$numericId = $row['storage'];
$path = $row['path'];
} else {
$this->update($id, ['size' => $totalSize]);
}
}
+ $result->closeCursor();
}
return $totalSize;
}
while ($row = $result->fetch()) {
$this->cache[$row['id']] = $row;
}
+ $result->closeCursor();
}
/**
->from('storages')
->where($builder->expr()->eq('id', $builder->createNamedParameter($storageId)));
- $row = $query->execute()->fetch();
+ $result = $query->execute();
+ $row = $result->fetch();
+ $result->closeCursor();
+
if ($row) {
$this->cache[$storageId] = $row;
}
->innerJoin('m', 'filecache', 'f', $builder->expr()->eq('m.root_id', 'f.fileid'))
->where($builder->expr()->eq('user_id', $builder->createPositionalParameter($user->getUID())));
- $rows = $query->execute()->fetchAll();
+ $result = $query->execute();
+ $rows = $result->fetchAll();
+ $result->closeCursor();
$this->mountsForUsers[$user->getUID()] = array_filter(array_map([$this, 'dbRowToMountInfo'], $rows));
}
$query->andWhere($builder->expr()->eq('user_id', $builder->createPositionalParameter($user)));
}
- $rows = $query->execute()->fetchAll();
+ $result = $query->execute();
+ $rows = $result->fetchAll();
+ $result->closeCursor();
return array_filter(array_map([$this, 'dbRowToMountInfo'], $rows));
}
->innerJoin('m', 'filecache', 'f', $builder->expr()->eq('m.root_id', 'f.fileid'))
->where($builder->expr()->eq('root_id', $builder->createPositionalParameter($rootFileId, IQueryBuilder::PARAM_INT)));
- $rows = $query->execute()->fetchAll();
+ $result = $query->execute();
+ $rows = $result->fetchAll();
+ $result->closeCursor();
return array_filter(array_map([$this, 'dbRowToMountInfo'], $rows));
}
->from('filecache')
->where($builder->expr()->eq('fileid', $builder->createNamedParameter($fileId, IQueryBuilder::PARAM_INT)));
- $row = $query->execute()->fetch();
+ $result = $query->execute();
+ $row = $result->fetch();
+ $result->closeCursor();
+
if (is_array($row)) {
$this->cacheInfoCache[$fileId] = [
(int)$row['storage'],
->setMaxResults($limit)
->setFirstResult($offset);
- return $query->execute()->fetchAll();
+ $result = $query->execute();
+ $rows = $result->fetchAll();
+ $result->closeCursor();
+
+ return $rows;
}
private function recentParse($result, $mountMap, $mimetypeLoader) {
->where(
$fetch->expr()->eq('mimetype', $fetch->createNamedParameter($mimetype)
));
- $row = $fetch->execute()->fetch();
+
+ $result = $fetch->execute();
+ $row = $result->fetch();
+ $result->closeCursor();
if (!$row) {
throw new \Exception("Failed to get mimetype id for $mimetype after trying to store it");
$qb = $this->dbConnection->getQueryBuilder();
$qb->select('id', 'mimetype')
->from('mimetypes');
- $results = $qb->execute()->fetchAll();
+
+ $result = $qb->execute();
+ $results = $result->fetchAll();
+ $result->closeCursor();
foreach ($results as $row) {
$this->mimetypes[$row['id']] = $row['mimetype'];
->where($qb->expr()->eq('user', $qb->createNamedParameter((string)$userId)))
->andWhere($qb->expr()->eq('identifier', $qb->createNamedParameter($identifier)))
;
- $result = $qb->execute()->fetch();
+
+ $qResult = $qb->execute();
+ $result = $qResult->fetch();
+ $qResult->closeCursor();
if (!$result) {
return null;
}
$shares[] = $row;
}
+ $result->closeCursor();
//if didn't found a result than let's look for a group share.
if (empty($shares) && $user !== null) {
->from('share')
->where($query->expr()->eq('id', $query->createNamedParameter($row['parent'])));
- $result = $query->execute();
- $parentRow = $result->fetch();
- $result->closeCursor();
+ $parentResult = $query->execute();
+ $parentRow = $parentResult->fetch();
+ $parentResult->closeCursor();
if ($parentRow === false) {
\OCP\Util::writeLog('OCP\Share', 'Can\'t select parent: ' .
->andWhere($query->expr()->eq('c.type', $query->createNamedParameter($objectType)))
->andWhere($query->expr()->eq('c.category', $query->createNamedParameter(ITags::TAG_FAVORITE)));
- return $query->execute()->fetchAll(\PDO::FETCH_COLUMN);
+ $result = $query->execute();
+ $users = $result->fetchAll(\PDO::FETCH_COLUMN);
+ $result->closeCursor();
+
+ return $users;
}
}
$stmt = \OC_DB::prepare($sql);
$result = $stmt->execute([$tagId]);
if ($result === null) {
+ $stmt->closeCursor();
\OCP\Util::writeLog('core', __METHOD__. 'DB error: ' . \OC::$server->getDatabaseConnection()->getError(), ILogger::ERROR);
return false;
}
while ($row = $result->fetchRow()) {
$ids[] = (int)$row['objid'];
}
+ $result->closeCursor();
}
return $ids;
]);
}
}
+ $result->closeCursor();
} catch (\Exception $e) {
\OC::$server->getLogger()->logException($e, [
'message' => __METHOD__,
return $this->statement->fetchColumn($column);
}
+ /**
+ * Closes the cursor, enabling the statement to be executed again.
+ *
+ * @deprecated Use Result::free() instead.
+ */
+ public function closeCursor(): void {
+ $this->statement->closeCursor();
+ }
+
/**
* Binds a PHP variable to a corresponding named or question mark placeholder in the
* SQL statement that was use to prepare the statement.
try {
$result = \OC_DB::executeAudited('SHOW SERVER_VERSION');
$data = $result->fetchRow();
+ $result->closeCursor();
if (isset($data['server_version'])) {
$version = $data['server_version'];
if (version_compare($version, '9.0.0', '<')) {
->where($query->expr()->eq('uid', $query->createParameter('uid')))
->setParameter('uid', $uid);
$query->execute();
- $result = $query->execute()->fetchAll();
+
+ $qResult = $query->execute();
+ $result = $qResult->fetchAll();
+ $qResult->closeCursor();
if (!empty($result)) {
return json_decode($result[0]['data'], true);
$this->assertEquals('bar', $this->getTextValueByIntergerField(1));
}
-
+
public function testSetValuesOverWritePreconditionFailed() {
$this->expectException(\OCP\PreConditionNotMetException::class);
$this->assertEquals(0, $result);
}
-
+
public function testUniqueConstraintViolating() {
$this->expectException(\Doctrine\DBAL\Exception\UniqueConstraintViolationException::class);
$this->assertTrue((bool)$result);
$row = $result->fetchRow();
$this->assertFalse($row);
+ $result->closeCursor();
+
$query = OC_DB::prepare('INSERT INTO `*PREFIX*'.$this->table2.'` (`fullname`,`uri`) VALUES (?,?)');
$result = $query->execute(['fullname test', 'uri_1']);
$this->assertEquals(1, $result);
$this->assertEquals($row['fullname'], 'fullname test');
$row = $result->fetchRow();
$this->assertFalse((bool)$row); //PDO returns false, MDB2 returns null
+ $result->closeCursor();
}
/**
$query = OC_DB::prepare('SELECT `fullname`,`uri` FROM `*PREFIX*'.$this->table2.'` WHERE `uri` = ?');
$result = $query->execute(['uri_2']);
$this->assertTrue((bool)$result);
+ $result->closeCursor();
}
public function testUNIX_TIMESTAMP() {
$query = OC_DB::prepare('SELECT `fullname`,`uri` FROM `*PREFIX*'.$this->table2.'` WHERE `uri` = ?');
$result = $query->execute(['uri_3']);
$this->assertTrue((bool)$result);
+ $result->closeCursor();
}
public function testLastInsertId() {
$result = $query->execute([$expected, 'uri_1', 'This is a vCard']);
$this->assertEquals(1, $result);
- $actual = OC_DB::prepare("SELECT `fullname` FROM `$table`")->execute()->fetchOne();
+ $query = OC_DB::prepare("SELECT `fullname` FROM `$table`");
+
+ $result = $query->execute();
+ $actual = $result->fetchOne();
+ $result->closeCursor();
+
$this->assertSame($expected, $actual);
}
$result = $query->execute();
$this->assertTrue((bool)$result);
$row = $result->fetchRow();
+ $result->closeCursor();
$this->assertArrayHasKey($rowname, $row);
$this->assertEquals($expect, $row[$rowname]);
$query = OC_DB::prepare('DELETE FROM `' . $table . '`');
$query = OC_DB::prepare("SELECT * FROM `$table` WHERE `fullname` LIKE ?");
$result = $query->execute(['foobar']);
$this->assertCount(0, $result->fetchAll());
+ $result->closeCursor();
$query = OC_DB::prepare("SELECT * FROM `$table` WHERE `fullname` ILIKE ?");
$result = $query->execute(['foobar']);
$this->assertCount(1, $result->fetchAll());
+ $result->closeCursor();
$query = OC_DB::prepare("SELECT * FROM `$table` WHERE `fullname` ILIKE ?");
$result = $query->execute(['foo']);
$this->assertCount(0, $result->fetchAll());
+ $result->closeCursor();
}
public function testILIKEWildcard() {
$query = OC_DB::prepare("SELECT * FROM `$table` WHERE `fullname` LIKE ?");
$result = $query->execute(['%bar']);
$this->assertCount(0, $result->fetchAll());
+ $result->closeCursor();
$query = OC_DB::prepare("SELECT * FROM `$table` WHERE `fullname` LIKE ?");
$result = $query->execute(['foo%']);
$this->assertCount(0, $result->fetchAll());
+ $result->closeCursor();
$query = OC_DB::prepare("SELECT * FROM `$table` WHERE `fullname` LIKE ?");
$result = $query->execute(['%ba%']);
$this->assertCount(0, $result->fetchAll());
+ $result->closeCursor();
$query = OC_DB::prepare("SELECT * FROM `$table` WHERE `fullname` ILIKE ?");
$result = $query->execute(['%bar']);
$this->assertCount(1, $result->fetchAll());
+ $result->closeCursor();
$query = OC_DB::prepare("SELECT * FROM `$table` WHERE `fullname` ILIKE ?");
$result = $query->execute(['foo%']);
$this->assertCount(1, $result->fetchAll());
+ $result->closeCursor();
$query = OC_DB::prepare("SELECT * FROM `$table` WHERE `fullname` ILIKE ?");
$result = $query->execute(['%ba%']);
$this->assertCount(1, $result->fetchAll());
+ $result->closeCursor();
}
/**
$result = $query->execute([$expected]);
$this->assertEquals(1, $result);
- $actual = OC_DB::prepare("SELECT `textfield` FROM `$table`")->execute()->fetchOne();
+ $query = OC_DB::prepare("SELECT `textfield` FROM `$table`");
+
+ $result = $query->execute();
+ $actual = $result->fetchOne();
+ $result->closeCursor();
$this->assertSame($expected, $actual);
}
->from('users')
->where($query->expr()->like($query->createNamedParameter($param1), $query->createNamedParameter($param2)));
- $this->assertEquals($match, $query->execute()->fetchColumn());
+ $result = $query->execute();
+ $column = $result->fetchColumn();
+ $result->closeCursor();
+ $this->assertEquals($match, $column);
}
public function ilikeProvider() {
->from('users')
->where($query->expr()->iLike($query->createNamedParameter($param1), $query->createNamedParameter($param2)));
- $this->assertEquals($match, $query->execute()->fetchColumn());
+ $result = $query->execute();
+ $column = $result->fetchColumn();
+ $result->closeCursor();
+ $this->assertEquals($match, $column);
}
}
$query->from('appconfig')
->setMaxResults(1);
- $this->assertEquals('foobar', $query->execute()->fetchColumn());
+ $result = $query->execute();
+ $column = $result->fetchColumn();
+ $result->closeCursor();
+ $this->assertEquals('foobar', $column);
}
public function testMd5() {
$query->from('appconfig')
->setMaxResults(1);
- $this->assertEquals(md5('foobar'), $query->execute()->fetchColumn());
+ $result = $query->execute();
+ $column = $result->fetchColumn();
+ $result->closeCursor();
+ $this->assertEquals(md5('foobar'), $column);
}
public function testSubstring() {
$query->from('appconfig')
->setMaxResults(1);
- $this->assertEquals('oo', $query->execute()->fetchColumn());
+ $result = $query->execute();
+ $column = $result->fetchColumn();
+ $result->closeCursor();
+ $this->assertEquals('oo', $column);
}
public function testSubstringNoLength() {
$query->from('appconfig')
->setMaxResults(1);
- $this->assertEquals('oobar', $query->execute()->fetchColumn());
+ $result = $query->execute();
+ $column = $result->fetchColumn();
+ $result->closeCursor();
+ $this->assertEquals('oobar', $column);
}
public function testLower() {
$query->from('appconfig')
->setMaxResults(1);
- $this->assertEquals('foobar', $query->execute()->fetchColumn());
+ $result = $query->execute();
+ $column = $result->fetchColumn();
+ $result->closeCursor();
+ $this->assertEquals('foobar', $column);
}
public function testAdd() {
$query->from('appconfig')
->setMaxResults(1);
- $this->assertEquals(3, $query->execute()->fetchColumn());
+ $result = $query->execute();
+ $column = $result->fetchColumn();
+ $result->closeCursor();
+ $this->assertEquals(3, $column);
}
public function testSubtract() {
$query->from('appconfig')
->setMaxResults(1);
- $this->assertEquals(1, $query->execute()->fetchColumn());
+ $result = $query->execute();
+ $column = $result->fetchColumn();
+ $result->closeCursor();
+ $this->assertEquals(1, $column);
}
public function testCount() {
$query->from('appconfig')
->setMaxResults(1);
- $this->assertGreaterThan(1, $query->execute()->fetchColumn());
+ $result = $query->execute();
+ $column = $result->fetchColumn();
+ $result->closeCursor();
+ $this->assertGreaterThan(1, $column);
}
private function setUpMinMax($value) {
->where($query->expr()->eq('appid', $query->createNamedParameter('minmax')))
->setMaxResults(1);
- $this->assertEquals(null, $query->execute()->fetchColumn());
+ $result = $query->execute();
+ $row = $result->fetchColumn();
+ $result->closeCursor();
+ $this->assertEquals(null, $row);
}
public function testMinEmpty() {
->where($query->expr()->eq('appid', $query->createNamedParameter('minmax')))
->setMaxResults(1);
- $this->assertEquals(null, $query->execute()->fetchColumn());
+ $result = $query->execute();
+ $row = $result->fetchColumn();
+ $result->closeCursor();
+ $this->assertEquals(null, $row);
}
public function testMax() {
->where($query->expr()->eq('appid', $query->createNamedParameter('minmax')))
->setMaxResults(1);
- $this->assertEquals(20, $query->execute()->fetchColumn());
+ $result = $query->execute();
+ $row = $result->fetchColumn();
+ $result->closeCursor();
+ $this->assertEquals(20, $row);
}
public function testMin() {
->where($query->expr()->eq('appid', $query->createNamedParameter('minmax')))
->setMaxResults(1);
- $this->assertEquals(10, $query->execute()->fetchColumn());
+ $result = $query->execute();
+ $row = $result->fetchColumn();
+ $result->closeCursor();
+ $this->assertEquals(10, $row);
}
public function testGreatest() {
$query->from('appconfig')
->setMaxResults(1);
- $this->assertEquals(2, $query->execute()->fetchColumn());
+ $result = $query->execute();
+ $row = $result->fetchColumn();
+ $result->closeCursor();
+ $this->assertEquals(2, $row);
}
public function testLeast() {
$query->from('appconfig')
->setMaxResults(1);
- $this->assertEquals(1, $query->execute()->fetchColumn());
+ $result = $query->execute();
+ $row = $result->fetchColumn();
+ $result->closeCursor();
+ $this->assertEquals(1, $row);
}
}
private function search(ISearchOperator $operator) {
$dbOperator = $this->querySearchHelper->searchOperatorToDBExpr($this->builder, $operator);
$this->builder->andWhere($dbOperator);
- return $this->builder->execute()->fetchAll(\PDO::FETCH_COLUMN);
+
+ $result = $this->builder->execute();
+ $rows = $result->fetchAll(\PDO::FETCH_COLUMN);
+ $result->closeCursor();
+
+ return $rows;
}
public function comparisonProvider() {
->from('mimetypes')
->where($qb->expr()->eq('id', $qb->createPositionalParameter($mimetypeId)));
- $mimetype = $qb->execute()->fetch();
+ $result = $qb->execute();
+ $mimetype = $result->fetch();
+ $result->closeCursor();
$this->assertEquals('testing/mymimetype', $mimetype['mimetype']);
$this->assertEquals('testing/mymimetype', $this->loader->getMimetypeById($mimetypeId));
$query->select('lock')
->from('file_locks')
->where($query->expr()->eq('key', $query->createNamedParameter($key)));
- return $query->execute()->fetchColumn();
+
+ $result = $query->execute();
+ $rows = $result->fetchColumn();
+ $result->closeCursor();
+
+ return $rows;
}
public function testDoubleShared() {