I am using PHP and MSSQL.
My problem is regarding column name in mssql.
Is there a function or a way to be able to display the name of a column whatever the case of this DB field.
I explain.
My Colum in MSSQL is called CompanyID (note Capital C and ID).
If I try to display the content of this column like $row["companyid"] I will not return any result.
But If respect the case of this fields as $row["CompanyID"] the right record will be display.
My database contain lots of fields that are Upper/Lower case, I am trying to find a way to convert everything to lower case without having to do it manually on the db.
Thanks
S
DB FIELD NAME
Moderator: General Moderators
Patience, snicolas, and reading the manual helps as well: mssql functions - personally, I suspect mssql_field_name will do the job.
Not sure if there is specific MSSQL syntax for this, but in MySQL, you'd have to change each column name manually, to be all lower case. The syntax for a query like that would be:
Of course, the column type can be whatever you want.
Code: Select all
ALTER TABLE my_table CHANGE CompanyID companyid int(2)Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
and if you want to do it the painfull way:
Code: Select all
// asuming a row - resultset is in $row
$lckeys = array();
foreach($row as $column => $value)
{
$lckeys[strtolower($column)] = $value;
}