[eluser]Avril[/eluser]
Hello,
I've made a model that will insert some data in my DB, model is called by using a controller.
I get the standard "cannot redeclare class" error message when executing the model.
Quote:Fatal error: Cannot redeclare class Expenses in /Users/avrilverhaeghen/Sites/myBudget/application/models/expenses.php on line 44
This is my model:
Code:
<?php
class Expenses extends Model {
function new_expense($data){
$query = $this->db->get_where('bank_account_link', array($data['account_id']));
foreach($query->result() as $row){
$data['bank_account_number'] = $row['bank_account_number'];
}
if(isset($data['bank_account_number'])){
$insert = $this->db->insert('expenses', $data);
if($insert == TRUE){
return TRUE;
}else{
return FALSE;
}
}else{
return FALSE;
}
}
}
And the method in the controller:
Code:
function new_expense(){
$data = array(
'account_id' => $this->authenticator->get_uid(),
'type' => $this->input->post('expense_type'),
'amount' => $this->input->post('expense_amount')
);
$this->load->model('expenses');
$insert_new_expense = $this->expenses->new_expense($data);
if($insert_new_expense == TRUE){
echo "Insert OK";
}else{
echo "Insert NOT OK, please contact the Administrator";
}
}
I used the echo to check if it's working, they will be changed after it's working.
I don't where I went wrong when calling the model, I used the same technique in the same project and there it's working.
Thanks!