for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Copyright (c) 2014, Tobia De Koninck hey--at--ledfan.be
* This file is licensed under the AGPL version 3 or later.
* See the COPYING file.
*/
namespace OCA\Chat\OCH\Db;
use \OCP\AppFramework\Db\Mapper;
use \OCP\IDb;
class MessageMapper extends Mapper{
public function __construct(IDb $api) {
parent::__construct($api, 'chat_och_messages'); // tablename is news_feeds
}
public function getMessagesByConvId($convId, $user, $startpoint=0){
$sql = <<<SQL
SELECT
*
FROM
*PREFIX*chat_och_messages
WHERE
`convid` = ?
AND
`timestamp` > (
`joined`
*PREFIX*chat_och_users_in_conversation
`user` = ?
AND `conversation_id` = ?
)
SQL;
if($startpoint !== 0){
$sql = $sql . <<<SQL
`timestamp` > ?
return $this->findEntities($sql, array($convId, $user, $convId, $startpoint));
} else {
return $this->findEntities($sql, array($convId, $user, $convId));
public function getMessagesByConvIdLimit($convId, $user, $limit){
ORDER BY timestamp DESC
LIMIT ?,?
return $this->findEntities($sql, array($convId, $user, $convId, $limit[0], $limit[1]));