For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > November 2005 > space in object attribute name









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author space in object attribute name
kevin bailey

2005-11-24, 7:56 am

hi,

using pg_fetch_object() to get a row from a recordset.

the recordset was extracted from a view on a database.

the view has fields in it where the the field name contains spaces 'Base
Total' etc.

now when i refer to the field using

$total_base = "Total Base";
$base_total = $row->$total_base;

it works ok.

but to be neater is there anyway that:

$base_total = $row->'Total Base';

can be made to work.

thanks,

kev
Nick

2005-11-24, 6:56 pm

kevin bailey wrote:
> hi,
>
> using pg_fetch_object() to get a row from a recordset.
>
> the recordset was extracted from a view on a database.
>
> the view has fields in it where the the field name contains spaces 'Base
> Total' etc.
>
> now when i refer to the field using
>
> $total_base = "Total Base";
> $base_total = $row->$total_base;
>
> it works ok.
>
> but to be neater is there anyway that:
>
> $base_total = $row->'Total Base';


Have you tried

$row->{'Total Base'}
kevin bailey

2005-11-24, 6:56 pm

Nick wrote:

> kevin bailey wrote:
>
> Have you tried
>
> $row->{'Total Base'}


have now and it works fine - marvellous!

i presume the curly braces are a way of php defining a sort of place holder
which is similar to how variables are defined at times - like {$varname}

thanks for the help,

kev
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com