[eluser]Dan Decker[/eluser]
I'm having a bear of a time getting a model to work. When the model is not loaded, everything works fine. If I load the model anywhere (autoload.php, in the Controller file), it seems to cause the script to stop processing.
I have loaded the model after an echo statement to verify that loading the model is waht is breaking things. I have even built a very bare bones model (testmodel.php whose only purpose was to generate an echo) and even trying to load it broke things.
Environment info: PHP 5.2.5, MySQL 5.0.41 via MAMP on a 2.33 Core2 Duo 24" iMac, 2GB RAM, Mac OS X v10.5.2
Here is my code:
action.php takes input from a form and attempts to log in the user --
Code:
<?php
/*
|The "Action" Controller will do various actions like login and logout the user.
|Currently the plan is that the Action COntroller will also handle various |Ticket entry/edit tasks. This may change based on semantics (are these things |related in some way? Should they be broken out into their own Controller?
*/
class Action extends Controller {
function Action()
{
parent::Controller();
}
function index()
{
//Routes to an "Error Message", prevents direct script access.
$this->load->view('error_message');
}
function login()
{
/*
|Process the Login values against the database (Database class is
|auto-loaded via autoload.php)
|
|Set the user session (Session calss is auto-loaded via autoload.php)
|
|Load the main Ticket management view
*/
$this->load->model('User_model');
if ($this->User_model->user_login())
{
$this->load->view('tickets');
} else {
$this->load->view('error_message');
}
}
}
?>
And here is the model,
user_model.php that is called by
action.php --
Code:
<?php
/*
|This model will handle User based functions. Login/Logout and user account |creation/edit/deletion.
|This model is called by the Action Controller
*/
class User_model extends Model {
function User_model()
{
parent::Model();
}
function user_login()
{
//Security helper is auto-loaded via autoload.php
$u_name = $this->input->post('u_name');
$p_word = dohash($this->input->post('p_word'), 'md5');
$query = $this->db->get_where('ls_ticket_users', array('u_name' => $this->u_name));
$u_check = $query->result();
if ($u_check['p_word'] == $this->p_word)
{
return TRUE;
} else {
return FALSE;
}
}
}
?>
Is there just something simple that I'm missing? I've stared at it for so long that I just can't tell. This is my first attempt at a CI based app, I've done all this is naked php before, but I'm a noob here. BTW, I've verrified that I can get the desired info out of my database, but it dorks up when I try to apply it in the model.
My only theory at this point is that Models are broken in CI with 1.6.1, but I
KNOW that's not true ;-)
Let me know if there is anything else I can provide. I'd love to get this worked out, I love CI!