This commit is contained in:
Bernhard Posselt 2014-05-14 20:22:53 +02:00
Родитель b567d32b0e
Коммит 10d76fff64
2 изменённых файлов: 13 добавлений и 6 удалений

Просмотреть файл

@ -166,12 +166,19 @@ class ItemMapper extends Mapper implements IMapper {
return $this->findEntities($sql, $params);
}
private function getOperator($oldestFirst) {
if($oldestFirst) {
return '>';
} else {
return '<';
}
}
public function findAllFeed($id, $limit, $offset, $status, $userId, $oldestFirst=false){
$params = [$userId, $id];
$sql = 'AND `items`.`feed_id` = ? ';
if($offset !== 0){
$sql .= 'AND `items`.`id` < ? ';
$sql .= 'AND `items`.`id` ' . $this->getOperator($oldestFirst) . ' ? ';
$params[] = $offset;
}
$sql = $this->makeSelectQueryStatus($sql, $status, $oldestFirst);
@ -183,7 +190,7 @@ class ItemMapper extends Mapper implements IMapper {
$params = [$userId, $id];
$sql = 'AND `feeds`.`folder_id` = ? ';
if($offset !== 0){
$sql .= 'AND `items`.`id` < ? ';
$sql .= 'AND `items`.`id` ' . $this->getOperator($oldestFirst) . ' ? ';
$params[] = $offset;
}
$sql = $this->makeSelectQueryStatus($sql, $status, $oldestFirst);
@ -195,7 +202,7 @@ class ItemMapper extends Mapper implements IMapper {
$params = [$userId];
$sql = '';
if($offset !== 0){
$sql .= 'AND `items`.`id` < ? ';
$sql .= 'AND `items`.`id` ' . $this->getOperator($oldestFirst) . ' ? ';
$params[] = $offset;
}
$sql = $this->makeSelectQueryStatus($sql, $status, $oldestFirst);

Просмотреть файл

@ -234,7 +234,7 @@ class ItemMapperTest extends \OCP\AppFramework\Db\MapperTestUtility {
public function testFindAllFeedOldestFirst(){
$sql = 'AND `items`.`feed_id` = ? ' .
'AND `items`.`id` < ? ';
'AND `items`.`id` > ? ';
$sql = $this->makeSelectQueryStatus($sql, $this->status, true);
$params = [$this->user, $this->id, $this->offset];
$this->setMapperResult($sql, $params, $this->rows);
@ -272,7 +272,7 @@ class ItemMapperTest extends \OCP\AppFramework\Db\MapperTestUtility {
public function testFindAllFolderOldestFirst(){
$sql = 'AND `feeds`.`folder_id` = ? ' .
'AND `items`.`id` < ? ';
'AND `items`.`id` > ? ';
$sql = $this->makeSelectQueryStatus($sql, $this->status, true);
$params = [$this->user, $this->id, $this->offset];
$this->setMapperResult($sql, $params, $this->rows);
@ -308,7 +308,7 @@ class ItemMapperTest extends \OCP\AppFramework\Db\MapperTestUtility {
public function testFindAllOldestFirst(){
$sql = 'AND `items`.`id` < ? ';
$sql = 'AND `items`.`id` > ? ';
$sql = $this->makeSelectQueryStatus($sql, $this->status, true);
$params = [$this->user, $this->offset];
$this->setMapperResult($sql, $params, $this->rows);