私は Doctrine 2.3 との協力を終了することに決めました。今は CodeIgniter のみを使用してデータベースに接続したいと考えています。私のコードのどこに問題があるのか分かりますか?
私が得るこのエラー:
A PHP Error was encountered
Severity: Notice
Message: Undefined property: Hello::$db
Filename: core/Model.php
Line Number: 51
データベース.php
$db['default']['hostname'] = 'localhost:8080';
$db['default']['username'] = 'root';
$db['default']['password'] = '';
$db['default']['database'] = 'ci_doctrine';
$db['default']['dbdriver'] = 'mysql';
コントローラ
<?php
// system/application/controllers/hello.php
class Hello extends CI_Controller {
public function __construct()
{
parent::__construct();
}
function world() {
echo "Hello CodeIgniter!";
}
function user_test() {
$this->load->model('user');
$this->user->save_User('username','password','first_name','last_name');
}
}
?>
モデル - データベース内のテーブル名「user」
<?php
// system/application/models/user.php
class User extends CI_Model {
function __construct()
{
// Call the Model constructor
parent::__construct();
}
function save_User($username,$password,$fName,$lName) {
$this->username = $username;
$this->password = $password;
$this->first_name = $fName;
$this->last_name = $lName;
$this->db->insert('user', $this);
}
}
?>