Model Context Protocol (MCP) finally gives AI models a way to access the business data needed to make them really useful at work. CData MCP Servers have the depth and performance to make sure AI has access to all of the answers.
Try them now for free →Natively Connect to Cvent Data in PHP
The CData ODBC driver for Cvent enables you to create PHP applications with connectivity to Cvent data. Leverage the native support for ODBC in PHP.
Drop the CData ODBC Driver for Cvent into your LAMP or WAMP stack to build Cvent-connected Web applications. This article shows how to use PHP's ODBC built-in functions to connect to Cvent data, execute queries, and output the results.
Configure a DSN
If you have not already, first specify connection properties in an ODBC DSN (data source name). This is the last step of the driver installation. You can use the Microsoft ODBC Data Source Administrator to create and configure ODBC DSNs.
Before you can authenticate to Cvent, you must create a workspace and an OAuth application.
Creating a Workspace
To create a workspace:
- Sign into Cvent and navigate to App Switcher (the blue button in the upper right corner of the page) >> Admin.
- In the Admin menu, navigate to Integrations >> REST API.
- A new tab launches for Developer Management. Click on Manage API Access in the new tab.
- Create a Workspace and name it. Select the scopes you would like your developers to have access to. Scopes control what data domains the developer can access.
- Choose All to allow developers to choose any scope, and any future scopes added to the REST API.
- Choose Custom to limit the scopes developers can choose for their OAuth apps to selected scopes. To access all tables exposed by the driver, you need to set the following scopes:
event/attendees:read event/attendees:write event/contacts:read event/contacts:write event/custom-fields:read event/custom-fields:write event/events:read event/events:write event/sessions:delete event/sessions:read event/sessions:write event/speakers:delete event/speakers:read event/speakers:write budget/budget-items:read budget/budget-items:write exhibitor/exhibitors:read exhibitor/exhibitors:write survey/surveys:read survey/surveys:write
Creating an OAuth Application
After you have set up a Workspace and invited them, developers can sign up and create a custom OAuth app. See the Creating a Custom OAuth Application section in the Help documentation for more information.
Connecting to Cvent
After creating an OAuth application, set the following connection properties to connect to Cvent:
- InitiateOAuth: GETANDREFRESH. Used to automatically get and refresh the OAuthAccessToken.
- OAuthClientId: The Client ID associated with the OAuth application. You can find this on the Applications page in the Cvent Developer Portal.
- OAuthClientSecret: The Client secret associated with the OAuth application. You can find this on the Applications page in the Cvent Developer Portal.
Establish a Connection
Open the connection to Cvent by calling the odbc_connect or odbc_pconnect methods. To close connections, use odbc_close or odbc_close_all.
$conn = odbc_connect("CData ODBC Cvent Source","user","password");
Connections opened with odbc_connect are closed when the script ends. Connections opened with the odbc_pconnect method are still open after the script ends. This enables other scripts to share that connection when they connect with the same credentials. By sharing connections among your scripts, you can save system resources, and queries execute faster.
$conn = odbc_pconnect("CData ODBC Cvent Source","user","password");
...
odbc_close($conn); //persistent connection must be closed explicitly
Create Prepared Statements
Create prepared statements and parameterized queries with the odbc_prepare function.
$query = odbc_prepare($conn, "SELECT * FROM Events WHERE Virtual = ?");
Execute Queries
Execute prepared statements with odbc_execute.
$conn = odbc_connect("CData ODBC Cvent Source","user","password");
$query = odbc_prepare($conn, "SELECT * FROM Events WHERE Virtual = ?");
$success = odbc_execute($query, array('true'));
Execute nonparameterized queries with odbc_exec.
$conn = odbc_connect("CData ODBC Cvent Source","user","password");
$query = odbc_exec($conn, "SELECT Id, Title FROM Events WHERE Virtual = 'true'");
Process Results
Access a row in the result set as an array with the odbc_fetch_array function.
$conn = odbc_connect("CData ODBC Cvent data Source","user","password");
$query = odbc_exec($conn, "SELECT Id, Title FROM Events WHERE Virtual = 'true'");
while($row = odbc_fetch_array($query)){
echo $row["Id"] . "\n";
}
Display the result set in an HTML table with the odbc_result_all function.
$conn = odbc_connect("CData ODBC Cvent data Source","user","password");
$query = odbc_prepare($conn, "SELECT * FROM Events WHERE Virtual = ?");
$success = odbc_execute($query, array('true'));
if($success)
odbc_result_all($query);
More Example Queries
You will find complete information on the driver's supported SQL in the help documentation. The code examples above are Cvent-specific adaptations of the PHP community documentation for all ODBC functions.