# SAM &Functions;

&reftitle.classes;

### `SAMConnection`

Object representing a connection to a Messaging Server

&reftitle.constructor;

- new SAMConnection - construct a new connection object to allow connection to a messaging infrastructure.

&reftitle.methods;

- commit - a method that commits (successfully completes) an in-flight unit of work.

- connect - a method that connects a PHP script to a messaging server.

- disconnect - a method that disconnects a PHP script from a messaging server.

- isConnected - a method that checks whether a PHP script is connected to a messaging server.

- peek - a method that receives a message from a queue without removing it from the queue.

- peekAll - a method that receives one or messages from a queue without removing them from the queue.

- receive - a method that receives a message from a queue or subscription.

- remove - a method that removes a message from a queue.

- rollback - a method that cancels (rolls back) an in-flight unit of work.

- send - a method that sends a message to a queue or posts to a topic

- setDebug - a method that switches additional debugging output on or off

- subscribe - a method that creates a subscription to one or more topics

- unsubscribe - a method that destroys a subscription to one or more topics

&reftitle.properties;

- errno - the numeric error code for the last encountered error on this connection. This property is set to 0 if the last operation was successful.

- error - the text description for the last encountered error on this connection

### `SAMMessage`

Object representing a message to be sent or received

&reftitle.constructor;

- new SAMMessage - construct a new message.

&reftitle.properties;

- body - the body of the message.

- header - the header properties of the message.

&reference.sam.entities.SAMConnection; &reference.sam.entities.SAMMessage;