[UPHPU] SQL field as prefix for all fields
CJackson at cirris.com
Mon Jan 28 16:21:50 MST 2008
I just remembered that on installation of Drupal, they have a feature that lets you add a prefix to your database tables. But, when you use the queries and fetches with drupal's built-in functions they return the tables as if they don't have a prefix. So, you could see what they are doing as well to get to an answer to your question.
From: Scott Hill [mailto:llihttocs at gmail.com]
Sent: Monday, January 28, 2008 4:15 PM
To: Craig Jackson
Cc: Wade Preston Shearer; UPHPU Discuss
Subject: Re: [UPHPU] SQL field as prefix for all fields
The AS option in an SQL command allows you to rename a field, like this:
select username as user, password as secretcode
Is it possible to rename all of the fields that you pull at once?
Here's what I want to do:
I have a table of fields that are all named with the same prefix. I
want to rename them as they are pulled from the DB with a different
prefix. Is that possible?
I have never heard of anything like this in SQL. You are probably stuck with renaming all of the columns in the SQL statement. If you are using Postgres or something besides MySQL you might do something like this in a stored procedure although I have never tried it. It would be neat if someone could figure out a nifty way to do this.
Food for thought:
An eagle may soar but a weasel will never get sucked into a jet engine.
A closed mouth gathers no foot.
Never squat with your spurs on.
More information about the UPHPU