This commit is contained in:
Bernhard Posselt 2013-03-22 21:49:36 +01:00
Родитель f9107664b0
Коммит 452d91ee39
2 изменённых файлов: 26 добавлений и 17 удалений

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

@ -49,15 +49,24 @@ class ItemMapper extends Mapper implements IMapper {
return $items;
}
protected function makeSelectQuery($prependTo){
return 'SELECT `*PREFIX*news_items`.* FROM `*PREFIX*news_items` ' .
'JOIN `*PREFIX*news_feeds` ' .
'ON `*PREFIX*news_feeds`.`id` = `*PREFIX*news_items`.`feed_id` '.
'AND `*PREFIX*news_feeds`.`user_id` = ? ' . $prependTo;
}
protected function makeFindAllFromFolderQuery($prependTo) {
return $this->makeSelectQuery(
'WHERE ((`*PREFIX*news_items`.`status` & ?) > 0) ' .
$prependTo
);
}
public function find($id, $userId){
$sql = 'SELECT `*PREFIX*news_items`.* FROM `*PREFIX*news_items` ' .
'JOIN `*PREFIX*news_feeds` ' .
'ON `*PREFIX*news_feeds`.`id` = `*PREFIX*news_items`.`feed_id` ' .
'AND `*PREFIX*news_feeds`.`user_id` = ? ' .
'WHERE `*PREFIX*news_items`.`id` = ? ';
$sql = $this->makeSelectQuery('WHERE `*PREFIX*news_items`.`id` = ? ');
$row = $this->findOneQuery($sql, array($id, $userId));
$item = new Item();

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

@ -65,23 +65,23 @@ class ItemMapperTest extends \OCA\AppFramework\Utility\MapperTestUtility {
}
private function makeFindAllFromFolderQuery($custom) {
private function makeSelectQuery($prependTo){
return 'SELECT `*PREFIX*news_items`.* FROM `*PREFIX*news_items` ' .
'JOIN `*PREFIX*news_feeds` ' .
'ON `*PREFIX*news_feeds`.`id` = `*PREFIX*news_items`.`feed_id` ' .
'AND `*PREFIX*news_feeds`.`folder_id` = ? ' .
'WHERE `*PREFIX*news_feeds`.`user_id` = ? ' .
'AND ((`*PREFIX*news_items`.`status` & ?) > 0) ' .
$custom;
'ON `*PREFIX*news_feeds`.`id` = `*PREFIX*news_items`.`feed_id` '.
'AND `*PREFIX*news_feeds`.`user_id` = ? ' . $prependTo;
}
private function makeFindAllFromFolderQuery($prependTo) {
return $this->makeSelectQuery(
'WHERE ((`*PREFIX*news_items`.`status` & ?) > 0) ' .
$prependTo
);
}
public function testFind(){
$sql = 'SELECT `*PREFIX*news_items`.* FROM `*PREFIX*news_items` ' .
'JOIN `*PREFIX*news_feeds` ' .
'ON `*PREFIX*news_feeds`.`id` = `*PREFIX*news_items`.`feed_id` ' .
'AND `*PREFIX*news_feeds`.`user_id` = ? ' .
'WHERE `*PREFIX*news_items`.`id` = ? ';
$sql = $this->makeSelectQuery('WHERE `*PREFIX*news_items`.`id` = ? ');
$this->setMapperResult($sql, array($this->id, $this->userId), $this->row);