これは私の最初の OOP php アプリで、ここで少し困惑しています...
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;
}
}
上記のクラスを拡張したクラスは次のとおりです。
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;
}
}
両方のクラスは Model ディレクトリにあり、クラス LXCoreModel は自動ロードされます (行 $autoload['model'] = array('LXCoreModel'); は autoload.php ファイルに存在します)。次のエラーが表示されます。
致命的なエラー: 25 行目の C:\wamp\www\CI_APP\application\models\LXAccAdminModel.php の未定義関数 elementExists() の呼び出し
御時間ありがとうございます!:)