Solved

Switching fromMySQL to ODBC

Posted on 2002-06-11
2
208 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Wordpress Query 1 35
php documentation 4 21
XML Data Missing in PHP SimpleXML 8 24
SQL inner join confusion 15 22
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.  …
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 count occurrences of each item in an array.
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…

762 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

20 Experts available now in Live!

Get 1:1 Help Now