PHP を使用して e コマース Web サイトを作成し、XAMPP 経由でロードしています。ただし、次のエラーが発生しました: 致命的なエラー: クラス 'Modelmyaccount' が見つかりません
XDebug を有効にして NetBeans を使用してデバッグを試みたところ、次のコール スタックが発生しました。
Call Stack
1. {main}( ) ..\index.php:0
2. require_once( 'E:\xampp\htdocs\promotion\system\codeigniter\CodeIgniter.php' ) ..\index.php:117
3. myshop->__construct( ) ..\CodeIgniter.php:201
4. CI_Loader->model( ???, ???, ??? ) ..\myshop.php:7
クラスが存在することを確認しましたが、認識していないようです。
以下の太字で強調表示されているのは、$name に格納するクラス名が見つからない部分です。
if ( ! class_exists('Model'))
{
load_class('Model', FALSE);
}
**require_once(APPPATH.'models/'.$path.$model.EXT);**
$model = ucfirst($model);
$CI->$name = new $model();
$CI->$name->_assign_libraries();
$this->_ci_models[] = $name;
}
以下の「modelmyaccount」および「Model」クラスも参照してください。
<?
class modelmyaccount extends Model{
protected $table_name = 'consumer_master';
function __construct()
{
parent::Model();
$this->table_country_master = 'country_master';
//$this->table_country_detail = 'country_detail';
$this->table_state_master = 'state_master';
//$this->table_state_detail = 'state_detail';
}
function checkEmail()
{
$fetch_user = "SELECT count(*) AS CNT FROM ".$this->table_name."
WHERE email = '".addslashes($_POST['email'])."'
";
$fetch_result=$this->db->query($fetch_user);
if($fetch_result->num_rows() > 0) {
$row=$fetch_result->row_array();
if($row['CNT'] == 0) {
return true;
}else {
return false;
}
}
}
function updateMember($member_id)
{
$dt = explode("-",addslashes($_POST['birth_date']));
$birth_date = $dt[2]."-".$dt[0]."-".$dt[1];
$saveSql = "UPDATE ".$this->table_name."
SET first_name = '".addslashes($_POST['first_name'])."',
last_name = '".addslashes($_POST['last_name'])."',
streetname = '".addslashes($_POST['address1'])."',
dob = '".$birth_date."',
interest = '".addslashes($_POST['interest'])."',
country = '".addslashes($_POST['country'])."',
state = '".addslashes($_POST['state'])."',
city = '".addslashes($_POST['city'])."',
postal = '".addslashes($_POST['zip'])."',
edit_date = NOW()
WHERE consumer_id = '".$member_id."'
";
//echo $saveSql;
//exit;
$saveResult = $this->db->query($saveSql);
return true;
}
/*function delMyFav($member_id, $topic_type)
{
$sql_del = "DELETE FROM favourite_master
WHERE member_id='".$member_id."'
AND topic_type='".$topic_type."'";
$result = $this->db->query($sql_del);
}*/
function checkConfirmation($emailId)
{
$sql = "SELECT status FROM ".$this->table_name."
WHERE email ='".base64_decode($emailId)."'";
$res = $this->db->query($sql);
if($res->num_rows() > 0) {
$row = $res->row_array();
if($row['status']=='A')
return false;
else
return true;
}
}
function confirmMember($emailId)
{
$confirmSql = "UPDATE ".$this->table_name. "
SET status = 'A'
WHERE email ='".base64_decode($emailId)."'";
$confirmResult = $this->db->query($confirmSql);
if($confirmResult) {
return true;
}
}
function getCountry()
{
$sql = " SELECT CM.*
FROM " .$this->table_country_master. " AS CM
WHERE CM.is_active ='Y'";
$recordSet = $this->db->query($sql);
if($recordSet) {
if($recordSet->num_rows() > 0) {
foreach($recordSet->result_array() as $key =>$val) {
$rs[]=$val;
}
}
} else {
return false;
}
return $rs ;
}
function getMemberById($member_id)
{
$sql = "SELECT * FROM ".$this->table_name." WHERE consumer_id = '".$member_id."'";
$recordset = $this->db->query($sql);
if($recordset->num_rows() > 0){
foreach($recordset->result_array() as $key=>$val){
$rs[] = $val;
}
}else{
return false;
}
return $rs;
}
function validateOldPassword($id)
{
$this->old_pwd = $this->input->request('old_pwd','');
$sql = " SELECT count(*) AS CNT
FROM ".$this->table_name."
WHERE consumer_id ='".$id."'
AND password ='".$this->old_pwd."'
";
$rs = $this->db->query($sql);
if($rs) {
if($rs->num_rows() > 0) {
$row = $rs->row_array();
if($row['CNT'] > 0) {
return true;
} else {
return false;
}
} else {
return false;
}
} else {
return false;
}
}
/*
function valideNewPassword
This function to check the New Password and Confirm New Password will be same or not
if both are the same then return true else return false
*/
function validateNewPassword()
{
$this->new_pwd = $this->input->request('new_pwd','');
$this->conf_new_pwd = $this->input->request('con_pwd','');
if($this->new_pwd!='' && $this->conf_new_pwd!='') {
if($this->new_pwd===$this->conf_new_pwd) {
return true;
} else {
return false;
}
} else {
return false;
}
}
function updatePassword($id)
{
$this->new_pwd = $this->input->request('new_pwd','');
$sql = " UPDATE ".$this->table_name."
SET password = '".$this->new_pwd."'
WHERE consumer_id ='".$id."'
";
$rs = $this->db->query($sql);
if($rs) {
return true;
} else {
return false;
}
}
function newsletterSubscription($subscriberEmail)
{
$sql = "SELECT subscriber_email
FROM newsletter_subscriber
WHERE subscriber_email = '".$subscriberEmail."'
AND is_active = 'Y'
";
//echo $sql;
$rs = $this->db->query($sql);
if($rs){
if($rs->num_rows() > 0){
return true;
}else{
return false;
}
}
}
function subscribeNewsletter($subscriberEmail)
{
$sql = "
INSERT INTO newsletter_subscriber
SET
subscriber_email = '".$subscriberEmail."',
is_active = 'Y',
db_add_date = NOW(),
db_edit_date = NOW()
";
//echo $sql;
$rs = $this->db->query($sql);
if($rs){
return true;
}else{
return false;
}
}
function unSubscribeNewsletter($subscriberEmail)
{
$sql = "
DELETE FROM newsletter_subscriber
WHERE
subscriber_email = '".$subscriberEmail."'
";
$rs = $this->db->query($sql);
if($rs){
return true;
}else{
return false;
}
}
}
?>
----------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 4.3.2 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
* @copyright Copyright (c) 2008 - 2009, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
/**
* CodeIgniter Model Class
*
* @package CodeIgniter
* @subpackage Libraries
* @category Libraries
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/libraries/config.html
*/
class Model {
var $_parent_name = '';
/**
* Constructor
*
* @access public
*/
function Model()
{
// If the magic __get() or __set() methods are used in a Model references can't be used.
$this->_assign_libraries( (method_exists($this, '__get') OR method_exists($this, '__set')) ? FALSE : TRUE );
// We don't want to assign the model object to itself when using the
// assign_libraries function below so we'll grab the name of the model parent
$this->_parent_name = ucfirst(get_class($this));
log_message('debug', "Model Class Initialized");
}
/**
* Assign Libraries
*
* Creates local references to all currently instantiated objects
* so that any syntax that can be legally used in a controller
* can be used within models.
*
* @access private
*/
function _assign_libraries($use_reference = TRUE)
{
$CI =& get_instance();
foreach (array_keys(get_object_vars($CI)) as $key)
{
if ( ! isset($this->$key) AND $key != $this->_parent_name)
{
// In some cases using references can cause
// problems so we'll conditionally use them
if ($use_reference == TRUE)
{
$this->$key = NULL; // Needed to prevent reference errors with some configurations
$this->$key =& $CI->$key;
}
else
{
$this->$key = $CI->$key;
}
}
}
}
}
// END Model Class
/* End of file Model.php */
/* Location: ./system/libraries/Model.php */