This is my first OOP php app and I'm getting a little stumped here...
I created the following class that extends the CI_Model
class LXCoreModel extends CI_Model
{
function __construct()
{
parent::__construct();
}
public function elementExists($table, $row, $data)
{
$result = $this->db
->select('*')
->from($table)
->where($row, $data)
->get()
->result();
if (empty($result))
return false;
return true;
}
}
And here is the class extending the class above:
class LXAccAdminModel extends LXCoreModel
{
function __construct()
{
parent::__construct();
}
function addAccountStatus($statusId = NULL, $username = NULL)
{
if ($statusId == NULL)
$statusId = $this->input->post('accountStatusId');
if ($username == NULL)
$username = $this->input->post('username');
if (elementExists('accounts', 'username', $username))
if (elementExists('statuses', 'id', $statusId)) {
$this->db
->insert('accountstatus', array(
'statusid' => $statusId,
'username' => $username
));
return true;
}
return false;
}
}
Both classes are in the CI_Model directory, and the class LXCoreModel is autoloaded (the line $autoload['model'] = array('LXCoreModel'); exists in the autoload.php file) and yet, when I try to run my code I get this error:
Fatal error: Call to undefined function elementExists() in C:\wamp\www\CI_APP\application\models\LXAccAdminModel.php on line 25