我正在构建一个输出xml文件的脚本但我无法从单个查询生成所有数据,因为描述可能来自各种来源。到目前为止,我有:
// Select the products
$query = $this->db->select('id,sku,name,image')
->from('products')
->get();
// !!! Here's where I need help - I need to loop through the results and run
// another query based on the ID which will pull a description from
// a number of possible sources and then add the resulting description into
// the main $query object so it can still use xml_from_result()
// Load the Database Utilities
$this->load->dbutil();
// Configure the xml structure
$config = array (
'root' => 'root',
'element' => 'element',
'newline' => "\n",
'tab' => "\t"
);
// Output the xml doc
header('Content-type: text/xml');
echo $this->dbutil->xml_from_result($query, $config);
我可以通过首先执行$ query-> result()来获取我需要的数据但是我不能再使用$ query与xml_from_result()。任何帮助将不胜感激。