Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Switching fromMySQL to ODBC

Posted on 2002-06-11
2
Medium Priority
?
217 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 400 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
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…
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

916 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