Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Not a member yet? Click here to register.
Forgot Password?

V9 PM Table Structrure Explained

Asked Modified Viewed 1,171 times
C
Chan
C
Chan 0
Lead Developer of PHP-Fusion
  • Super Admin, joined since
  • Contributed 3,841 posts on the community forums.
  • Started 232 threads in the forums
  • Started this discussions
  • Answered 6 questions
asked
Super Admin

This thread is to clarify the mechanics and the table structure for the version 9 core difference than other existing versions.

Column Name Description
message_id ID unique
message_to Receipient User ID
message_from Sender User ID
message_user Owner user ID
message_subject Heading of message
message_message Content of message
message_smileys Use smileys in message, 'y' or 'n', default 'y' indicates yes
message_read Read status, 1 or 0 - 0 indicates new
message_datestamp timestamp
message_folder designated sections inbox - 1 inbox , 2 outbox, 3 archive

Typical situation and data row entry value examples - User 1 sends a message to User 201:

First, entry is the message sent to user 201 with the following values.

message_id = auto increment
message_to = 201
message_from = 1
message_user = 201
message_subject = "Test"
message_message = "Test"
message_smileys = "y"
message_read = 0
message_datestamp = time()
message_folder = 0

AND a copy of your sent message will be made available for user 1

message_id = auto increment
message_to = 201
message_from = 1
message_user = 201
message_subject = "Test"
message_message = "Test"
message_smileys = "y"
message_read = 0
message_datestamp = time()
message_folder = 1

- message_user is 201, indicating this message only can be viewed, deleted, and archived by user 201.
- message_folder must be 0 if current message_user is a recipient. 1 if current message_user is a sender.
- There was no swapping of the message_to and message_from values in any case. message_to always means that original message was sent to whom. Vice versa for message_from.
- Only difference here is that we keep a copy for ourselves when sending a message. This is because message_user is the owner of the message entry. Nobody will have access to them. If you delete your message, the other party will still be able to view the original message since he has a copy of it as well.

The SQL callback for all received PM will be:
$my_inbox = dbquery("SELECT message_id FROM ".DB_MESSAGES." WHERE message_to=:my_id AND message_folder=0");


The SQL callback for all sent PM will be:
$my_inbox = dbquery("SELECT message_id FROM ".DB_MESSAGES." WHERE message_to=:my_id AND message_folder=1");


Notice that in both occassion, the condition column is "message_to" and "message_folder"

The SQL callback for all received and sent PM will be:
$my_inbox_outbox = dbquery("SELECT message_id FROM ".DB_MESSAGES." WHERE message_user=:my_id");

or
$my_inbox_outbox = dbquery("SELECT message_id FROM ".DB_MESSAGES." WHERE (message_to=:my_id AND message_folder=0) OR (message_to=:my_id1 AND message_folder=1)");
0 replies

4 posts

C
Cupid
C
Cupid 10
  • Member, joined since
  • Contributed 151 posts on the community forums.
  • Started 49 threads in the forums
answered
Member

I know this thread is old, but I find it relevant. 

I updated from v7 to v9. 

I don't know what happened, but my site's private messages aren't working correctly. None show up. 

I noticed if I use the new table created from a new site and not using my old stuff there's a difference with the "message_user" numbers. On the old table the "message_user" id is always 0
on the new table it seems to match the "message_to"

Is this code above a script to update the table manually? 

How would I go about fixing this?

Edit: I took a look at the old table in the database before I updated and the 'message_user" category isn't present. So I guess it's a new thing for v9? 

Thanks for any help. 
Edited by Cupid on 11-11-2020 05:26,
0 replies
D
douwe_yntema
D
  • Senior Member, joined since
  • Contributed 667 posts on the community forums.
  • Started 57 threads in the forums
  • Answered 1 question
answered
Senior Member

The structure for private messages table is different in V7 and V9.
If you are using infusions sendings PM's, this one needs updated.

There was a post about it, but is seems removed.

in V9 the Table has an extra column witch needs to be filled to make the system work
2 replies
D
douwe_yntema
D
  • Senior Member, joined since
  • Contributed 667 posts on the community forums.
  • Started 57 threads in the forums
  • Answered 1 question
answered
Senior Member

If you have an old infusion, this function send_pm is not used. It is the common sense to inject sql directly.
In stead of throwing mud, please explain how the guy can adapt his code with this function.

The function is not described in the developper documentation on this site.

And please stop modifying forums posts if there is something in it you do not agree with. 

In Post#1 from Chan, I guess something is also not right, see remarks below:

Column Name Description
message_id ID unique
message_to Receipient User ID
message_from Sender User ID
message_user Owner user ID
message_subject Heading of message
message_message Content of message
message_smileys Use smileys in message, 'y' or 'n', default 'y' indicates yes
message_read Read status, 1 or 0 - 0 indicates new
message_datestamp timestamp
message_folder designated sections inbox - 1 inbox , 2 outbox, 3 archive

Typical situation and data row entry value examples - User 1 sends a message to User 201:

First, entry is the message sent to user 201 with the following values.

message_id = auto increment
message_to = 201
message_from = 1
message_user = 201
message_subject = "Test"
message_message = "Test"
message_smileys = "y"
message_read = 0
message_datestamp = time()
message_folder = 0  Should be 1 according to above

AND a copy of your sent message will be made available for user 1

message_id = auto increment
message_to = 201
message_from = 1
message_user = 201
message_subject = "Test"
message_message = "Test"
message_smileys = "y"
message_read = 0
message_datestamp = time()
message_folder = 1 Should be 2 according to above

- message_user is 201, indicating this message only can be viewed, deleted, and archived by user 201.
- message_folder must be 0 if current message_user is a recipient. 1 if current message_user is a sender. Message folder 0 is not defined
- There was no swapping of the message_to and message_from values in any case. message_to always means that original message was sent to whom. Vice versa for message_from.
- Only difference here is that we keep a copy for ourselves when sending a message. This is because message_user is the owner of the message entry. Nobody will have access to them. If you delete your message, the other party will still be able to view the original message since he has a copy of it as well.

The SQL callback for all received PM will be:
[color=#e74c3c]should be:[/color] $my_inbox = dbquery("SELECT message_id FROM ".DB_MESSAGES." WHERE message_to=:my_id AND[color=#e74c3c] message_folder=1[/color]");

CodeDOWNLOAD  
$my_inbox = dbquery("SELECT message_id FROM ".DB_MESSAGES." WHERE message_to=:my_id AND message_folder=0");
PHP
Copy



The SQL callback for all sent PM will be:
 Should be: 
$my_inbox = dbquery("SELECT message_id FROM ".DB_MESSAGES." WHERE[color=#e74c3c] message_from[/color]=:my_id AND [color=#e74c3c]message_folder=2[/color]");


CodeDOWNLOAD  
$my_inbox = dbquery("SELECT message_id FROM ".DB_MESSAGES." WHERE message_to=:my_id AND message_folder=1");

PHP
Copy

Notice that in both occassion, the condition column is "message_to" and "message_folder"

The SQL callback for all received and sent PM will be:
CodeDOWNLOAD  
$my_inbox_outbox = dbquery("SELECT message_id FROM ".DB_MESSAGES." WHERE message_user=:my_id");
NO, only received

PHP
Copy

or
CodeDOWNLOAD  
$my_inbox_outbox = dbquery("SELECT message_id FROM ".DB_MESSAGES." WHERE (message_to=:my_id AND message_folder=0) OR (message_to=:my_id1 AND message_folder=1)");


PHP

Copy

should be: 
$my_inbox_outbox = dbquery("SELECT message_id FROM ".DB_MESSAGES." WHERE (message_to=:my_id AND [color=#e74c3c]message_folder=1[/color]) OR ([color=#e74c3c]message_from=:my_id[/color] AND [color=#e74c3c]message_folder=2)[/color]");
Edited by Falk on 11-11-2020 13:19,
0 replies
F
Falk
F
Falk 131
Need help?, Having trouble?
• View our Documentation for Guides, Standards and Functions
• Name and Organize your Topics and Content correctly in the corresponding Forums for best support results
• Attaching Log Files and Screenshots when reporting issues will help
• Provide with an URL to live example if one exists
• Please read the How to Report an Error post
• Please read and comply with the Code of Conduct

(¯·._.·(¯°·._.·°º*[ Project Manager ]*º°·._.·°¯)·._.·¯)
  • Super Admin, joined since
  • Contributed 6,201 posts on the community forums.
  • Started 639 threads in the forums
  • Answered 11 questions
answered
Super Admin

You don´t get to decide what any Admin moderate on this site. 
I once more edit your post : There are no need to quote whole posts above own reply!

It is great that you want to help, but send_pm function is what we tell people to use. It has been present since PHPFusion 7.01
Yes it has been in our Wiki a very long time : https://www.php-fusion.co.uk/infusion...e_id_id=44
We avoid to encurage any teachings regarding modifications of faulty implementations., esp under our guides. 
You can think whatever you want of that. But we like to stick to the standards for ease of upgrade etc etc!.
 
Edited by Falk on 12-11-2020 04:51,
1 reply

Category Forum

Upgrading issues - 9

Labels

None yet

Statistics

  • Views 0 views
  • Posts 4 posts
  • Votes 0 votes
  • Topic users 4 members

4 participants

F
F
Falk 131
Need help?, Having trouble?
• View our Documentation for Guides, Standards and Functions
• Name and Organize your Topics and Content correctly in the corresponding Forums for best support results
• Attaching Log Files and Screenshots when reporting issues will help
• Provide with an URL to live example if one exists
• Please read the How to Report an Error post
• Please read and comply with the Code of Conduct

(¯·._.·(¯°·._.·°º*[ Project Manager ]*º°·._.·°¯)·._.·¯)
  • Super Admin, joined since
  • Contributed 6,201 posts on the community forums.
  • Started 639 threads in the forums
  • Answered 11 questions
C
C
Chan 0
Lead Developer of PHP-Fusion
  • Super Admin, joined since
  • Contributed 3,841 posts on the community forums.
  • Started 232 threads in the forums
  • Started this discussions
  • Answered 6 questions
C
C
Cupid 10
  • Member, joined since
  • Contributed 151 posts on the community forums.
  • Started 49 threads in the forums
D
D
  • Senior Member, joined since
  • Contributed 667 posts on the community forums.
  • Started 57 threads in the forums
  • Answered 1 question

Notifications

Track thread

You are not receiving notifications from this thread.

Related Questions

Not yet