php - My extended CodeIgniter 2.0.2 class doesn't see it's parent class methods -
php - My extended CodeIgniter 2.0.2 class doesn't see it's parent class methods -
this first oop php app , i'm getting little stumped here...
i created next class extends 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; homecoming true; } } and here class extending 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)); homecoming true;} homecoming false; } } both classes in model diretory, , class lxcoremodel autoloaded (the line $autoload['model'] = array('lxcoremodel'); exists in autoload.php file) , yet, when seek run code error:
fatal error: phone call undefined function elementexists() in c:\wamp\www\ci_app\application\models\lxaccadminmodel.php on line 25
thanks time! :)
you're calling elementexists(), not method of class.
try:
$this->elementexists(); or lxaccadminmodel:
parent::elementexists(); $this->elementexists() should suffice in both cases, $this referring current class.
php codeigniter-2
Comments
Post a Comment