src/snac/server/database/SQL.php
/**
     * Select Messages for UserID
     *
     * Selects all non-deleted messages for the given userID.  By default, it gives both read and unread messages
     * sent to this user.
     *
     * @param int $userid The userid of the user
     * @param boolean $toUser optional Whether or not to select messages to this user (or from this user)
     * @param boolean $unreadOnly optional Whether to query only unread messages (default false)
     * @param boolean $archivedOnly optional Whether to query only archived messages (default false)
     * @return string[] The list of message data for the user
     */
Select Messages for UserID
Selects all non-deleted messages for the given userID.  By default, it gives both read and unread messages
sent to this user.


Select Messages for UserID Selects all non - deleted messages for the given userID . By default it gives both read and unread messages sent to this user .
public function selectMessagesForUserID($userid, $toUser=true, $unreadOnly=false, $archivedOnly=false) {
        $searchUser = 'to_user';
        if (!$toUser) {
            $searchUser = 'from_user';
        }
        $readFilter = '';
        if ($unreadOnly) {
            $readFilter = 'and not read';
        }
        $archiveFilter= ($archivedOnly ? "deleted " : "not deleted");
        $result = $this->sdb->query(
            'select m.*,to_char(m.time_sent, \'YYYY-MM-DD"T"HH24:MI:SS\') as sent_date from messages m where '
            .$archiveFilter.' and '.$searchUser.' = $1 '.$readFilter.' order by m.time_sent desc',
            array($userid));
        $all = array();
        while ($row = $this->sdb->fetchrow($result)) {
            array_push($all, $row);
        }
        return $all;
    }
public function selectMessagesForUserID ( $ userid , $ toUser = true , $ unreadOnly = false , $ archivedOnly = false ) { $ searchUser = 'to_user' ; if ( ! $ toUser ) { $ searchUser = 'from_user' ; } $ readFilter = '' ; if ( $ unreadOnly ) { $ readFilter = 'and not read' ; } $ archiveFilter = ( $ archivedOnly ? " deleted  " : " not deleted " ) ; $ result = $ this -> sdb -> query ( 'select m.*,to_char(m.time_sent, \'YYYY-MM-DD"T"HH24:MI:SS\') as sent_date from messages m where ' . $ archiveFilter . ' and ' . $ searchUser . ' = $1 ' . $ readFilter . ' order by m.time_sent desc' , array ( $ userid ) ) ; $ all = array ( ) ; while ( $ row = $ this -> sdb -> fetchrow ( $ result ) ) { array_push ( $ all , $ row ) ; } return $ all ; }
Select Messages for UserID
 Selects all non-deleted messages for the given userID.
Select Messages for UserID Selects all non - deleted messages for the given userID .
// select only deleted messages if $archivedOnly is true