Solved

Switching fromMySQL to ODBC

Posted on 2002-06-11
2
214 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

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

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
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…
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…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

729 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