"You must submit a valid result object" returned even though I'm passing an object. |
[eluser]Josh Kendall[/eluser]
Hi, I hope someone can offer some advice. I'm trying to use the DB Utility to export a result as a CSV file. Problem is, I need to update part of the result before export. After about an hour of converting the result_array() to an object (since I couldn't update the object) I'm now being told "You must submit a valid result object", even though I'm submitting an object that looks exactly like the object $query->result() produces. Here is the results of printing a "true" result object: Code: Array and here is my object after making the changes and converting it from a result array to an object: Code: Array And here is the code I'm using in my controller: Code: // ------ EXPORT FUNCTIONS and this is the function that converts the array to an object: Code: function arr2obj($arg_array) { Any help would be appreciated.
[eluser]wiredesignz[/eluser]
the csv_from_result utility requires functions named field_names(), list_fields() and result_array() within the true result object. Why not just modify the data in the original result object and pass it on?
[eluser]rfrancis[/eluser]
[quote author="wiredesignz" date="1202192090"]the csv_from_result utility requires functions named field_names(), list_fields() and result_array() within the true result object. Why not just modify the data in the original result object and pass it on?[/quote] I'm actually struggling with this very same problem. How do modify the original result object itself so I can pass it on? Thanks in advance for any help.
[eluser]Nathan Pitman (Nine Four)[/eluser]
Anyone ever find a solution to this, I've modified the original object but when I pass it to csv_from_result it resets to the original result object... :?
[eluser]WanWizard[/eluser]
csv_from_output() internally calls result_array() method of the query result. If the result has been fetched before, that result is returned (= the result_array property of the object), if not, it fetches the rows from the database driver (i.e. the original resultset). So before you call csv_from_output(), fetch the result array in your model, and modify it. If you fetch it into a local variable, make sure to write that back to $query_object->result_array, so your modified values are exported to csv.
[eluser]Nathan Pitman (Nine Four)[/eluser]
Thanks, got it working using the same method you describe but I needed to modify the column headers also so ended up rolling my own csv_from_result function which allowed for an additional parameter including column headings. |
Welcome Guest, Not a member yet? Register Sign In |