[eluser]44kyle[/eluser]
Hey guys, I'm having an issue calling my model from my controller for some reason in 2.0. Here is my code.
Controller:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Welcome extends CI_Controller {
function __construct()
{
parent::__construct();
}
public function index()
{//echo "HERE";die;
$this->load->view('insert');
}
public function insertrecord()
{ //echo "HERE";die;
$this->Welcome->insert_entry();
}
public function deleteRecord($id='')
{
$this->Welcome->deleteRecord($id);
$this->displayResults();
}
public function displayresults()
{
$data['results'] = $this->Welcome->getAllRecords();
$this->load->view('results',$data);
}
}
Model:
<?php
class Welcome extends CI_Model{
function __construct()
{
parent::__construct();
}
function insert_entry()
{echo "HERE";die;
$this->fname = $this->input->post("fname");
$this->lname = $this->input->post("lname");
$this->email = $this->input->post("email");
$this->db->insert('people.information', $this);
print "inserted";die;
}
function getAllRecords()
{echo "HERE2";die;
$this->load->database();
$data = $this->db->query("SELECT * FROM people.information");
foreach ($data->result()() as $row)
{//var_dump($row);die;
$return['fname'] = $row['fname'];
$return['lname'] = $row['lname'];
$return['email'] = $row['email'];
//var_dump($return);die;
}
//var_dump($return);die;
return $return;
}
function update_entry()
{
$this->fname = $_POST['fname'];
$this->lname = $_POST['lname'];
$this->email = $_POST['email'];
$this->db->update('people.information', $this, array('id' => $_POST['id']));
}
public function deleteRecord($id)
{
$this->db->delete('people.information', array('id' => $id));
}
}
?>
I'm calling
$autoload['model'] = array('Welcome');
in my autoload php script. For some reason this isn't working the way it should. Can someone see what I'm missing?
Thanks in advance!