Jump to content

Column Alias


AV1611

Recommended Posts

Trying to do a join on a query via odbc with PHP...

Problem: Both tables have a column name of the same name.
The Database is FoxPro

It would seem that ODBC for foxpro doesn't allow the column_name as alias_name
SO...

And to boot, PHP has a bug? that makes the array not associative, so I can't just use $row[0]...
it comes up as Undefined Index: 0...

If I echo it out as $row['column name'], it works like normal, but each time I get to the second tables
identical name, it echo the value from the first table's column...

Any suggestion for a work around????????????????????????????????????

Is there a way to dump the array en mass into another array then pull it out from there???

HelP!
Link to comment
https://forums.phpfreaks.com/topic/11114-column-alias/
Share on other sites

// Edit

This doesn't fix it only partly - see last post for solution...

// End Edit

Well, it's ugly, but I found a way around it...

Someone might want to make a note of it (Barand?)
Please let me know if there is a prettier solution...
I know I'll use this again...

[code]
WHILE($row=ODBC_fetch_array($result)){

    foreach ($row as $temp[]);
    echo $temp[0]."   ".$temp[1]."   ".$temp[3]."   ".$temp[4]."   ".$temp[5]."   ".$temp[6]."   ".$temp[7]."   ".$temp[8]."   ".$temp[9]."   ".$temp[10]."   ".$temp[11]."   ".$temp[12]."\n";


[/code]

-Ciao



[!--quoteo(post=379723:date=Jun 3 2006, 04:15 PM:name=AV1611)--][div class=\'quotetop\']QUOTE(AV1611 @ Jun 3 2006, 04:15 PM) [snapback]379723[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Trying to do a join on a query via odbc with PHP...

Problem: Both tables have a column name of the same name.
The Database is FoxPro

It would seem that ODBC for foxpro doesn't allow the column_name as alias_name
SO...

And to boot, PHP has a bug? that makes the array not associative, so I can't just use $row[0]...
it comes up as Undefined Index: 0...

If I echo it out as $row['column name'], it works like normal, but each time I get to the second tables
identical name, it echo the value from the first table's column...

Any suggestion for a work around????????????????????????????????????

Is there a way to dump the array en mass into another array then pull it out from there???

HelP!
[/quote]
Link to comment
https://forums.phpfreaks.com/topic/11114-column-alias/#findComment-41557
Share on other sites

FORGET IT!

JUST FORGET IT ALL!!!

I feel like an idiot...

Here is the problem... When I aliased, I did it like this:

serialnum as SN

but in the array the key was sn

SO...

when I went

echo $row['SN']

it didn't find it, because is should have been

$row['sn']

I don't think MySQL does it, just happens to do it in Foxpro via ODBC...

OUCH!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


Thanks, Barand, for leading me to the answer...
Link to comment
https://forums.phpfreaks.com/topic/11114-column-alias/#findComment-42034
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.