posts - 88 , comments - 3 , trackbacks - 0

Access QuickBooks from PHP

This article will explain how to connect to any of the CData SQLBrokers from PHP. While the example will use the SQLBroker for QuickBooks.

  • Step 1: Download and install the SQLBroker for QuickBooks from CData.
  • Step 2: Next configure the SQLBroker for QuickBooks to connect to your QuickBooks company file or online account. If you browse to the Help file in the Windows start menu, there is a link to the Getting Started Guidewhich walks you through setting up the SQLBroker for QuickBooks. Once you have installed the SQLBroker for QuickBooks and configured the connection to QuickBooks, you are ready to begin querying data from PHP.
  • Step 3: Now open the connection to the SQLBroker from PHP. Invoking the mysql_connect method will connect with the CData SQLBroker server in PHP. As parameters to the mysql_connect method, you will need to supply the connection info to your CData SQLBroker instance. This will contain the following:
    • The remote host location and port where the server is running. In this case "localhost" is used for the remote host setting since it is running on the local machine and the port is 3307.
    • The username in this case is root.
    • The password for the specified user.
    <?php
    $con mysql_connect("localhost:3307","root","my_password");
    ?>
  • Step 4: We are now ready to query our QuickBooks data. In this example, we will query the data from the Customers table in our QuickBooks database. The following steps will walk you through the example:
    • First, we must tell the CData SQLBroker which database we want to connect to. In our example, we have configured the database name to be "QuickBooksSqlBroker".
    • Now we will use the mysql_query method to query the table. The results will be stored in the $result object.
    • Finally, we can walk through each row and column, printing the values to display in our PHP page.
    <?php
    mysql_select_db("QuickBooksSqlBroker", $con);
     
    $result mysql_query("SELECT * FROM Customers");
     
    while($row mysql_fetch_assoc($result)) {
    foreach ($row as $k=>$v) {
    echo "$k : $v";
    echo "<br />";
    }
    }
    ?>
  • Step 5: Finally close the connection to CData SQLBroker when we are finished querying our data source.
    <?php
    mysql_close($con);
    ?>

Print | posted on Friday, May 31, 2013 8:11 AM | Filed Under [ quickbooks php cdata ]

Feedback

No comments posted yet.
Post A Comment
Title:
Name:
Email:
Comment:
Verification:
 

Powered by: