Solved

Switching fromMySQL to ODBC

Posted on 2002-06-11
2
210 Views
Last Modified: 2008-02-01
Hi,

I wrote an Application using WAMP. For some reason I have to use ODBC now.

I defined a class with the following method:

function select ($sql="")
{
     $count = 0;
     $data = array();
     while ( $row = mysql_fetch_array($results))
     {
          $data[$count] = $row;
          $count++;
     }
     return $data;
}

Since the lack of a function like "odbc_fetch_array()" I need a different way to return an associative array with "return $data", because the above method is the basis for a lot of other application-specific methods.

Any suggestions?

THX,
j
0
Comment
Question by:jufabw00
2 Comments
 
LVL 7

Accepted Solution

by:
axis_img earned 100 total points
ID: 7069301
What version of PHP are you using? There is a function called odbc_fetch_array(), although I know it has had problems in early versions of PHP4.

I am not all that familiar with the odbc modules, but just from glancing at the docs, it seems that other users tend to use odbc_fetch_into($res, &$result_array) to throw it into the array. ie: while(odbc_fetch_into($res, &$array))

The corresponding pages can be found at:
http://www.php.net/manual/en/function.odbc-fetch-array.php
[the 2nd example seems to be what you need]

http://www.php.net/manual/en/function.odbc-fetch-into.php

The odbc functions seem to be poorly written in my opinion, as there are many different variations on how to write it based on the exact version of PHP you are using.

Anyway... please let me know if you have any more questions.
Barry
0
 

Author Comment

by:jufabw00
ID: 7069783
... works with 4.2.1 (doesn't with 4.0.6. - yet ;-)))

thx,
j
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

895 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now