• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
insert not working.

#1
[eluser]reghan[/eluser]
Hello the following is my code I am trying to insert a new system but it doesnt seem to want to insert. I am fairly new to this program, so it might be something simple but at this time I am just stuck. Any help would be great

Here is my Model:
Code:
<?php
class Department_model extends CI_Model {

public function __construct()
{
  $this->load->database();
}

  function systems_table_list()
{
  $this->db->order_by('SystemID', 'asc');
  return $this->db->get('systems');
}


// add new system
function saveSystem($system)
{

  $this->db->insert('systems', $system);
  return $this->db->insert_id();

  }




}

here is the controller:

Code:
function addSystem()
{
  
  
  // set common properties
  $data['title'] = 'Add new system';
  $data['action'] = site_url('bia/addSystem');
  $data['link_back'] = anchor('bia/systems/','Back to list of persons',array('class'=>'back'));
  
  //set validation rules
  //have validation set here but it is too long to include its the same as the function below
  
  
   if ($this->form_validation->run() == FALSE)
   {
  
              $data['message'] = '';
   }
  
  else
  {
   // save data
   $system = array('SystemName' => $this->input->post('sysname'),
     'Servers' => $this->input->post('server'),
     'HA' => $this->input->post('ha'),
     'DR' => $this->input->post('dr'),
     'Desc' => $this->input->post('descrip'),
     'Class' => $this->input->post('class'),
     'LowestRTO' => $this->input->post('lowRTO'),
     'LowestRTOProcess' => $this->input->post('lowProcess'),
     'LowestRTODept' => $this->input->post('lowDept'));
  
  
     $this->department_model->saveSystem($system);
    // set user message
   $data['message'] = '<div class="success">add new person success</div>';
   }
  
  
  
  
   // load view
  $this->load->view('systemEdit', $data);

}

function add_sys(){


         // set common properties

         $data['title'] = 'Add New System';



  //set validation rules
  $this->form_validation->set_rules('sysname', 'System Name', 'required');
  $this->form_validation->set_rules('server','Server Name', 'required');
  $this->form_validation->set_rules('ha', 'HA','required');
  $this->form_validation->set_rules('dr', 'DR','required');
  $this->form_validation->set_rules('descrip','Description', 'required');
  $this->form_validation->set_rules('class','Class', 'required');
  $this->form_validation->set_rules('lowRTO','Lowest RTO', 'required|numeric');
  $this->form_validation->set_rules('lowProcess','Lowest RTO Process', 'required');
  $this->form_validation->set_rules('lowDept','Lowest RTO Department', 'required');

// set common properties
   $data['title'] = 'Add a new system';
   $data['message'] = '';
   $data['action'] = site_url('bia/addSystem');
   $data['link_back'] = anchor('bia/systems/','Back to list of systems',array('class'=>'back'));

   //load the add system view.
   $this->load->view('systemEdit', $data);

     }
view:
Code:
<div class="content">
  <h1>&lt;?php echo $title; ?&gt;</h1>
  <p>&lt;?php echo $message; ?&gt;</p>

&lt;form method="post" action="&lt;?php echo $action; ?&gt;"&gt;

   <div class="data">
<table>
   <tr>

                 <td valign="top"><strong>System Name: </strong><span>*</span></td>

                 <td>
                  &lt;input type="text" name="sysname" size="60" class="text" value="&lt;?php echo set_value('sysname'); ?&gt;"/&gt;
     &lt;?php echo form_error('sysname'); ?&gt;
    </td>

          </tr>
  <tr>

                 <td valign="top"><strong>Server: </strong><span>*</span></td>
    <td>&lt;input type="text"  name="server" size="60" value="&lt;?php echo set_value('server'); ?&gt;" /&gt;&lt;br /></td>
   <td>&lt;?php echo form_error('server'); ?&gt;</td>
             </tr>
   <tr>

                 <td valign="top"><strong>HA: </strong><span>*</span></td>
   <td>

   <select name="ha">
       <option value="Yes">Yes</option>
       <option value="Partial">Partial</option>
       <option value="None">None</option>
       <option value="Na">NA</option>
       </select><br />
      </td>
                
                
            </tr>
            <tr>
              
              <td valign="top"><strong>DR: </strong><span>*</span></td>
       <td>
    
       <select name="ha">
           <option value="Yes">Yes</option>
           <option value="Partial">Partial</option>
           <option value="None">None</option>
           <option value="Na">NA</option>
          </select><br />
      </td>
            
            </tr>
            
            <tr>
              
              <td valign="top"><strong>Description: </strong><span>*</span></td>
              <td>&lt;textarea name="descrip" class="text" cols="45" rows="10" &gt;&lt;?php echo set_value('descrip'); ?&gt;&lt;/textarea&gt;&lt;/td>
   <td>&lt;?php echo form_error('lowProcess'); ?&gt;</td>
            
            </tr>
            
            <tr>  
              <td valign="top"><strong>Class: </strong><span>*</span></td>
              <td>
  
    <select name="class">
     <option value="Platform-Network">Platform-Network</option>
     <option value="Platform-Server">Platform-Server</option>
     <option value="Platform-Storage">Platform-Storage</option>
     <option value="Application">Application</option>
     <option value="Infrastructure Service">Infrastructure Service</option>
    </select><br />
    </td>

some of this code from the view is cut off as it doesn fit, but I tried to include important info. But if you have any suggestions why it is not doing an insert please let me know that would be super great!!!!


Messages In This Thread
insert not working. - by El Forum - 06-11-2012, 11:29 AM
insert not working. - by El Forum - 06-11-2012, 11:55 AM
insert not working. - by El Forum - 06-11-2012, 12:01 PM
insert not working. - by El Forum - 06-11-2012, 12:03 PM
insert not working. - by El Forum - 06-11-2012, 12:05 PM
insert not working. - by El Forum - 06-11-2012, 12:10 PM
insert not working. - by El Forum - 06-11-2012, 12:12 PM
insert not working. - by El Forum - 06-11-2012, 12:14 PM
insert not working. - by El Forum - 06-11-2012, 12:16 PM
insert not working. - by El Forum - 06-11-2012, 12:17 PM
insert not working. - by El Forum - 06-11-2012, 12:20 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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