Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

PHP connecting to Pervasive SQL

Posted on 2003-03-10
3
Medium Priority
?
1,396 Views
Last Modified: 2013-12-12
I am currently using PHP to connect to MySQL but have a need to use Pervasive Sql.

What is the best way to connect to Pervasive Sql? I can't find examples anywhere.
And yes I am new at this  :)

Thanx.
0
Comment
Question by:dc_sava
3 Comments
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 8127126
http://www.pervasive.com/library/index.asp?_portal=PHP seems a good place to start.

It looks like there is no native support for Pervasive, so using ODBC is required.
0
 
LVL 5

Accepted Solution

by:
mokelly1 earned 750 total points
ID: 8159721
I have set up an ODBC system dsn that points to my pervasive database. Then I use the following top three lines of code to open the database and the rest to access tables and fields:

// connect to an ODBC-dba with a user and password
$connect = odbc_connect("ODBCDatabaseName", "username", "password");

// query the users table for Finished Goods
$query = "SELECT mtro_code, mtro_desc
            FROM routing
        ORDER BY mtro_code";
$result = odbc_exec($connect, $query);
// fetch the data from the database
$i=0;
$LastTopLevel = "1";
$TopLevel[$i] = " ";
while(odbc_fetch_row($result))
{
  $TopLevel[$i] = odbc_result($result, 1);
  if ($LastTopLevel <> $TopLevel[$i])
  {  
     $Description[$i] = odbc_result($result, 2);
     $LastTopLevel = $TopLevel[$i];
     $i = $i + 1;
  }                                        
}

odbc_result($result,1) is the field mtro_code
odbc_result($result,2) is the field mtro_desc in the Select statement above
0
 

Author Comment

by:dc_sava
ID: 8185323
Thanks for the comments.
Unfortunately I found the pervasive examples to not even download from their site.
On the up side I have managed to figure out how to connect using ODBC from some PHP resources similar to the above suggestion.

Thanks again.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question