(Picture source: http://visual.ly/formal-dining-setting)
As you can see from the picture above, your mobile device is not part of the table setting. So keep yours in your bag, briefcase or your jacket. Since almost everyone has a smartphone now, noone cares that you have got one as well, so keep it out of sight.
Don't text under the table. If it's urgent, excuse yourself, exit the room, and finish whatever it is that you need to communicate, then return and keep your phone as mentioned above: in a bag, briefcase or jacket.
Consider the fact, that it is a social gathering you are attending, not a social media one. Do not interrupt your table mates in order to take pictures of what is being served, so that you can post on Instagram, Facebook, Twitter or similar. Also, when taking a picture, ask for permission (if you really feel the urge) to post later on social media platforms.
You might also consider turning your phone to "silent" or "vibration"-mode. However, if you are expecting a phone call, be prepared to stand up and exit the room when required. Do the same as with the texting (2nd point of this list).
Do not text with someone at the same table. Let's admit it, it's weird (because they're sitting so close to you) and it is also rude, in case you have secrets from the others. Talk to each-other or meet at another time separately, without offending others.
To sum it up, if you are at a table with someone, be with them. Interact, have fun, enjoy your time with them, laugh, live, be social, not social media.