[eluser]esset[/eluser]
Hi
I have an XML-document I read in from my controller to my model which makes the insert into the DB. The insert call returnes TRUE but it doesn't return it back to the controller, then it's empty. Any ideas why? Thank you so much.
Controller
Code:
function _add_shows($shows)
{
// Shows
foreach($shows->show as $node)
{
$result = $this->Show_model->add($node);
if($result == TRUE)
{
echo '<b style="color: green;">Show added:</b> '. $node->showname . '<br/>';
} else {
echo '<b style="color: red;">Show not added:</b> '. $node->showname . '<br/>';
}
}
}
Model
Code:
function add($show) {
if( !$this->check_if_show_exists($show->showid) )
{
// Data
$data = array(
'id' => $show->showid,
'name' => xml_convert($show->showname),
'link' => xml_convert($show->showlink)
);
// Insert
$result = $this->db->insert('shows', $data);
return TRUE;
} else {
return FALSE;
}
}
// --------------------------------------------------------------------
/*
* Check if show ID exists
*/
function check_if_show_exists($id = '')
{
if ($id == '')
{
// no id, return false
return FALSE;
}
$this->db->select('id');
$this->db->where('id', $id);
$result = $this->db->get('shows');
if ($result->num_rows() != 1)
{
// no match, return false
return FALSE;
}
else
{
//match, return true
return TRUE;
}
}