0

私は、opencart の登録プロセスに変更を加えようとしています。ビューのフォームを変更し、以下に示すように、新しいフィールドを処理するコードを追加した account/customer.php モデルに値がポストされます。

/* add children and links to product categories */
    $this->load->model('account/children');
    //loop childrens names to use key for remaining info
    foreach($data['children-name'] as $key=>$name){
        //re-assign data and purify
        $child['name'] = mysql_real_escape_string($name);
        $child['surname'] = mysql_real_escape_string($data['children-surname'][$key]);
        $child['gender'] = mysql_real_escape_string($data['children-gender'][$key]);
        $child['dob'] = mysql_real_escape_string($data['children-dob'][$key]);
        $child['school'] = mysql_real_escape_string($data['children-school'][$key]);
        $child['unit'] = mysql_real_escape_string($data['children-unit'][$key]);
        $child['height'] = mysql_real_escape_string($data['children-height'][$key]);
        $child['chest'] = mysql_real_escape_string($data['children-chest'][$key]);
        $child['waist'] = mysql_real_escape_string($data['children-waist'][$key]);
        $child['waistToKnee'] = mysql_real_escape_string($data['children-waist-to-knee'][$key]);
        $child['insideLeg'] = mysql_real_escape_string($data['children-inside-leg'][$key]);
        $child['shoeSize'] = mysql_real_escape_string($data['children-shoe-size'][$key]);
        $child['customerId'] = $customer_id;

        //update/create child record
        $this->model_account_children->addChild($child);
    }
    /* end add children and links to product categories */

次に、次のコードを含む相対モデル ファイルを account/children.php に作成しました。

class ModelAccountChildren extends Model {
    public function addChild($data) {
        //create other fields not in $data
        $lastUpdated = date('Y-m-d h:i:s');
        $childCat = getChildCategory($data['school']);
        $dob = date('Y-m-d h:i:s', $date['dob']);
        if($data['gender'] == 'm'){
            $data['gender'] = 'Male';
        }else{
            $data['gender'] = 'Female';
        }
        echo "INSERT INTO " . DB_PREFIX . "customer_children (customer_id, child_name, child_surname, child_gender, child_dob, category_id, child_school, child_unit, child_height, child_chest, child_waist, child_waist_to_knee, child_inside_leg, child_shoe_size, child_last_updated) VALUES (".$data['customerId'].", '".$data['name']."', '".$data['surname']."', '".$data['gender']."', '".$dob."', ".$childCat['category_id'].", '".$data['school']."', '".$data['unit']."', '".$data['unit']."', '".$data['height']."', '".$data['chest']."', '".$data['waist']."', '".$data['waistToKnee']."', '".$data['insideLeg']."', '".$data['shoeSize']."', '".$lastUpdated."')";
        //perform insert
        $this->db->query("INSERT INTO " . DB_PREFIX . "customer_children (customer_id, child_name, child_surname, child_gender, child_dob, category_id, child_school, child_unit, child_height, child_chest, child_waist, child_waist_to_knee, child_inside_leg, child_shoe_size, child_last_updated) VALUES (".$data['customerId'].", '".$data['name']."', '".$data['surname']."', '".$data['gender']."', '".$dob."', ".$childCat['category_id'].", '".$data['school']."', '".$data['unit']."', '".$data['unit']."', '".$data['height']."', '".$data['chest']."', '".$data['waist']."', '".$data['waistToKnee']."', '".$data['insideLeg']."', '".$data['shoeSize']."', '".$lastUpdated."')");
    }

    public function updateChild($data) {

    }

    public function getChildCategory($childSchoolStr){
        $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "category_description WHERE name LIKE '" . $childSchoolStr . "'");

        return $query->row;
    }
}

何らかの理由で、次の行の model/account/customer.php で呼び出した時点で、スクリプトが新しいモデルにアクセスできません。

$this->load->model('account/children');

私は何か間違ったことをしていますか?

4

3 に答える 3

1

チャップスを解決しました。

$childCat = getChildCategory($data['school']);

少し頭がおかしいですが、上記の行は次のようになります。

$childCat = $this->getChildCategory($data['school']);
于 2012-11-14T13:36:15.290 に答える
0

ファイルを確実に に入れましたcatalog/model/account/children.phpか? もしそうなら、これをデバッグするのに役立つエラーメッセージが表示されますか? また、コードを実行するときに、$data['children-name']データが含まれていることを確信していますか?

于 2012-11-14T12:09:24.140 に答える