src/Neuron/GameServer/Mappers/ChatMapper.php
public function getMessages ($channelId, $limit = 20, $since = null, $before = null)
	{
		$db = Neuron_DB_Database::getInstance ();

		$additionalWhere = "";

		if (!isset ($since))
		{
			$since = $this->getNewSince ($channelId, $limit, $before);

			// raise the limit to load everything at once
			$limit ++;
		}

		// If since is null & before is set, return empty array.
		if ($since === null && isset ($before))
		{
			return array ();
		}

		$additionalWhere = "AND c_m_id > '" . $since . "' ";

		if (isset ($before))
		{
			$additionalWhere .= "AND c_m_id < '" . $before . "' ";			
		}

		$sql = "
			SELECT
				*,
				UNIX_TIMESTAMP(c_date) AS date
			FROM
				n_chat_messages
			WHERE
				c_c_id = '{$channelId}'
				{$additionalWhere}
			ORDER BY
				c_m_id ASC
			LIMIT
				{$limit}
		";

		//echo $sql;

		$message = $db->query ($sql);

		return $this->getDataFromReader ($message);
	}
public function getMessages ($channelId, $limit = 20, $since = null, $before = null)
	{
		$db = Neuron_DB_Database::getInstance ();

		$additionalWhere = "";

		if (!isset ($since))
		{
			$since = $this->getNewSince ($channelId, $limit, $before);

			// raise the limit to load everything at once
			$limit ++;
		}

		// If since is null & before is set, return empty array.
		if ($since === null && isset ($before))
		{
			return array ();
		}

		$additionalWhere = "AND c_m_id > '" . $since . "' ";

		if (isset ($before))
		{
			$additionalWhere .= "AND c_m_id < '" . $before . "' ";			
		}

		$sql = "
			SELECT
				*,
				UNIX_TIMESTAMP(c_date) AS date
			FROM
				n_chat_messages
			WHERE
				c_c_id = '{$channelId}'
				{$additionalWhere}
			ORDER BY
				c_m_id ASC
			LIMIT
				{$limit}
		";

		//echo $sql;

		$message = $db->query ($sql);

		return $this->getDataFromReader ($message);
	}
Return the latest messages since $since.
$since should be the last received message ID.