public function getUnreadMessages($uid, $limit=null)
	{
		if (!$uid)
		{
			return array();
		}

		$r = $this->getTableName();
		$m = Message::blank()->getTableName();
		$s = Seen::blank()->getTableName();

		$entries = Message::all()
			->select($m . '.*,' . $r . '.expires,' . $r . '.actionid')
			//->join($m, $m . '.id', $r . '.mid', 'inner')
			->join($r, $m . '.id', $r . '.mid', 'inner')
			->whereEquals($r . '.uid', $uid)
			->where($r . '.state', '!=', 2)
			->whereRaw($m . ".id NOT IN (SELECT s.mid FROM `" . $s . "` AS s WHERE s.uid=" . $uid . ")")
			->order($r . '.created', 'desc');

		if ($limit)
		{
			$entries->limit($limit);
		}

		return $entries->rows();
	}
public function getUnreadMessages($uid, $limit=null)
	{
		if (!$uid)
		{
			return array();
		}

		$r = $this->getTableName();
		$m = Message::blank()->getTableName();
		$s = Seen::blank()->getTableName();

		$entries = Message::all()
			->select($m . '.*,' . $r . '.expires,' . $r . '.actionid')
			//->join($m, $m . '.id', $r . '.mid', 'inner')
			->join($r, $m . '.id', $r . '.mid', 'inner')
			->whereEquals($r . '.uid', $uid)
			->where($r . '.state', '!=', 2)
			->whereRaw($m . ".id NOT IN (SELECT s.mid FROM `" . $s . "` AS s WHERE s.uid=" . $uid . ")")
			->order($r . '.created', 'desc');

		if ($limit)
		{
			$entries->limit($limit);
		}

		return $entries->rows();
	}
public function getUnreadMessages ( $ uid , $ limit = null ) { if ( ! $ uid ) { return array ( ) ; } $ r = $ this -> getTableName ( ) ; $ m = Message :: blank ( ) -> getTableName ( ) ; $ s = Seen :: blank ( ) -> getTableName ( ) ; $ entries = Message :: all ( ) -> select ( $ m . '.*,' . $ r . '.expires,' . $ r . '.actionid' ) //->join($m, $m . '.id', $r . '.mid', 'inner') -> join ( $ r , $ m . '.id' , $ r . '.mid' , 'inner' ) -> whereEquals ( $ r . '.uid' , $ uid ) -> where ( $ r . '.state' , '!=' , 2 ) -> whereRaw ( $ m . ".id NOT IN (SELECT s.mid FROM `" . $ s . "` AS s WHERE s.uid=" . $ uid . ")" ) -> order ( $ r . '.created' , 'desc' ) ; if ( $ limit ) { $ entries -> limit ( $ limit ) ; } return $ entries -> rows ( ) ; }
Get a list of unread messages for a user

@param   integer  $uid    User ID
@param   integer  $limit  Number of records to return
@return  mixed    False if errors, array on success
Get a list of unread messages for a user