Welcome Guest, Not a member yet? Register   Sign In
xml_from_result error
#1

[eluser]escape[/eluser]
With the following:

Code:
$this->load->dbutil();
$query = $this->db->query("SELECT * FROM table_name");
echo $this->dbutil->xml_from_result($query);

I'm getting the following error:
Quote:You must submit a valid result object

If I change the result to csv like:
Code:
echo $this->dbutil->csv_from_result($query);
all works as expected and csv output is generated.

I would assume xml_from_result would generate xml but instead I'm getting an error.

Suggestions to this error message?

Thanks
#2

[eluser]jtkendall[/eluser]
I tried your code and got the same issue after a quick search on the forums I found this post. Which recommends changing line 220 in /system/database/DB_utility.php to
Code:
if ( ! is_object($query) OR ! method_exists($query, 'list_fields'))

I tried that and it worked seems there was a change between 1.6.3 which caused it to break.
#3

[eluser]escape[/eluser]
You will note from the referenced post I was the last to reply regarding
Code:
if ( ! is_object($query) OR ! method_exists($query, 'list_fields'))
as fix to repair csv_from_result (which did work).

However it does not repair the xml_from_result error I'm reporting.
#4

[eluser]jtkendall[/eluser]
Yeah, I realized you were the last to reply on that post. However, I tried the basic xml_from_result() example you posted and it failed with the same error. I made the same change the reference post mentions in the xml_from_result() method in /system/database/DB_utility.php and it DID fix the issue.

The referenced post solution mentioned line 178 which is the csv_from_result() method, line 220 (that I mentioned) is for the xml_from_result() method.
#5

[eluser]escape[/eluser]
Unfortunately I cannot reproduce your results. I installed a fresh version of CI and tested the following code:

Code:
$this->load->database();
$query = $this->db->get(my_data_table, 5);
$this->load->dbutil();
echo $this->dbutil->csv($query);
echo '<BR>----------------------------<BR>';
echo $this->dbutil->xml($query);

on two shared hosting accounts (one Linux and one Windows OS) and another on a desktop server using XAMPP. All three installations were modified to include the recommended patch to fix csv

Code:
if ( ! is_object($query) OR ! method_exists($query, 'result_object'))

Each installation was able to create csv but not xml.

Quote:note: both 'result_object' and 'list_fields' repair csv but not xml
#6

[eluser]docevi1[/eluser]
I had this problem too with CodeIgniter 1.7.1.

I changed line 220 in /system/database/db_utility.php from

if ( ! is_object($query) OR ! method_exists($query, 'field_names'))

to

if ( ! is_object($query) OR ! method_exists($query, 'row'))

This solved my problem.




Theme © iAndrew 2016 - Forum software by © MyBB