1

だから私は自分のアプリの CRUD を作ろうとしていました。次のようにコントローラーをセットアップしました。

class Clients extends CI_Controller {


public function __construct() {
    parent::__construct();
    session_start();
    $this->c = new Client();
    $this->u = new User();
}

function index() {
    $data['current_view'] = 'client_view';
    $data['header'] = 'Меню клиентов';

    $data['clients'] = $this->getClients();

    $this->load->view('main_view',$data);
}

function getClients() {

    $this->u->where('username',$_SESSION['username'])->get();

    $c = $this->c->where('user_id',$this->u->id)->get();

    return $c;
}

function delClient() {
    $this->c->where('client_id', $this->uri->segment(3))->delete();

    $this->c->skip_validation()->save();

    $this->index();
}

}

ただし、クライアントで削除を実行しようとすると、db エラーが発生します。

エントリを更新するには、「set」メソッドを使用する必要があります。

ファイル名: C:\OpenServer\domains\localhost\system\database\DB_active_rec.php

ライン番号: 1174

これの原因は何ですか?ここで同様の質問を見つけましたが、そうではないと思います。

編集: クライアント モデル:

class Client extends DataMapper {

public $has_one = array('user');

public function __construct($id = NULL) {
   parent::__construct($id);
}

}
4

1 に答える 1