Unpredictable CCK field name in returned View data
- by AK
I'm using views_get_view_result to directly access the data in a view. I've stumbled upon this odd behavior where cck fields are prefixed with the first field name as a query optimization. Explained here.
What's bizarre though is that fields are named differently depending on whether I retrieve that data as Anonymous or as Admin. I'm pretty sure all my permissions are set up, and the view itself has no restrictions. What is going on here?
This is a big problem since I can't know how to retrieve a field. Here's a dump of the two view results. Notice that node_data_field_game_date_field_game_home_score_value != node_data_field_game_official_field_game_home_score_value.
// View as Admin
stdClass Object
(
[nid] => 3191
[node_data_field_game_date_field_game_date_value] => 2010-03-27T00:00:00
[node_type] => game
[node_vid] => 5039
[node_data_field_game_date_field_game_official_value] => 0
[node_node_data_field_game_home_team_title] => TeamA
[node_node_data_field_game_home_team_nid] => 3396
[node_data_field_game_date_field_game_home_score_value] => 68
[node_node_data_field_game_visitor_team_title] => TeamB
[node_node_data_field_game_visitor_team_nid] => 3442
[node_data_field_game_date_field_game_visitor_score_value] => 118
)
// View as Anonymous
stdClass Object
(
[nid] => 3191
[node_data_field_game_date_field_game_date_value] => 2010-03-27T00:00:00
[node_type] => game
[node_vid] => 5039
[node_data_field_game_official_field_game_official_value] => 0
[node_node_data_field_game_home_team_title] => TeamA
[node_node_data_field_game_home_team_nid] => 3396
[node_data_field_game_official_field_game_home_score_value] => 68
[node_node_data_field_game_visitor_team_title] => TeamB
[node_node_data_field_game_visitor_team_nid] => 3442
[node_data_field_game_official_field_game_visitor_score_value] => 118
)