[eluser]bugboy[/eluser]
Hello all.
This is my first post on this forum.
I have recently decided to move over to this frame work as it promotes faster coding and a better way of logic.
Now my question is this. I'm using sendAndLoad on a flash site i'm making at the minute and wanted to use codeigniter for the backend part. (not being built in flash but flash will pull the data out when needed)
When i use sendAndLoad in flash i send the data via $_POST. The function in the controller at the min looks like this.
Code:
function forflash(){
if(isset($_POST['id'])){
$id = $_POST['id'];
}else{
$id = '0';
}
$xml['xml'] = $this->country->getCountriesReturn($id);
$data['content'] = $this->load->view('country_xml',$xml,true);
$this->load->view('country_xml', $data);
}
Now the code above works like a dream but i was wondering if this was the best approach. This isn't validated but hopefully you'll understand what i mean.
I'm trying to use the MVC way.
other parts of my code looks like this
model:
Code:
function getCountriesReturn($id)
{
$this->db->select('id, name');
$this->db->where('id', $id);
$this->db->from($this->_table);
$query = $this->db->get();
if ($query->num_rows() > 0)
{
return $query->result();
}
return null;
}
view:
Code:
<?php
$output = '<?xml version="1.0" encoding="ISO-8859-1"?>'."\n";
$output .= '<cms_item>'."\n";
if ($xml != null){
foreach ($xml as $array){
$output .= ' <item>'."\n";
while(list($key, $value) = each($array)){
if($value !='0'){
$output .= ' <'.$key.'>'.$value.'</'.$key.'>'."\n";
}
}
$output .= ' </item>'."\n";
}
$output .= '</cms_item>'."\n";
}else{
$output .= ' <cms_item><item><report>No data to show</report></item></cms_item>'."\n";
}
echo $output;
?>
Now my gut instinct on this is if it works why worry but you know perfection an all that.
Any help great thanks in advance.