Welcome Guest, Not a member yet? Register   Sign In
Modifying query result before export CSV from result
#1

[eluser]dsloan[/eluser]
I have a query which produces a result set in which I want to modify some field values before exporting to CSV. Specically, one column value has an integer value which I want to replace with the appropriate "status" value, e.g. 1=ACTIVE, 2=CEASED, 3=SUSPENDED, etc.

I found this thread which was exactly what I was looking for, but no answer! http://ellislab.com/forums/viewthread/77147/

Anyone any ideas? I have tried looping through the array and modifying, but no joy.

foreach($query->result_array() as &$result)
#2

[eluser]CroNiX[/eluser]
You can do that directly in the query. Either use a join (assuming you have those status' defined in a table) or use a CASE statement in the query.
#3

[eluser]dsloan[/eluser]
Thanks. This is just one example of what I need, but there's several fields which need processed, concatenated and logic applied. That might all be possible to do via SQL but is it possible to do it by modifying the query directly?




Theme © iAndrew 2016 - Forum software by © MyBB