• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to return database errors ?

#1
[eluser]bhenbe[/eluser]
Hello all,

this is my first post here and sorry for my english (i'm belgian).

Here's my problem : i want to show the returned error from a database transaction. I use html parser.

My code :

Model :
Code:
function service_add_user($service_id, $user_id) {

$this->db->trans_start();
        
$this->db->query('INSERT INTO tbluserbyservice(userbyservice_serviceid, userbyservice_userid, userbyservice_role)
          VALUES (?, ?, ?)',
         array($service_id, $user_id, 1));
        
$this->db->trans_complete();

if ($this->db->trans_status() === FALSE)
    return false;
            
return true;
        
}

Controller :
Code:
function service_add_user($service_id) {
    
$this->load->library('form_validation');

if ($this->form_validation->run('service_user_add') == FALSE)
    return array('message_type' => 'error-msg',
                 'message_title' => 'Ajout d\'utilisateur à un service',
                 'message_content' => validation_errors());
        
if ($this->service_model->service_add_user($service_id, $_POST['user_id']) == FALSE)
    return array('message_type' => 'error-msg',
         'message_title' => 'Ajout d\'utilisateur à un service',
         'message_content' => [--Dunno what i must use here--]);

return array('message_type' => 'valid-msg',
         'message_title' => 'Ajout d\'utilisateur à un service',
         'message_content' => 'L\'utilisateur a été ajouté.');
    
}

View :
Code:
{messages}
<div class="{message_type}"><p>{message_title}</p>{message_content}</div>
{/messages}

Thank you for your help !


Messages In This Thread
How to return database errors ? - by El Forum - 10-07-2009, 06:54 AM
How to return database errors ? - by El Forum - 10-07-2009, 07:20 AM
How to return database errors ? - by El Forum - 10-07-2009, 07:37 AM
How to return database errors ? - by El Forum - 10-07-2009, 07:55 AM
How to return database errors ? - by El Forum - 10-07-2009, 08:07 AM
How to return database errors ? - by El Forum - 10-07-2009, 08:10 AM
How to return database errors ? - by El Forum - 10-07-2009, 08:26 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.