Welcome Guest, Not a member yet? Register   Sign In
MySQL Field names
#1

[eluser]bhenry001[/eluser]
I just want to verify the following: The SQL tables I am using have field names with spaces and /'s in them. Is there a way to refer to this information using the active record?

Ex.

Would like to use
<h3>&lt;?=$row->title name?&gt;</h3>

instead of

<h3>&lt;?=$row->title_name?&gt;</h3>

The field names came from a master database and this is how they are used.

Please let me know.
Thank you,
Bruce
#2

[eluser]kgill[/eluser]
Find whoever created that DB and beat them until they promise never to do it again, spaces and /'s do not belong in table names. To answer the question, no you can't get active record to recognize a space in a variable or function name because PHP doesn't allow them to be there.
#3

[eluser]bhenry001[/eluser]
Thank you. It is just what I thought. But wanted to make sure. As for as who to beat, the data is coming from Remedy Helpdesk Manager SQL database and I am just getting the data I need. Thanks again!
#4

[eluser]m4rw3r[/eluser]
If you really need spaces in your property names, I think you can do this:
Code:
$obj->{'some property name'}
#5

[eluser]kgill[/eluser]
Heh I intentionally avoided mentioning that because it's based on exploiting the curly brace eval and isn't guaranteed to work, the amusing thing is spaces aren't the only thing you can get away with, ${1 + 2} = 'foo'; will give you a variable named $3. Smile
#6

[eluser]majidmx[/eluser]
In your case I think the only way should be going for writing the queries manually instead of using the active records.




Theme © iAndrew 2016 - Forum software by © MyBB