Reputation: 8086
Ok I stripped out validation and other code to make this example as transparent as possible. I am unable to POST
a VAR to my MODEL.
<?php echo form_open('invoice'); ?>
<?php echo validation_errors(); ?>
<?php echo form_input('order_num', $this->input->post('order_num')); ?>
<?php echo form_submit('submit','submit'); ?>
<?php echo form_close(); ?>
public function invoice()
{
$order = $this->input->post('order_num');
$this->General_Model->get_customer_order($order);
}
function get_customer_order($order)
{
. . .
$this->db->where('client_orders.id', $order);
$result = $this->db->get('client_orders');
. . .
}
Ok Basically you enter an order number on the form. Then it goes to the controller which does the validation (i removed it here to keep example simple) and finally it passes the data to the model which runs the query on the db and returns the $result
.
However instead of my desired output im getting: Fatal error: Call to a member function get_customer_order() on a non-object and A PHP Error was encountered Severity: Notice Message: Undefined property: Account_dashboard::$General_Model
What am I doing wrong here? Thanks for the help.
Upvotes: 1
Views: 9654
Reputation: 18705
Make sure you're loading the model in your controller:
$this->load->model('General_Model');
The controller line should
$data['order'] = $this->General_Model->get_customer_order($order);
Then you pass $data to the view.
Upvotes: 1